Commit bc4e7be
authored
Fix DO04 dead rule by dropping handlesResources from its condition (#335)
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.
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>1 parent 9412ef4 commit bc4e7be
2 files changed
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
752 | 752 | | |
753 | 753 | | |
754 | 754 | | |
755 | | - | |
| 755 | + | |
756 | 756 | | |
757 | 757 | | |
758 | 758 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1120 | 1120 | | |
1121 | 1121 | | |
1122 | 1122 | | |
1123 | | - | |
1124 | 1123 | | |
1125 | 1124 | | |
1126 | 1125 | | |
| |||
0 commit comments