Skip to content

fix: don't close old findings when reimport auto-creates a new test#14396

Open
valentijnscholten wants to merge 2 commits intoDefectDojo:bugfixfrom
valentijnscholten:fix/reimport-auto-create-close-old-findings
Open

fix: don't close old findings when reimport auto-creates a new test#14396
valentijnscholten wants to merge 2 commits intoDefectDojo:bugfixfrom
valentijnscholten:fix/reimport-auto-create-close-old-findings

Conversation

@valentijnscholten
Copy link
Member

@valentijnscholten valentijnscholten commented Feb 26, 2026

Summary

  • When reimport-scan is called with auto_create_context=True and the test does not yet exist, the endpoint falls back to DefaultImporter to create the test.
  • If close_old_findings=True is set (the reimport default), DefaultImporter.close_old_findings() queries across the engagement/product scope for findings of the same test type that don't match the newly imported hash codes — and closes them. On an empty report this closes all matching findings in other tests.
  • This goes against the docs and intended behaviour of the reimport endpoint.
  • Fixed by passing close_old_findings=False to the importer in this path. A brand-new test has no prior findings to compare against, so closing old findings has no valid semantic here.
  • Alternative fix by creating an empty test first is not immediately feasible as for dynamic parsers we don't know the TestType up front.

Fixes #14363.

When auto_create_context=True and the test doesn't exist yet, the reimport
falls back to DefaultImporter. With close_old_findings=True, this would
incorrectly close findings from other tests in the same engagement/product
scope because the newly created test has no prior findings to compare against.

Suppress close_old_findings for this initial-import path. Fixes DefectDojo#14363.
Add test_reimport_auto_create_does_not_close_findings_in_existing_test to
ImportReimportTestAPI. It calls the reimport endpoint with
auto_create_context=True and close_old_findings=True targeting a non-existing
test title, verifying that the existing test's findings are not closed when
the endpoint auto-creates a new test. This test would fail if the
close_old_findings=False override in the serializer were reverted.
@valentijnscholten valentijnscholten added this to the 2.56.0 milestone Feb 26, 2026
@valentijnscholten valentijnscholten marked this pull request as ready for review February 26, 2026 21:14
Copy link
Contributor

@mtesauro mtesauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

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.

4 participants