-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
with heavy heart I write these lines. on one side, the customer, the other security.
- Loading branch information
mike dupont
committed
Sep 16, 2023
1 parent
2103b9b
commit ab82b10
Showing
4 changed files
with
65 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# #begin inject | ||
|
||
# from streamlit.web.server.server import Server | ||
# server_create_app_backup = Server._create_app | ||
|
||
# def server_create_app_hack(self): | ||
# app = server_create_app_backup(self) | ||
# print("PATCH",app) | ||
|
||
|
||
# return app | ||
# Server._create_app=server_create_app_hack | ||
|
||
|
||
#begin inject | ||
from streamlit.web.server.server import Server | ||
import streamlit as st | ||
server_create_app_backup = Server._create_app | ||
def server_create_app_hack(self): | ||
app = server_create_app_backup(self) | ||
print("PATCH",app) | ||
st.write(app) | ||
return app | ||
Server._create_app=server_create_app_hack |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import streamlit.web.server.server | ||
import inspect | ||
import os.path | ||
target = "backups" | ||
#st.write(inspect.getsourcefile(streamlit.web.server.server)) | ||
INJECT=""" | ||
import streamlit.web.server.inject | ||
""" | ||
|
||
def patch_server(): | ||
#copy a backup of server code | ||
target = inspect.getsourcefile(streamlit.web.server.server) | ||
inject_target = target.replace("/server.py","/inject.py",) | ||
backups = "backups" | ||
backup = os.path.join(backups,"server_old.py") | ||
inject_source = os.path.join(backups,"inject.py") | ||
if not os.path.exists(backup): | ||
with open(backup,"w") as fo: | ||
with open(target,"r") as fi: | ||
fo.write(fi.read()) | ||
# patch the file | ||
with open(backup,"r") as fi: | ||
with open(target,"w") as fo: | ||
fo.write(fi.read()) | ||
fo.write(INJECT) | ||
|
||
# write the injection target, safer | ||
with open(inject_target,"w") as fo: | ||
with open(inject_source,"r") as fi: | ||
fo.write(fi.read()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters