Skip to content

Potential fix for code scanning alert no. 61: Information exposure through an exception - #126

Merged
dvir001 merged 2 commits into
mainfrom
alert-autofix-61
Nov 2, 2026
Merged

dvir001 merged 2 commits into
mainfrom
alert-autofix-61

Conversation

@dvir001

@dvir001 dvir001 commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/dvir001/Simple-Org-Chart/security/code-scanning/61

Best practice is to keep detailed exception info in server logs only, and return sanitized/generic status to clients. Here, the safest minimal fix is in simple_org_chart/app_main.py where the API response is assembled: before returning settings, copy and sanitize dataUpdateStatus so any error field is replaced with a generic message.

Single best fix without changing core functionality:

  • In handle_settings() GET branch (around lines 996–1000), stop assigning load_data_update_status() directly into response.
  • Instead:
    • Load status into a local variable.
    • If it is a dict and contains a truthy error, replace that field with a generic string like "An internal error occurred during data update.".
    • Put sanitized status into settings['dataUpdateStatus'].
  • No new dependencies are required.

This preserves endpoint behavior and status structure while preventing exception detail disclosure.

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

…rough an exception

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@dvir001
dvir001 marked this pull request as ready for review November 2, 2026 21:42
Copilot AI balanced review requested due to automatic review settings November 2, 2026 21:42
@dvir001

dvir001 commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

@copilot Fix Docker Image CI / build (pull_request) in this PR also

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the settings API error-sanitization change.

No open issues 🎉

What changed in this PR

This PR addresses code-scanning alert #61 by sanitizing data-update errors returned by the settings API.

Changes:

  • Replaces a truthy dataUpdateStatus.error with a generic message.
  • Copies the status before sanitizing it, preserving the original object and other status fields.
File Description
simple_org_chart/​app_main.py Sanitizes data-update error details in the settings GET response.

Review effort: Balanced

Co-authored-by: dvir001 <39403717+dvir001@users.noreply.github.com>

Copilot AI commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@copilot Fix Docker Image CI / build (pull_request) in this PR also

Fixed by pinning Pillow to 12.3.0, which supports the Docker image’s Python 3.10 runtime. The local Docker image build succeeds. Commit: 0231e95.

@dvir001
dvir001 merged commit a795bd1 into main Nov 2, 2026
6 checks passed
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.

3 participants