-
Notifications
You must be signed in to change notification settings - Fork 3
π§ Security hardening fixes #1319
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
Open
aymankanso
wants to merge
19
commits into
main
Choose a base branch
from
security-hardening-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3dae0dd
Security hardening: Fix critical vulnerabilities across all categories
aymankanso b7b7cbc
Security enhancements: Additional fixes and improvements
aymankanso 8d26522
fix
aymankanso a64b711
fix2
aymankanso ce96896
replace python-magic-bin with python-magic in requirements.txt
aymankanso 641c438
Merge branch 'dev' into security-hardening-fixes
aymankanso 0671b5c
Fix formatting to satisfy Black
aymankanso 2d40af3
Fix formatting to satisfy Black
aymankanso 48c59ea
Fixes
aymankanso b14477d
Merge branch 'dev' into security-hardening-fixes
robert-dm 6c12cb2
update Python dependencies
aymankanso 83df25f
new fixes
aymankanso da6baa1
formatting
aymankanso b651dd3
requirements fix
aymankanso fd8ca06
requirements fixed
aymankanso cc31c42
requirements fixed
aymankanso 4a12402
fixes
aymankanso 8a34de2
changes
aymankanso 795d797
fix
aymankanso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -13,5 +13,4 @@ pyproject.toml000 | |
.DS_Store | ||
app.log | ||
backend/app.log | ||
tests/.env | ||
tests/cypress/screenshots/ | ||
tests/.env |
This file contains hidden or 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
web: cd backend && gunicorn --workers 1 --threads 256 --worker-class eventlet manage:app | ||
web: cd backend && gunicorn --workers 1 --threads 256 --worker-class gevent manage:app | ||
worker: cd backend && python manage.py runworker | ||
clock: python backend/scripts/emails.py |
This file contains hidden or 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 |
---|---|---|
@@ -1,4 +1,28 @@ | ||
!api | ||
# Exclude everything by default | ||
* | ||
|
||
# Include only necessary files | ||
!api/ | ||
!manage.py | ||
!requirements.txt | ||
!creds.ini | ||
!firebase_service_key.json | ||
!scripts.py | ||
|
||
# Explicitly exclude sensitive files (even if included above) | ||
.env | ||
.env.* | ||
*.log | ||
__pycache__/ | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
.git/ | ||
.gitignore | ||
.pytest_cache/ | ||
.coverage | ||
.DS_Store | ||
Thumbs.db | ||
*.key | ||
*.pem | ||
*.p12 | ||
user_options.json |
Binary file not shown.
This file contains hidden or 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 |
---|---|---|
|
@@ -2,14 +2,12 @@ | |
FROM python:3.9 | ||
LABEL maintainer "Kelley Chau <[email protected]>" | ||
|
||
COPY requirements.txt requirements.txt | ||
RUN apt-get update -y && \ | ||
apt-get install -y python3-dev python3-pkg-resources python3-setuptools python3-wheel python3-pip | ||
WORKDIR /app | ||
|
||
RUN pip install -r requirements.txt | ||
COPY requirements.txt requirements.txt | ||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
|
||
ENTRYPOINT [ "python" ] | ||
|
||
|
This file contains hidden or 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 hidden or 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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import pyrebase | ||
import os | ||
from api.utils.secure_env import SecureEnvironmentManager | ||
|
||
client = pyrebase.initialize_app( | ||
{ | ||
"apiKey": os.environ.get("FIREBASE_API_KEY"), | ||
"apiKey": SecureEnvironmentManager.get_required_env("FIREBASE_API_KEY"), | ||
"authDomain": "mentee-d0304.firebaseapp.com", | ||
"databaseURL": "", | ||
"storageBucket": "mentee-d0304.appspot.com", | ||
"serviceAccount": os.environ.get("GOOGLE_APPLICATION_CREDENTIALS"), | ||
"serviceAccount": SecureEnvironmentManager.get_optional_env( | ||
"GOOGLE_APPLICATION_CREDENTIALS" | ||
), | ||
} | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aymankanso please explain these lines and how it will impact when deployed in Heroku
Copy only necessary application files
COPY api/ /app/api/
COPY manage.py /app/
COPY firebase_service_key.json /app/
COPY scripts.py /app/
Change ownership to non-root user
RUN chown -R appuser:appuser /app
Switch to non-root user
USER appuser