Jira webhook: stop mis-mitigating findings on non-"done" issues#14716
Open
paulOsinski wants to merge 1 commit intoDefectDojo:bugfixfrom
Open
Jira webhook: stop mis-mitigating findings on non-"done" issues#14716paulOsinski wants to merge 1 commit intoDefectDojo:bugfixfrom
paulOsinski wants to merge 1 commit intoDefectDojo:bugfixfrom
Conversation
|
This pull request modifies sensitive files (dojo/jira_link/helper.py and dojo/jira_link/views.py), triggering configured-codepaths alerts for edits to protected paths; review and/or update
🔴 Configured Codepaths Edit in
|
| Vulnerability | Configured Codepaths Edit |
|---|---|
| Description | Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml. |
🔴 Configured Codepaths Edit in dojo/jira_link/views.py (drs_87122cb0)
| Vulnerability | Configured Codepaths Edit |
|---|---|
| Description | Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml. |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
users see findings auto-mitigated immediately after reopening via
either the UI or API. Looking at finding pghistory we see the pattern:
12:32:48 active=True is_mitigated=False source=None ← user reopens
12:32:51 active=False is_mitigated=True source=jira_webhook ← ricochet
mitigated_byis always the system "JIRA" user, set only from one place:process_resolution_from_jira's "Mitigated by default" branch.Root cause
Two independent issues compound:
Self-inflicted race in
update_jira_issue. When DefectDojopushes an update to a linked Jira issue, it does
issue.update(...)first (priority, description, labels) and thenpush_status_to_jira(...)(the transition). Each API call fires itsown
jira:issue_updatedwebhook. The first webhook, fired byissue.update, sees the pre-transition state - for a reopen, thatmeans the issue is still resolved from the previous close. Our
webhook handler then mitigates the linked finding. The second
webhook, post-transition, would try to reopen the finding, but for
grouped findings that reopen is (deliberately) gated behind
DD_JIRA_WEBHOOK_ALLOW_FINDING_GROUP_REOPEN=False, so the ricochetis irreversible.
Fragile "resolved" check in the webhook handler. The handler
treated any non-null
resolutionas "the Jira issue is closed",which also mis-fires for Jira configurations that set a default
resolution on open issues ("Unresolved"), or workflows whose Reopen
transition does not clear the resolution field.
Fix
update_jira_issueso the status transition runs beforeother field updates. Webhooks fired during our own sync now see a
consistent post-transition state.
process_resolution_from_jira, require bothresolutionANDstatusCategory.key == "done"before mitigating. Extract thestatusCategory from the webhook payload in
webhook()and pass itthrough.
Tests
Three new tests covering status categories
new,indeterminate, anddone, all with a non-null resolution value - regression-locking theguard against the "open but resolved" state.
Backward compatibility
status_category_keyis a keyword-only optional argument onprocess_resolution_from_jira. When not supplied, behavior isidentical to before the change.