Skip to content

fix: replace bare except with specific exception types - #15430

Merged
Maffooch merged 3 commits into
DefectDojo:devfrom
lxcxjxhx:fix/bare-except-cleanup
Jul 30, 2026
Merged

fix: replace bare except with specific exception types#15430
Maffooch merged 3 commits into
DefectDojo:devfrom
lxcxjxhx:fix/bare-except-cleanup

Conversation

@lxcxjxhx

Copy link
Copy Markdown
Contributor

Summary

Replace bare \except:\ clauses with specific exception types to improve error handling precision.

Changes

  • dojo/api_v2/serializers.py: Replace bare \except:\ with \Development_Environment.DoesNotExist\ in environment lookup
  • dojo/endpoint/models.py: Replace bare \except:\ with (ValueError, ValidationError)\ in URL cleaning and \is_broken\ property
  • dojo/utils.py: Replace bare \except:\ with \Exception\ in \get_period_counts\ query fallbacks

Rationale

Bare \except:\ clauses catch \SystemExit, \KeyboardInterrupt, and \GeneratorExit\ in addition to regular exceptions. This can:

  • Prevent users from interrupting the application with Ctrl+C
  • Hide system-level errors that should propagate
  • Make debugging more difficult by catching unexpected errors silently

Using specific exception types makes the error handling more precise and prevents these issues.

lxcxjxhx added 2 commits July 29, 2026 10:07
When GitHub API calls fail, execution continued with undefined 'issue' variable, causing UnboundLocalError. Also replace bare except with specific Exception type.
@dryrunsecurity

dryrunsecurity Bot commented Jul 30, 2026

Copy link
Copy Markdown

DryRun Security

This pull request contains critical security findings because an unauthorized author modified multiple sensitive codepaths, including dojo/api_v2/serializers.py, dojo/endpoint/models.py, and dojo/utils.py. These changes violate the configured access controls for sensitive files, resulting in a failing risk threshold.

🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/api_v2/serializers.py (drs_169585d6)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/api_v2/serializers.py' matches configured sensitive codepath pattern 'dojo/api_v2/*.py' and was modified by 'lxcxjxhx' (commit d49a6e4) who is not in the allowed authors list.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/endpoint/models.py (drs_1d3408a1)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/endpoint/models.py' matches configured sensitive codepath pattern 'dojo/endpoint/*.py' and was modified by 'lxcxjxhx' (commit d49a6e4) who is not in the allowed authors list.
🔴 Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/utils.py (drs_d7b00d0f)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/utils.py' matches configured sensitive codepath pattern 'dojo/utils.py' and was modified by 'lxcxjxhx' (commit d49a6e4) who is not in the allowed authors list.

We've notified @mtesauro.


Comment to provide feedback on these findings.

Report false positive: @dryrunsecurity fp [FINDING ID] [FEEDBACK]
Report low-impact: @dryrunsecurity nit [FINDING ID] [FEEDBACK]

Example: @dryrunsecurity fp drs_90eda195 This code is not user-facing

All finding details can be found in the DryRun Security Dashboard.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@Maffooch Maffooch added this to the 3.2.0 milestone Jul 30, 2026
@Maffooch
Maffooch merged commit 3416ad8 into DefectDojo:dev Jul 30, 2026
276 of 277 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants