Skip to content

Fix DO04 dead rule by dropping handlesResources from its condition#335

Open
arpitjain099 wants to merge 1 commit into
OWASP:masterfrom
arpitjain099:chore/fix-do04-dead-rule
Open

Fix DO04 dead rule by dropping handlesResources from its condition#335
arpitjain099 wants to merge 1 commit into
OWASP:masterfrom
arpitjain099:chore/fix-do04-dead-rule

Conversation

@arpitjain099

@arpitjain099 arpitjain099 commented Jun 27, 2026

Copy link
Copy Markdown

Fixes #272.

DO04 ("XML Entity Expansion") targets Dataflow, but its condition also reads target.handlesResources, which only exists on Asset subclasses, not on a plain Dataflow. So for any XML dataflow the lookup raises AttributeError, and the broad except Exception: return False in Threat.apply swallows it into a False. The rule has been silently dead, never firing on the flows it's meant to flag.

Per @raphaelahrens' suggestion in the issue, I dropped the and target.handlesResources is False clause so the condition is just any(d.format == 'XML' for d in target.data), which matches the threat's description. I also removed the handlesResources = False line in test_DO04, since that assignment was injecting the missing attribute and masking the bug.

Tested on Python 3.13: the issue repro now flags DO04, pytest -k DO04 passes, and the full suite (243 tests) is green.

Heads-up: #328 reworks the threat library into Python classes, so if it lands first this'll need a small rebase. Happy to redo it whichever way is easier. Thanks for taking a look.

…ondition

DO04 (XML Entity Expansion) targets Dataflow, but its condition also read
target.handlesResources, an attribute that only exists on Asset subclasses.
For any XML Dataflow the lookup raised AttributeError, which the broad
except Exception in Threat.apply swallowed and turned into False, so DO04
never fired on the very flows it is meant to flag.

Drop the handlesResources clause, leaving the format check that matches
the threat description. Also remove the test line that injected
handlesResources onto a Dataflow, which had been masking the bug.

Fixes OWASP#272

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
@arpitjain099 arpitjain099 requested a review from izar as a code owner June 27, 2026 01:12
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.

Threat "DO04" in threats.json raises AttributeError when applied to Dataflow with XML data

1 participant