mirror of
https://github.com/atiilla/GeoIntel.git
synced 2026-04-26 16:15:57 +03:00
[PR #17] [MERGED] Potential fix for code scanning alert no. 34: Information exposure through an exception #18
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/GeoIntel#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/atiilla/GeoIntel/pull/17
Author: @atiilla
Created: 3/9/2026
Status: ✅ Merged
Merged: 3/9/2026
Merged by: @atiilla
Base:
main← Head:alert-autofix-34📝 Commits (2)
61fca7bPotential fix for code scanning alert no. 34: Information exposure through an exception16c233aMerge branch 'main' into alert-autofix-34📊 Changes
2 files changed (+6 additions, -1 deletions)
View changed files
📝
geointel/geointel.py(+2 -0)📝
geointel/web_server.py(+4 -1)📄 Description
Potential fix for https://github.com/atiilla/GeoIntel/security/code-scanning/34
General approach: Ensure that client-facing responses never include raw exception messages or type names. Instead, log detailed error information on the server and return generic messages. Specifically, adjust
GeoIntel.locateso that on errors it returns a safe, generic error structure withoutstr(e)ortype(e).__name__, and, in the web handler, avoid blindly returning whateverresultcontains on error.Best concrete fix with minimal behavior change:
In
geointel/geointel.py, update the twoexceptblocks inGeoIntel.locate:str(e)andexc_info=True.str(e)or the exception class name. For example:GeoIntelError:"error": "Request cannot be processed"and optionally a generic"details": "GeoIntelError"or omitdetails.Exception:"error": "An unexpected error occurred"and omit or genericizedetails."error"key when something goes wrong, but without internal detail.In
geointel/web_server.py’sanalyze_image:jsonify(result), 400directly when'error' in result, wrap it into a safer structure that does not trust arbitrary contents fromGeoIntel.locate. For example:error_message = result.get("error") or "Request could not be processed"but clamp it to a short, non-technical message.resultentirely and always return a fixed generic 400 for these cases, but that is a slightly larger behavior change.Given the information-exposure focus, the single most impactful change is to sanitize what
GeoIntel.locatereturns, removing inclusion ofstr(e)in returned data, and to avoid echoing any untrusteddetailsto clients.Concretely:
Edit
geointel/geointel.pylines 46–59 to:logger.error(...)calls but adjustreturndicts to:GeoIntelError: nostr(e)or type name in the client-visible dict (or use a non-specific code like"invalid_request").Exception: nostr(e)at all in returned dict.Edit
geointel/web_server.pyaround lines 169–174:'error' in result, construct a new dict with a generic message rather than passing through the entireresult. This also future-proofs against any other sensitive fields that might be added toresultlater.No new utilities or external libraries are required; we only use existing logging and Flask facilities.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.