Skip to content

Handle XML ParseError in scan import API (fixes #14752)#14794

Open
davidwebdeveloper wants to merge 2 commits intoDefectDojo:devfrom
davidwebdeveloper:fix-xml-parse-error-14752
Open

Handle XML ParseError in scan import API (fixes #14752)#14794
davidwebdeveloper wants to merge 2 commits intoDefectDojo:devfrom
davidwebdeveloper:fix-xml-parse-error-14752

Conversation

@davidwebdeveloper
Copy link
Copy Markdown

This PR addresses issue #14752 by catching ElementTree ParseError in the scan import serializers and re-raising it as a ValidationError. This ensures that malformed XML uploads result in a 400 Bad Request response rather than crashing the uwsgi worker. Includes a regression test.

DefectDojo#14752)

Translates xml.etree.ElementTree.ParseError into a DRF ValidationError to return a 400 Bad Request instead of a 500 error or worker termination.
@dryrunsecurity
Copy link
Copy Markdown

dryrunsecurity Bot commented May 2, 2026

DryRun Security

This pull request includes sensitive edits detected in dojo/api_v2/serializers.py, which is flagged as a configured codepath and may require review or authorization depending on .dryrunsecurity.yaml.

🔴 Configured Codepaths Edit in dojo/api_v2/serializers.py (drs_7f0ae22a)
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/api_v2/serializers.py (drs_8bfc895a)
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.


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.

…#14752)

Switched to defusedxml for better security alignment and updated the error format to use a field-specific dictionary as recommended in DRF. Also moved the catch block to avoid misleading comment alignment.
@valentijnscholten
Copy link
Copy Markdown
Member

Thanks. Why did you opt for catching it the API level and not at the parser/importer level?

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