Skip to content

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

Merged
tonytech83 merged 1 commit into
mainfrom
alert-autofix-1
Aug 28, 2026
Merged

Potential fix for code scanning alert no. 1: Information exposure through an exception#9
tonytech83 merged 1 commit into
mainfrom
alert-autofix-1

Conversation

@tonytech83

Copy link
Copy Markdown
Owner

Potential fix for https://github.com/tonytech83/Inventory/security/code-scanning/1

To fix this safely, keep the bulk-import behavior and per-row success/failure reporting, but stop returning raw exception details to the client.

Best approach (without changing functional behavior):

  1. In inventory/devices/utils.py, add server-side logging.
  2. In the except Exception as e: block, log the exception with context (e.g., device name/row info) using logger.exception(...).
  3. Replace "error": str(e) in results with a generic message like "Device could not be imported due to invalid data.".

This preserves:

  • Row-level error reporting for clients (status: Error still present),
  • Operational debugging for developers (full traceback in server logs),
  • Existing API shape (results still includes an error field).

Files/regions to change:

  • inventory/devices/utils.py: import logging, define module logger, and update exception handling block in create_devices_form_upload.

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

…ough an exception

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@tonytech83 tonytech83 self-assigned this Aug 28, 2026
@tonytech83 tonytech83 added the enhancement New feature or request label Aug 28, 2026
@tonytech83
tonytech83 marked this pull request as ready for review August 28, 2026 18:04
@tonytech83
tonytech83 merged commit 299937d into main Aug 28, 2026
4 checks passed
@tonytech83
tonytech83 deleted the alert-autofix-1 branch August 28, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant