Skip to content

Potential fix for code scanning alert no. 5: Flask app is run in debug mode - #8

Merged
Rashed-alothman merged 1 commit into
mainfrom
alert-autofix-5
Dec 21, 2025
Merged

Potential fix for code scanning alert no. 5: Flask app is run in debug mode#8
Rashed-alothman merged 1 commit into
mainfrom
alert-autofix-5

Conversation

@Rashed-alothman

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/Rashed-alothman/TMS/security/code-scanning/5

In general, the problem is fixed by ensuring that the Flask development server is not started with debug=True in production. This usually means either removing the debug=True argument entirely (defaulting to False), or making it conditional on a clear development flag (for example, an environment variable).

For this specific code, the least intrusive fix that preserves functionality is to remove the hard‑coded debug=True and instead read a boolean from an environment variable, defaulting to False. That way:

  • In production, with no environment variable set, debug is off.
  • For local development, the developer can explicitly opt in by setting FLASK_DEBUG=1 (or similar) before running the script.

Concretely, in app.py around line 170–171, we should:

  • Import os near the other imports.
  • Replace app.run(debug=True, host='0.0.0.0', port=5000) with a call that computes a debug flag from os.environ.get("FLASK_DEBUG", "0"), such as:
    debug_mode = os.environ.get("FLASK_DEBUG", "0") == "1"
    app.run(debug=debug_mode, host='0.0.0.0', port=5000)

This change keeps the existing behavior easy to reproduce for development (set FLASK_DEBUG=1) while preventing accidental debug mode in production.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…g mode

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Rashed-alothman
Rashed-alothman marked this pull request as ready for review December 21, 2025 12:45
@Rashed-alothman
Rashed-alothman merged commit eb8f3b8 into main Dec 21, 2025
11 checks passed
@Rashed-alothman
Rashed-alothman deleted the alert-autofix-5 branch December 21, 2025 12:52
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.

1 participant