Skip to content

Fix Qualys parser collapsing findings with same QID but different por…#14528

Open
tejas0077 wants to merge 4 commits into
DefectDojo:bugfixfrom
tejas0077:fix/qualys-port-deduplication
Open

Fix Qualys parser collapsing findings with same QID but different por…#14528
tejas0077 wants to merge 4 commits into
DefectDojo:bugfixfrom
tejas0077:fix/qualys-port-deduplication

Conversation

@tejas0077
Copy link
Copy Markdown
Contributor

@tejas0077 tejas0077 commented Mar 15, 2026

Description
When importing Qualys scan reports, findings with the same QID but
different ports were being collapsed into a single finding, causing
inaccurate vulnerability counts and loss of port-level granularity.
Root cause: the finding title only used QID and vulnerability name,
so findings with the same QID on different ports (e.g. 80, 5985, 9999)
got deduplicated into one finding.
Fix: port is now added directly to the Endpoint (and LocationData for V3) when present. Each QID+port combination gets its own endpoint on the finding. Finding titles and deduplication are completely unchanged.
Fixes #13682
Test results
Manually traced the parser logic. Port is already extracted from the
XML as temp["port_status"] and is now passed to the Endpoint object when present.
Documentation
No documentation changes needed.
Checklist

Bugfix submitted against the bugfix branch.
Meaningful PR name given.
Proper label added.

@valentijnscholten
Copy link
Copy Markdown
Member

This will need some consideration/assurance as this will completely break deduplication with existing findings. Posted a comment on #13682

@tejas0077
Copy link
Copy Markdown
Contributor Author

Hi @valentijnscholten, thank you for the feedback!

You raise a valid point. Changing the title format will break
deduplication with existing findings since the hash code is
calculated from the title.

A safer approach would be to keep the title unchanged but instead
use the port in the hash code calculation for Qualys specifically,
by adding port to the HASHCODE_FIELDS_PER_SCANNER setting:

"Qualys Scan": ["title", "severity", "vulnerability_ids", "cwe", "port"]

This way:

  • Existing finding titles remain unchanged
  • Deduplication correctly separates findings by port
  • No breaking change to existing data

Would you prefer this approach instead? I can update the PR accordingly.

Copy link
Copy Markdown
Contributor

@Maffooch Maffooch left a comment

Choose a reason for hiding this comment

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

Qualys is a super popular parser, and breaking deduplication would have far reaching impacts. Port is not a field that could be used for deduplication since port is on the endpoint model rather than the finding model.

Something that could be more palatable is to add the port to the endpoint, and then add multiple endpoints to the finding

@tejas0077
Copy link
Copy Markdown
Contributor Author

Thanks @Maffooch, that makes sense! I'll rework the fix to keep a single finding per QID but attach multiple endpoints with the respective ports. That way port-level granularity is preserved without touching titles or breaking deduplication. Will update the PR shortly.

@tejas0077
Copy link
Copy Markdown
Contributor Author

Hi @Maffooch, I've reworked the fix as suggested. Instead of modifying the title, the port is now added directly to the Endpoint (and LocationData for V3) when present. This way each QID+port combination gets its own endpoint on the finding, port-level granularity is preserved, and existing titles/deduplication are completely unchanged. Please take a look!

@valentijnscholten
Copy link
Copy Markdown
Member

The title is still being modified, I believe this has to be removed.

@tejas0077
Copy link
Copy Markdown
Contributor Author

Hi @valentijnscholten, thanks for catching that! I've removed the port from the finding title. The title is now back to the original format QID-XXXX | Vulnerability Name and the port is only added to the Endpoint. Please take a look!

@Maffooch
Copy link
Copy Markdown
Contributor

Please add some unit tests for this to prevent regressions, add some updates to the release notes, and then I think this should be good!

@Maffooch Maffooch added this to the 2.57.0 milestone Mar 20, 2026
@tejas0077 tejas0077 force-pushed the fix/qualys-port-deduplication branch from 1671d06 to a4e5698 Compare March 20, 2026 17:38
tejas0077 pushed a commit to tejas0077/django-DefectDojo that referenced this pull request Mar 20, 2026
…n fix

- Add test XML with same QID on ports 80, 443, 8080
- Add test verifying each port gets its own endpoint
- Add 2.57.x release notes mentioning the fix

Addresses review feedback from @Maffooch on PR DefectDojo#14528
@github-actions github-actions Bot added docker settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR apiv2 docs unittests ui helm labels Mar 20, 2026
@tejas0077
Copy link
Copy Markdown
Contributor Author

Hi @Maffooch, I have addressed both your review requests:

Added unit tests -created a test XML file with the same QID (12345) on three different ports (80, 443, 8080) and added a test that verifies each port gets its own separate endpoint, the finding title remains unchanged as QID-12345 | Test Vulnerability, and all 3 ports are correctly captured.
Added release notes -created docs/content/releases/os_upgrading/2.57.md with a note about the Qualys parser fix referencing issue #13682.

Please take a look!

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@valentijnscholten
Copy link
Copy Markdown
Member

@tejas0077 Can you rebase to get rid of the conflicts?

@tejas0077 tejas0077 force-pushed the fix/qualys-port-deduplication branch from a4e5698 to a998e63 Compare March 30, 2026 18:42
tejas0077 pushed a commit to tejas0077/django-DefectDojo that referenced this pull request Mar 30, 2026
…n fix

- Add test XML with same QID on ports 80, 443, 8080
- Add test verifying each port gets its own endpoint
- Add 2.57.x release notes mentioning the fix

Addresses review feedback from @Maffooch on PR DefectDojo#14528
@github-actions
Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@tejas0077
Copy link
Copy Markdown
Contributor Author

Hi @valentijnscholten, I've rebased the branch onto the latest bugfix branch. Conflicts are resolved. Please take a look!

@Maffooch Maffooch modified the milestones: 2.57.0, 2.58.0 Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 6, 2026

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@valentijnscholten valentijnscholten marked this pull request as draft April 11, 2026 13:55
@Maffooch Maffooch modified the milestones: 2.58.0, 2.59.0 May 1, 2026
Tejas Saubhage added 4 commits May 20, 2026 09:02
…n fix

- Add test XML with same QID on ports 80, 443, 8080
- Add test verifying each port gets its own endpoint
- Add 2.57.x release notes mentioning the fix

Addresses review feedback from @Maffooch on PR DefectDojo#14528
test(qualys): add unit test for same QID different ports deduplication fix

- Add test XML with same QID on ports 80, 443, 8080
- Add test verifying each port gets its own endpoint
- Add 2.59.x release notes mentioning the fix

Addresses review feedback from @Maffooch on PR DefectDojo#14528
@tejas0077 tejas0077 force-pushed the fix/qualys-port-deduplication branch from a998e63 to 8104595 Compare May 20, 2026 13:23
@tejas0077 tejas0077 marked this pull request as ready for review May 20, 2026 13:24
@github-actions github-actions Bot removed docker settings_changes Needs changes to settings.py based on changes in settings.dist.py included in this PR apiv2 ui helm conflicts-detected labels May 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

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