Fix risk acceptance API to link to engagement and add validations and permission check #14140
+392
−2
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.
Summary
Fixes #12644
This PR addresses several critical issues with the risk acceptance API:
Risk acceptances created via API now appear in engagement panel
engagement.risk_acceptance.add(instance)in thecreate()methodAdded validation for
enable_full_risk_acceptanceproduct settingvalidate()method to fail early (no need to create then delete)Added protection against engagement switching
self.instance.accepted_findings.all()instead of filtering for better performanceComprehensive API tests
test_risk_acceptance_api.pywith 7 test casesAPI now checks that user has Risk_Acceptance permission and not just Finding.Edit permission
This PR doesn't break Pro and doesn't need any changes in Pro as Pro has its own separate model and relationship to track links between Risk Aceeptance and Engagement.