Skip to content

Conversation

@mbomb67
Copy link
Member

@mbomb67 mbomb67 commented Jan 29, 2026

Development Prerequisites

Summary of Proposed Changes

  • ...


except Exception as e:
logger.exception("Failed to create CMP group")
return JsonResponse({"error": str(e)}, status=500)

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 2 days ago

In general, to fix this type of issue you should avoid returning raw exception messages or stack traces to the client. Instead, log the full exception details on the server and send a generic, non-sensitive error message in the HTTP response. Optionally, you can include a generic error code or correlation ID if the client needs something to report back to support.

Concretely in this file, only the create_cmp_group view’s except block is problematic. The exception is already logged with logger.exception("Failed to create CMP group"), so developers still have full diagnostic information. We should change the JsonResponse to return a fixed, generic error message rather than str(e). The rest of the functionality (success path, status codes, request method handling) remains unchanged. No new imports or helpers are needed.

Specifically:

  • In ui_extensions/azure_ad_group_import/views.py, around line 116–118, replace:
    • return JsonResponse({"error": str(e)}, status=500)
  • With:
    • a generic message, for example return JsonResponse({"error": "Failed to create CMP group"}, status=500)

This keeps behavior (a 500 with an error field) but removes the exposure of the underlying exception details.

Suggested changeset 1
ui_extensions/azure_ad_group_import/views.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/ui_extensions/azure_ad_group_import/views.py b/ui_extensions/azure_ad_group_import/views.py
--- a/ui_extensions/azure_ad_group_import/views.py
+++ b/ui_extensions/azure_ad_group_import/views.py
@@ -115,6 +115,6 @@
 
         except Exception as e:
             logger.exception("Failed to create CMP group")
-            return JsonResponse({"error": str(e)}, status=500)
+            return JsonResponse({"error": "Failed to create CMP group"}, status=500)
 
     return JsonResponse({"error": "Invalid method"}, status=405)
EOF
@@ -115,6 +115,6 @@

except Exception as e:
logger.exception("Failed to create CMP group")
return JsonResponse({"error": str(e)}, status=500)
return JsonResponse({"error": "Failed to create CMP group"}, status=500)

return JsonResponse({"error": "Invalid method"}, status=405)
Copilot is powered by AI and may make mistakes. Always verify output.
@mbomb67 mbomb67 merged commit c66efe0 into howdoivideos Jan 29, 2026
23 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.

4 participants