Handle XML ParseError in scan import API (fixes #14752)#14794
Open
davidwebdeveloper wants to merge 2 commits intoDefectDojo:devfrom
Open
Handle XML ParseError in scan import API (fixes #14752)#14794davidwebdeveloper wants to merge 2 commits intoDefectDojo:devfrom
davidwebdeveloper wants to merge 2 commits intoDefectDojo:devfrom
Conversation
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.
|
This pull request includes sensitive edits detected in
🔴 Configured Codepaths Edit in
|
| 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.
Member
|
Thanks. Why did you opt for catching it the API level and not at the parser/importer level? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.