Skip to content

Commit 62f8b28

Browse files
security: remove hardcoded Flask secret, disable debug mode, add SHA256 verification (Issue #272)
1 parent c4602ec commit 62f8b28

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

Dockerfile.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ RUN mkdir /mcr-install \
99

1010
WORKDIR /mcr-install
1111

12-
RUN wget https://ssd.mathworks.com/supportfiles/downloads/R2021a/Release/1/deployment_files/installer/complete/glnxa64/MATLAB_Runtime_R2021a_Update_1_glnxa64.zip
12+
ENV MATLAB_RUNTIME_SHA256="b821022690804e498d2e5ad814dccb64aab17c5e4bc10a1e2a12498ef5364e0d"
13+
14+
RUN wget https://ssd.mathworks.com/supportfiles/downloads/R2021a/Release/1/deployment_files/installer/complete/glnxa64/MATLAB_Runtime_R2021a_Update_1_glnxa64.zip \
15+
&& echo "${MATLAB_RUNTIME_SHA256} MATLAB_Runtime_R2021a_Update_1_glnxa64.zip" | sha256sum -c -
1316

1417
RUN unzip MATLAB_Runtime_R2021a_Update_1_glnxa64.zip \
1518
&& ./install -destinationFolder /opt/mcr -agreeToLicense yes -mode silent \

fri/server/main.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515

1616
app = Flask(__name__)
17-
app.secret_key = "secret key"
17+
app.secret_key = os.environ.get("FLASK_SECRET_KEY")
18+
if not app.secret_key:
19+
raise RuntimeError("FLASK_SECRET_KEY environment variable not set")
1820

1921
cors = CORS(app)
2022
app.config['CORS_HEADERS'] = 'Content-Type'
@@ -407,4 +409,6 @@ def openJupyter():
407409

408410

409411
if __name__ == "__main__":
410-
app.run(host="0.0.0.0", port=5000)
412+
# In production, use:
413+
# gunicorn -w 4 -b 0.0.0.0:5000 main:app
414+
app.run(host="0.0.0.0", port=5000, debug=False)

0 commit comments

Comments
 (0)