Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(notebookviewer): upgrade dependencies to resolve ECR scan findings #72

Merged

Conversation

benforshey
Copy link
Contributor

No description provided.

@benforshey benforshey self-assigned this Dec 20, 2024
@@ -1,15 +1,16 @@
ARG REGISTRY
FROM ${REGISTRY}python:3.9.1
FROM ${REGISTRY}python:3.13.1-alpine
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Alpine versions of docker had no security vulnerabilities on DockerHub scans, so I chose it. Sometimes Alpine Linux doesn't work with the app's dependencies, but in this case the app is so simple it works well.

@@ -6,9 +6,12 @@
from lib.html_exporter import html_exporter

# only notebooks from these domains are allowed
DOMAIN_WHITELIST_REGEX = "^https://([a-zA-Z0-9]+\.)*(nasa\.gov|github\.com|githubusercontent\.com)\/?.*"
DOMAIN_WHITELIST_REGEX = (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added r to tell Pyright that this string literal should use regex escaping.

@@ -17,39 +20,43 @@ def getNotebookAsHtml():

def convertNotebookToHtml():
# ensure the user passed in a notebook url
if request.args.get('notebookUrl') == None:
if request.args.get("notebookUrl") is None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None should be compared with is, according to Ruff. All other changes are just the Ruff / Black formatter.

Jinja2==3.1.4
nbconvert==7.16.4
nbformat==5.10.4
gunicorn==23.0.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds Gunicorn for use as a production server. Upgrades dependencies for vulnerability mitigation.

@benforshey
Copy link
Contributor Author

Python ECR Results:
Screenshot 2024-12-20 at 1 12 10 PM

Notebook Viewer ECR Results:
Screenshot 2024-12-20 at 1 13 20 PM


WORKDIR /usr/src/app

COPY . .

RUN pip install -r requirements.txt

CMD python -m flask run --host=0.0.0.0 --port 8080
CMD ["gunicorn", "-b", "0.0.0.0:8080", "app:app"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning behind running gunicorn for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flask is a development server, so in their server logs they output something like "this is a development server; don't run it in production". In their docs, they recommend a number of WSGI servers to choose from. gunicorn is one that I've used before, so I picked it based on familiarity.

@benforshey benforshey merged commit 0a0e0f7 into main Jan 2, 2025
3 of 5 checks passed
@benforshey benforshey deleted the feature/MEDITOR-928-address-vulnerabilities-in-notebookviewer branch January 2, 2025 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants