Skip to content

fix(risk-acceptance): keep an unaccepted duplicate inactive when it leaves or expires - #16982

Merged
blakeaowens merged 4 commits into
devfrom
fix/risk-acceptance-release-keeps-unaccepted-duplicate
Nov 18, 2026
Merged

blakeaowens merged 4 commits into
devfrom
fix/risk-acceptance-release-keeps-unaccepted-duplicate

Conversation

@blakeaowens

@blakeaowens blakeaowens commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

A Full Risk Acceptance can hold a member it never accepted: add_findings_to_risk_acceptance leaves a duplicate that is not risk accepted as it is (duplicate=True, risk_accepted=False, inactive), while the form or the serializer has already written it into accepted_findings. Three writers still reopened that duplicate, leaving active=True, duplicate=True, an active duplicate the acceptance never suppressed:

  • release_finding, behind remove_finding_from_risk_acceptance (the Remove button on the Risk Acceptance page, the API removal) and helper.delete (deleting the acceptance), set every member active unless it was closed for another reason.
  • _expire_now, with Reactivate Findings on Expiration on (the expire action and the scheduled expiry), set every inactive member active.

release_finding now reads not_held() (closed for another reason, or a duplicate never accepted) before it clears the risk accepted flag. Such a member keeps its active value, and its endpoint statuses lose only their risk_accepted flag, as a member closed for another reason already did. _expire_now leaves a duplicate that is not risk accepted as it is: it is not saved and is not in the reactivated list. A duplicate the acceptance did accept (risk accepted before it was marked a duplicate) is held, and still comes back. The expiry change is deliberately limited to that duplicate rule.

Test results

New cases in unittests/test_risk_acceptance.py (RiskAcceptanceTestUI) build an acceptance holding two findings plus an unaccepted duplicate with a mitigated endpoint status:

  • test_remove_keeps_an_unaccepted_duplicate_inactive, test_delete_keeps_an_unaccepted_duplicate_inactive, test_expire_keeps_an_unaccepted_duplicate_inactive: the duplicate stays inactive and not risk accepted, its endpoint status stays mitigated; the held findings come back, and expiry's notification lists only them;
  • test_remove_reopens_a_duplicate_the_acceptance_accepted: the control, an accepted finding marked a duplicate afterwards still comes back.

On dev the first three fail (the unaccepted duplicate was reactivated, active=True), and the control passes; with this change all four pass.

The shared setup test_add_risk_acceptance_multiple_findings_accepted accepted findings 2 and 3, and finding 3 in dojo_testdata.json is a duplicate that is not risk accepted, so the acceptance never held it. Eight expire and reinstate tests built on it (test_expire_risk_acceptance_sla_reset, test_expire_risk_acceptance_restores_verified_when_enabled, the six test_reinstate_* that close a member and expire again) passed only because an expiry reopened finding 3, the behavior this PR removes. The setup now accepts findings 2 and 7, the engagement's two findings that are not duplicates, so every member is one the acceptance holds. With the old setup and this fix those eight fail exactly as the first CI run on this PR did; with the new setup the whole RiskAcceptanceTestUI class passes (51 tests). ruff check (0.16.10) passes on the changed files.

Performance, an acceptance holding 25 findings plus 25 unaccepted duplicates (each with one endpoint status), median of 7 interleaved runs:

dev this change
remove the 25 duplicates 1200 queries, 4469 ms 1175 queries, 4394 ms
delete the acceptance 1282 queries, 6446 ms 982 queries, 3388 ms
expire it (reactivating) 1317 queries, 6633 ms 667 queries, 3431 ms

The duplicates left active go from 25 to 0 in each case; the savings are the writes that reopened them.

Documentation

OS__risk_acceptance.md and PRO__risk_acceptance.md (expiry and delete or removal) and PRO__bulk_edit_findings.md (moving a Finding to another Engagement) now say that a duplicate the Risk Acceptance never accepted stays inactive.

🤖 Generated with Claude Code

https://claude.ai/code/session_0143hYTFvxQiwycLMvhG5mDm

blakeaowens and others added 2 commits November 17, 2026 21:12
…eaves or expires

A duplicate that a risk acceptance never accepted (duplicate, not risk accepted) can be a member:
add_findings_to_risk_acceptance leaves it as it is. Removing it from the acceptance, deleting the
acceptance, or expiring an acceptance that reactivates its findings still set it active, leaving an
active duplicate the acceptance never suppressed.

release_finding now keeps such a member's active value (helper.not_held: closed for another reason,
or a duplicate never accepted) and clears only the risk accepted flags, as it already did for a
member closed for another reason. _expire_now leaves it as it is. A duplicate the acceptance did
accept still comes back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0143hYTFvxQiwycLMvhG5mDm
…n it leaves or expires

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0143hYTFvxQiwycLMvhG5mDm
blakeaowens and others added 2 commits November 17, 2026 22:05
…e shared setup

test_add_risk_acceptance_multiple_findings_accepted accepted findings 2 and 3, and finding 3 is a
duplicate that is not risk accepted: add_findings_to_risk_acceptance leaves it as it is. The expire
and reinstate tests built on that setup only passed because an expiry reopened finding 3, which is
the behavior the previous commit removes. Accept 2 and 7 (the engagement's other finding that is not a
duplicate), so every member is one the acceptance holds; the unaccepted duplicate keeps its own tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0143hYTFvxQiwycLMvhG5mDm
…ccepted

With the expiry no longer reopening a duplicate the acceptance never accepted, a later reinstate
of a reactivating acceptance leaves it out through findings_closed_since_expiry, as it leaves out a
member closed since the expiry. Pin that with a test (expire, reinstate: the duplicate is no longer
a member and keeps its status, the held members are accepted again), and say so in the docstring,
the reinstate log line and the reinstate docs.

The bulk edit docs named a per-Asset deduplication setting that does not exist: the switch is per
Engagement (Deduplication within this engagement only).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0143hYTFvxQiwycLMvhG5mDm
@blakeaowens
blakeaowens added this pull request to the merge queue Nov 18, 2026
Merged via the queue into dev with commit e12fd1f Nov 18, 2026
50 checks passed
@blakeaowens
blakeaowens deleted the fix/risk-acceptance-release-keeps-unaccepted-duplicate branch November 18, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants