Skip to content

bugfix: reimport: close_old_findings must respect service field#12782

Merged
valentijnscholten merged 6 commits into
DefectDojo:bugfixfrom
valentijnscholten:reimport-service-fix
Jul 17, 2025
Merged

bugfix: reimport: close_old_findings must respect service field#12782
valentijnscholten merged 6 commits into
DefectDojo:bugfixfrom
valentijnscholten:reimport-service-fix

Conversation

@valentijnscholten

@valentijnscholten valentijnscholten commented Jul 14, 2025

Copy link
Copy Markdown
Member

Fixes #12754

reimport was not respecting the value of the service field when closing old findings.

The problem was proven by a test case and is now fixed by the PR.

For import there already was working code and a test case covering this.

The PR also tweaks the docs and help texts for the close_old_findings related flags.

The new testcase also asserts that the "reopen" functionality of reimport respects the service field.

@valentijnscholten valentijnscholten marked this pull request as ready for review July 15, 2025 15:29
@dryrunsecurity

dryrunsecurity Bot commented Jul 15, 2025

Copy link
Copy Markdown

DryRun Security

This pull request contains two findings: an insecure default setting that could automatically close old security findings without proper review, and debug logging statements that might expose sensitive database query details if logs are inadvertently made public.

Insecure Default Finding Closure in dojo/forms.py
Vulnerability Insecure Default Finding Closure
Description The close_old_findings form field is set with initial=True, which means by default, old findings will be automatically closed when re-importing a scan. This creates a potential security risk where legitimate findings might be inadvertently marked as mitigated without proper review. The default 'true' setting could lead to unintentional hiding of security issues, especially if users are not carefully reviewing the import process.

label="Choose report file",
allow_empty_file=True,
required=False)
close_old_findings = forms.BooleanField(help_text="Select if old findings in the same test that are no longer present in the report get closed as mitigated when importing.",
required=False, initial=True)
version = forms.CharField(max_length=100, required=False, help_text="Version that will be set on existing Test object. Leave empty to leave existing value in place.")
branch_tag = forms.CharField(max_length=100, required=False, help_text="Branch or Tag that was scanned.")

Sensitive Information Logging in dojo/importers/default_reimporter.py
Vulnerability Sensitive Information Logging
Description Debug logging statements expose sensitive internal details about database queries and finding identifiers. The logs reveal database query structures and finding IDs/hash codes, which could provide reconnaissance information to potential attackers if debug logs are accidentally exposed or left enabled in production environments.

at import time
"""
self.deduplication_algorithm = self.determine_deduplication_algorithm()
# Only process findings with the same service value (or None)
# Even though the service values is used in the hash_code calculation,
# we need to make sure there are no side effects such as closing findings
# for findings with a different service value
# https://github.com/DefectDojo/django-DefectDojo/issues/12754
original_findings = self.test.finding_set.all().filter(service=self.service)
logger.debug(f"original_findings_qyer: {original_findings.query}")
self.original_items = list(original_findings)
logger.debug(f"original_items: {[(item.id, item.hash_code) for item in self.original_items]}")
self.new_items = []
self.reactivated_items = []
self.unchanged_items = []


All finding details can be found in the DryRun Security Dashboard.

@valentijnscholten valentijnscholten changed the title reimport: close_old_findings must respect service field bugfix: reimport: close_old_findings must respect service field Jul 15, 2025
@Maffooch Maffooch requested review from blakeaowens and dogboat July 16, 2025 16:42

@mtesauro mtesauro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved

@valentijnscholten valentijnscholten merged commit b54652e into DefectDojo:bugfix Jul 17, 2025
162 of 164 checks passed
Maffooch added a commit that referenced this pull request Jul 22, 2025
As part of #12782 the default value for `close_old_findings` was swapped from `True` to `False`. This PR restores that functionality
Maffooch added a commit that referenced this pull request Jul 22, 2025
As part of #12782 the default value for `close_old_findings` was swapped from `True` to `False`. This PR restores that functionality
Maffooch added a commit that referenced this pull request Jul 22, 2025
* Update versions in application files

* Reimport: Restore default for `close_old_findings` to `True` (#12837)

As part of #12782 the default value for `close_old_findings` was swapped from `True` to `False`. This PR restores that functionality

* Update versions in application files

---------

Co-authored-by: DefectDojo release bot <dojo-release-bot@users.noreply.github.com>
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>
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.

5 participants