-
Notifications
You must be signed in to change notification settings - Fork 228
fix: remove unused http import and set stable secret key fallback #503
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||
|
|
||||||
| from http import HTTPStatus | ||||||
|
|
||||||
| from flask import Flask, render_template, request, redirect, url_for, session, jsonify, flash | ||||||
| import sqlite3 | ||||||
| import os | ||||||
|
|
@@ -18,7 +18,7 @@ | |||||
| pass | ||||||
|
|
||||||
| app = Flask(__name__) | ||||||
| app.secret_key = os.environ.get("SECRET_KEY", secrets.token_hex(16)) | ||||||
| app.secret_key = os.environ.get("SECRET_KEY" ,"dev-secret-key-change-me") | ||||||
| app.permanent_session_lifetime = timedelta(days=30) | ||||||
|
|
||||||
| # Session security configuration | ||||||
|
|
@@ -38,7 +38,7 @@ def make_session_permanent(): | |||||
| DB_PATH = os.path.join(os.path.dirname(__file__), "ams.db") | ||||||
|
|
||||||
| # Define upload folder path for certificates | ||||||
| UPLOAD_FOLDER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static", "uploads") | ||||||
| UPLOAD_FOLDER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static" "uploads") | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Python's implicit string literal concatenation turns
Suggested change
Prompt to fix with AI
|
||||||
| os.makedirs(UPLOAD_FOLDER, exist_ok=True) | ||||||
|
|
||||||
|
|
||||||
|
|
||||||
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.
Any deployment that omits the
SECRET_KEYenv var will use the publicly visible string"dev-secret-key-change-me", allowing an attacker to forge signed session cookies. The previous defaultsecrets.token_hex(16)was randomly generated per process, which was safer.Prompt to fix with AI