Commit 29fbdc1
authored
In scope=false assets fix (#312)
Summary:
This PR fixes issue #310, where threat findings from out-of-scope
elements were still rendered in generated reports.
The fix centralizes scope filtering inside ReportUtils and updates all
report templates to use scope-safe helper methods, preventing accidental
leakage of findings.
What was changed
Code:
1)pytm/report_util.py
Added helper methods that return only in-scope findings
Introduced scope-safe accessors for:
>threat ID
>description
>target
>severity
>references
Prevented templates from directly iterating over raw item.findings
Templates:
1)docs/basic_template.md
2)docs/advanced_template.md
3)docs/reveal.md
All templates were updated to:
>Stop accessing item.findings, item.id, item.target, etc. directly
>Use ReportUtils helper methods instead (for example:
getInScopeFindings, getThreatId, etc.)
>This ensures consistent and safe behavior across all report formats.
Why this fixes the bug:
>Previously, report templates accessed findings directly, bypassing
scope checks.
This caused out-of-scope threats to appear in reports, even when
elements were explicitly marked inScope = False.
With this change:
>Scope filtering is enforced in one centralized location
>Templates cannot accidentally leak out-of-scope findings
>All report types behave consistently
How this was verified
Generated reports using:
>docs/basic_template.md
>docs/advanced_template.md
>docs/reveal.md
Verified that:
>No templates reference item.findings, item.id, item.target, or
item.severity
>Out-of-scope elements do not render findings
>In-scope elements render findings correctly
>Existing report structure remains unchanged aside from the bug fix
>Commits included
>Fix threat leakage into out-of-scope elements
>Prevent out-of-scope threats from rendering in reports
(Commits can be squashed if preferred.)
Notes:
>No functional behavior outside report rendering was changed
>No new dependencies were added
>Changes are strictly limited to what is required to fix issue #3101 parent 54affa2 commit 29fbdc1
File tree
4 files changed
+207
-140
lines changed- docs
- pytm
4 files changed
+207
-140
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
38 | 37 | | |
39 | 38 | | |
40 | | - | |
41 | 39 | | |
42 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | | - | |
| 47 | + | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
49 | 50 | | |
50 | | - | |
| 51 | + | |
51 | 52 | | |
52 | | - | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
56 | | - | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
| 71 | + | |
73 | 72 | | |
74 | 73 | | |
75 | | - | |
76 | 74 | | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | | - | |
88 | | - | |
| 87 | + | |
89 | 88 | | |
90 | 89 | | |
91 | | - | |
92 | 90 | | |
93 | 91 | | |
94 | | - | |
| 92 | + | |
| 93 | + | |
95 | 94 | | |
96 | 95 | | |
97 | 96 | | |
| |||
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
104 | | - | |
105 | | - | |
| 103 | + | |
106 | 104 | | |
107 | 105 | | |
108 | | - | |
109 | 106 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
115 | 114 | | |
116 | | - | |
| 115 | + | |
117 | 116 | | |
118 | | - | |
| 117 | + | |
119 | 118 | | |
120 | | - | |
121 | | - | |
| 119 | + | |
122 | 120 | | |
123 | 121 | | |
124 | | - | |
125 | 122 | | |
126 | 123 | | |
127 | | - | |
| 124 | + | |
| 125 | + | |
128 | 126 | | |
129 | 127 | | |
130 | 128 | | |
| |||
136 | 134 | | |
137 | 135 | | |
138 | 136 | | |
139 | | - | |
140 | | - | |
| 137 | + | |
141 | 138 | | |
142 | 139 | | |
143 | | - | |
144 | 140 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
150 | 148 | | |
151 | | - | |
| 149 | + | |
152 | 150 | | |
153 | | - | |
| 151 | + | |
154 | 152 | | |
155 | | - | |
156 | | - | |
| 153 | + | |
157 | 154 | | |
158 | 155 | | |
159 | | - | |
160 | 156 | | |
161 | 157 | | |
| 158 | + | |
162 | 159 | | |
163 | 160 | | |
164 | 161 | | |
165 | 162 | | |
166 | 163 | | |
167 | 164 | | |
168 | | - | |
169 | | - | |
170 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
171 | 173 | | |
172 | | - | |
173 | | - | |
| 174 | + | |
| 175 | + | |
174 | 176 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
| 177 | + | |
| 178 | + | |
180 | 179 | | |
181 | | - | |
| 180 | + | |
182 | 181 | | |
183 | | - | |
| 182 | + | |
184 | 183 | | |
185 | 184 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
59 | 64 | | |
60 | | - | |
| 65 | + | |
| 66 | + | |
61 | 67 | | |
62 | | - | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | | - | |
65 | | - | |
| 71 | + | |
| 72 | + | |
66 | 73 | | |
67 | | - | |
68 | 74 | | |
69 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments