Skip to content

Comments

Hotfix - errors added from security tool#112

Merged
millenr merged 1 commit intomainfrom
patch-1
Jan 15, 2026
Merged

Hotfix - errors added from security tool#112
millenr merged 1 commit intomainfrom
patch-1

Conversation

@millenr
Copy link
Contributor

@millenr millenr commented Jan 15, 2026

No description provided.

@millenr millenr requested a review from Jeyaraman January 15, 2026 18:09
return {"error": "Failed to process network."}
return {"error": "Failed to send network to Cytoscape."}
logger.error(f"Error in single network mode: {e}")
return {"error": str(e)}

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix

AI about 1 month ago

In general, to fix information exposure through exceptions, you should avoid sending raw exception messages or stack traces back to clients. Instead, log the detailed error on the server, and return a generic, user-safe message (optionally with a non-sensitive error code) in the API response.

For this specific case in api/server.py around line 870, the best fix is:

  • Keep the existing logging so developers still get details (logger.error(f"Error in single network mode: {e}")).
  • Change the returned payload from {"error": str(e)} to a generic message such as {"error": "Failed to create Cytoscape network"} that does not include the exception text.
  • Optionally include a non-sensitive field like "detail": "Internal error", but do not echo e or its string representation.

No new imports or helpers are needed; the fix is just a small change to the return value in that except block. This preserves behavior semantics (error vs success) while preventing sensitive information from leaking to the client.

Suggested changeset 1
api/server.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/api/server.py b/api/server.py
--- a/api/server.py
+++ b/api/server.py
@@ -869,7 +869,7 @@
             return _send_single_network_to_cytoscape(converted_json, layout_type)
         except Exception as e:
             logger.error(f"Error in single network mode: {e}")
-            return {"error": str(e)}
+            return {"error": "Failed to create Cytoscape network."}
     
     # Multiple routes mode (new default behavior)
     try:
EOF
@@ -869,7 +869,7 @@
return _send_single_network_to_cytoscape(converted_json, layout_type)
except Exception as e:
logger.error(f"Error in single network mode: {e}")
return {"error": str(e)}
return {"error": "Failed to create Cytoscape network."}

# Multiple routes mode (new default behavior)
try:
Copilot is powered by AI and may make mistakes. Always verify output.
@millenr millenr requested a review from walkerbdev January 15, 2026 18:15
@millenr millenr merged commit 0029a48 into main Jan 15, 2026
4 of 7 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.

2 participants