Skip to content

Conversation

Lexorn-ADT
Copy link

Tags were not being applied to endpoints when importing in "add_endpoints_to_unsaved_finding" (endpoint_manager.py) due to missing code.

- Added check for unsaved_tags attribute and applied tags to endpoint
- Includes debug logging for applied tags
- Resolves issue where tags were missing from imported endpoints
- Added check for unsaved_tags attribute and applied tags to endpoint
- Includes debug logging for applied tags
- Resolves issue where tags were missing from imported endpoints
Copy link

DryRun Security

🔴 Risk threshold exceeded.

This pull request modifies a sensitive file (dojo/importers/endpoint_manager.py) and the scanner flagged edits to that path as sensitive; review is recommended and allowed authors/paths can be configured in .dryrunsecurity.yaml.

🔴 Configured Codepaths Edit in dojo/importers/endpoint_manager.py
Vulnerability Configured Codepaths Edit
Description Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.
🔴 Configured Codepaths Edit in dojo/importers/endpoint_manager.py
Vulnerability Configured Codepaths Edit
Description Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.

We've notified @mtesauro.


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

Copy link
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.

I had never considered this use case before. Are there parsers today the attempt to implement this behavior? If not, do you have a good example of where endpoint tags can be ingested at import/reimport time?

@Lexorn-ADT
Copy link
Author

Hi! This feature seems very similar to the "unsaved tags" functionality for findings, which works as expected. However, my use case might be niche? Let me explain below.
I developed a custom parser that processes vulnerabilities as findings, with devices represented as endpoints. The parser handles .json files where each object represents a vulnerability. I extract specific keys as tags and add them to unsaved_tags. Each object also includes an array of active endpoints, each with its own list of tags. The issue is that while unsaved_tags are supported for both findings and endpoints, they only function correctly for findings during an API import. The UI import works fine for both.
As a workaround, I considered using hostname or userinfo, but since IP addresses can be dynamic, this approach creates new endpoints instead of updating existing ones during re-imports. After examining the code, I discovered that while unsaved_tags for endpoints are stored during API imports, they aren't processed further. By adding two lines of code, I enabled endpoint tag support, and now it works as intended.
Regarding the provided parsers, I haven't found any that utilize endpoint tags (though I haven't reviewed all of them). Could this bug explain their absence? Some parsers do use tags but only for findings.

Code examples:
works in git version:

if unsaved_tags:
    finding.unsaved_tags = unsaved_tags

Doesn't work in git version:

if isinstance(endpoint_tags, list):
    endpoint.unsaved_tags = [t.strip() for t in endpoint_tags if t.strip()]

@Lexorn-ADT Lexorn-ADT requested a review from Maffooch October 1, 2025 10:34
@Maffooch
Copy link
Contributor

Maffooch commented Oct 1, 2025

I took a look around the repo, and the use of unsaved_tags on the Endpoint model is not used by anything else in DefectDojo. It looks like the unsaved_tags attribute is initialized on the finding before anything happens, so the same may need to be done on the Endpoint model:

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.unsaved_endpoints = []
self.unsaved_request = None
self.unsaved_response = None
self.unsaved_tags = None
self.unsaved_files = None
self.unsaved_vulnerability_ids = None

In order to accept this PR, unit tests that exercise this code, and check that tags are being created as expected would be required

@valentijnscholten
Copy link
Member

I think it's a nice plan to support the unsaved_tags on endpoints. Please note the tags need to be cleaned before being added, similar to:

finding.tags = clean_tags(finding.unsaved_tags)

@valentijnscholten valentijnscholten added this to the 2.51.1 milestone Oct 2, 2025
@github-actions github-actions bot added the helm label Oct 2, 2025
@github-actions github-actions bot removed the helm label Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants