Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes reimporter to ensure that risk accepted findings do not get mitigated #9050

Merged
merged 2 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dojo/importers/default_reimporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,13 @@ def process_matched_special_status_finding(
):
self.unchanged_items.append(existing_finding)
return existing_finding, True
# If the finding is risk accepted and inactive in Defectdojo we do not sync the status from the scanner
# We also need to add the finding to 'unchanged_items' as otherwise it will get mitigated by the reimporter
# (Risk accepted findings are not set to mitigated by Defectdojo)
# We however do not exit the loop as we do want to update the endpoints (in case some endpoints were fixed)
elif existing_finding.risk_accepted and not existing_finding.active:
self.unchanged_items.append(existing_finding)
return existing_finding, False
# The finding was not an exact match, so we need to add more details about from the
# new finding to the existing. Return False here to make process further
return existing_finding, False
Expand Down
2 changes: 1 addition & 1 deletion unittests/test_import_reimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ def test_import_reimport_keep_false_positive_and_out_of_scope(self):
active_findings_before = self.get_test_findings_api(test_id, active=True)
self.assert_finding_count_json(0, active_findings_before)

with assertTestImportModelsCreated(self, reimports=1, affected_findings=1, created=1):
with assertTestImportModelsCreated(self, reimports=1, affected_findings=1, created=1, untouched=1):
reimport0 = self.reimport_scan_with_params(test_id, self.zap_sample0_filename)

self.assertEqual(reimport0["test"], test_id)
Expand Down
Loading