Skip to content

fix(import): resolve the import target the same way in the permission check and the import - #16873

Merged
Maffooch merged 2 commits into
DefectDojo:devfrom
svader0:harden-import-target-resolution
Nov 13, 2026
Merged

Maffooch merged 2 commits into
DefectDojo:devfrom
svader0:harden-import-target-resolution

Conversation

@svader0

@svader0 svader0 commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Scan imports check permissions on the raw request, before validation, and then run on the serializer's validated data. This change makes both steps read the target names and the engagement the same way, so the permission check looks at the same product and engagement the import uses. Names with leading or trailing spaces now resolve in the check the same way they do in the import. Adds tests. No functional change for correctly permissioned users.

… check and the import

The scan import permission checks read the raw request, while the import
itself runs on the serializer's validated data. Two differences let them
pick different targets: the serializer trims whitespace from the name
fields and the raw read did not, and the import permission check read a
response-only engagement field that the serializer drops. Trim the names
when reading the raw request, and ignore that field in the check, so the
check authorizes the same product and engagement the import writes to.
@dryrunsecurity

dryrunsecurity Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

DryRun Security

This pull request modifies two sensitive codepaths in the dojo/importers and dojo/authorization directories by an author not on the allowed list. These changes are flagged as low severity and are non-blocking.

Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/importers/auto_create_context.py (drs_09abd77f)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/importers/auto_create_context.py' matches configured sensitive codepath pattern 'dojo/importers/*.py' and was modified by 'svader0' (commit f35c2d7) who is not in the allowed authors list.
Configured Sensitive Codepath Modified by Non-Allowed Author in dojo/authorization/api_permissions.py (drs_66017f84)
Vulnerability Configured Sensitive Codepath Modified by Non-Allowed Author
Description File 'dojo/authorization/api_permissions.py' matches configured sensitive codepath pattern 'dojo/authorization/*.py' and was modified by 'svader0' (commit f35c2d7) who is not in the allowed authors list.

Comment to provide feedback on these findings.

Report false positive: @dryrunsecurity fp [FINDING ID] [FEEDBACK]
Report low-impact: @dryrunsecurity nit [FINDING ID] [FEEDBACK]

Example: @dryrunsecurity fp drs_90eda195 This code is not user-facing

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

Comment thread dojo/importers/auto_create_context.py Resolved
@svader0

svader0 commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

Review summary: the check and the import now resolve the same target in the cases I tried. API v3 does not call the changed helper, so the change does not affect it.

Follow-ups I am adding to this PR:

  • a reimport test (see the inline comment)
  • the same cleanup in the reimport and endpoint meta import checks, so all three checks resolve their target the same way as the serializer

… checks

ReImportScanSerializer drops test_id and EndpointMetaImporterSerializer
drops product_id, because both are response-only fields. The permission
checks still read them from the raw request. Ignore them in the checks
too, so each check resolves its target the same way as its serializer.

Adds reimport tests, including one for a name with surrounding spaces,
and a meta import test.
@svader0 svader0 added this to the 3.5.200 milestone Nov 13, 2026
@Maffooch
Maffooch enabled auto-merge November 13, 2026 20:45
@Maffooch
Maffooch disabled auto-merge November 13, 2026 20:49
@Maffooch
Maffooch enabled auto-merge November 13, 2026 20:49
@Maffooch
Maffooch added this pull request to the merge queue Nov 13, 2026
Merged via the queue into DefectDojo:dev with commit 4844a0b Nov 13, 2026
48 checks passed
@defectdojo-release-tracker defectdojo-release-tracker Bot modified the milestones: 3.5.200, 3.5.103 Nov 13, 2026
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