Skip to content

Commit 16e60e3

Browse files
authored
Merge pull request #307 from GaneshPatil7517/fix/security-fri-server
2 parents 098f4a5 + 37cbd17 commit 16e60e3

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

Dockerfile.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ 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+
ARG MATLAB_RUNTIME_SHA256="b821022690804e498d2e5ad814dccb64aab17c5e4bc10a1e2a12498ef5364e0d"
13+
ENV MATLAB_RUNTIME_SHA256=${MATLAB_RUNTIME_SHA256}
14+
15+
RUN wget https://ssd.mathworks.com/supportfiles/downloads/R2021a/Release/1/deployment_files/installer/complete/glnxa64/MATLAB_Runtime_R2021a_Update_1_glnxa64.zip \
16+
&& echo "${MATLAB_RUNTIME_SHA256} MATLAB_Runtime_R2021a_Update_1_glnxa64.zip" | sha256sum -c -
1317

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

fri/server/main.py

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

1515

1616
app = Flask(__name__)
17-
app.secret_key = "secret key"
17+
secret_key = os.environ.get("FLASK_SECRET_KEY")
18+
if not secret_key:
19+
# In production, require an explicit FLASK_SECRET_KEY to be set.
20+
# For local development and tests, fall back to a per-process random key
21+
# so that importing this module does not fail hard.
22+
if os.environ.get("FLASK_ENV") == "production":
23+
raise RuntimeError("FLASK_SECRET_KEY environment variable not set in production")
24+
secret_key = os.urandom(32)
25+
app.secret_key = secret_key
1826

1927
cors = CORS(app)
2028
app.config['CORS_HEADERS'] = 'Content-Type'
@@ -431,4 +439,6 @@ def openJupyter():
431439

432440

433441
if __name__ == "__main__":
434-
app.run(host="0.0.0.0", port=5000)
442+
# In production, use:
443+
# gunicorn -w 4 -b 0.0.0.0:5000 fri.server.main:app
444+
app.run(host="0.0.0.0", port=5000, debug=False)

0 commit comments

Comments
 (0)