Commit a00effe
chore: reorganize dedupe code (#14641)
* Add match-only deduplication helpers and close-old queryset extraction.
Expose match_batch_* and match_batch_of_findings for read-only matching. Support unsaved findings in location/endpoint comparison and _is_candidate_older. Refactor default_importer close_old_findings to use get_close_old_findings_queryset. Restore batch deduplication debug logging.
* Batch-refresh close_old_findings status fields to avoid N refresh_from_db queries.
Replace per-finding refresh_from_db(false_p, risk_accepted, out_of_scope) with one
values() query for all PKs and assign onto instances, falling back to refresh_from_db
when a row is missing.
* docs: cite #12291 for close_old_findings status refresh origin
* perf: chunk close_old_findings status sync queries (1000 PKs per SELECT)
* fix(parsers): use unsaved_tags instead of tags= in Finding constructor for performance
Passing tags= directly to the Finding() constructor triggers expensive
tagulous processing for every finding. Using finding.unsaved_tags instead
bypasses this overhead and lets the import pipeline handle tags efficiently.
Affected parsers: jfrog_xray_unified, dependency_check, cargo_audit,
anchore_grype, threat_composer.
Benchmark on 14,219 findings: 99s -> 7.97s (12x faster).
* fix: resolve ruff D203 and COM812 lint errors from formatter conflict
* fix: update tests to check unsaved_tags instead of tags
* fix: correct unsaved_tags assertions to expect lists and fix tag ordering
Update tests for dependency_check and jfrog_xray_unified parsers to match
the actual list format returned by unsaved_tags, and fix the expected order
of tags for the suppressed-without-notes case in dependency_check.
* fix(reimport): do not update finding tags on reimport for matched findings
Tags from the report were being appended to matched findings via tags.add(),
causing tags to accumulate across reimports instead of being left unchanged.
This aligns tag handling with how other finding fields are treated on reimport.
Closes #14606
---------
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>1 parent 0349f01 commit a00effe
7 files changed
Lines changed: 259 additions & 164 deletions
File tree
- dojo
- finding
- importers
- tools
- anchore_grype
- cargo_audit
- dependency_check
- jfrog_xray_unified
- threat_composer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
226 | 229 | | |
227 | | - | |
| 230 | + | |
228 | 231 | | |
229 | 232 | | |
230 | 233 | | |
| |||
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
245 | | - | |
246 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
247 | 251 | | |
248 | 252 | | |
249 | 253 | | |
| |||
266 | 270 | | |
267 | 271 | | |
268 | 272 | | |
269 | | - | |
270 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
271 | 278 | | |
272 | 279 | | |
273 | 280 | | |
| |||
284 | 291 | | |
285 | 292 | | |
286 | 293 | | |
287 | | - | |
288 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
289 | 299 | | |
290 | 300 | | |
291 | 301 | | |
| |||
535 | 545 | | |
536 | 546 | | |
537 | 547 | | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
538 | 551 | | |
539 | 552 | | |
540 | 553 | | |
| |||
715 | 728 | | |
716 | 729 | | |
717 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
718 | 836 | | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
719 | 841 | | |
720 | 842 | | |
721 | 843 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
| 320 | + | |
325 | 321 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
| 322 | + | |
335 | 323 | | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
| 324 | + | |
| 325 | + | |
349 | 326 | | |
350 | 327 | | |
351 | 328 | | |
| |||
382 | 359 | | |
383 | 360 | | |
384 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
385 | 394 | | |
386 | 395 | | |
387 | 396 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
| 91 | + | |
95 | 92 | | |
96 | 93 | | |
97 | 94 | | |
98 | 95 | | |
99 | 96 | | |
100 | 97 | | |
101 | 98 | | |
102 | | - | |
103 | | - | |
104 | | - | |
| 99 | + | |
105 | 100 | | |
106 | | - | |
107 | | - | |
108 | | - | |
| 101 | + | |
109 | 102 | | |
110 | 103 | | |
111 | 104 | | |
112 | 105 | | |
113 | | - | |
114 | | - | |
115 | | - | |
| 106 | + | |
116 | 107 | | |
117 | 108 | | |
118 | | - | |
119 | | - | |
120 | | - | |
| 109 | + | |
121 | 110 | | |
122 | 111 | | |
123 | 112 | | |
| |||
148 | 137 | | |
149 | 138 | | |
150 | 139 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 140 | + | |
154 | 141 | | |
155 | 142 | | |
156 | 143 | | |
157 | | - | |
158 | | - | |
159 | | - | |
| 144 | + | |
160 | 145 | | |
161 | 146 | | |
162 | 147 | | |
163 | 148 | | |
164 | 149 | | |
165 | 150 | | |
166 | | - | |
167 | | - | |
168 | | - | |
| 151 | + | |
169 | 152 | | |
170 | 153 | | |
171 | 154 | | |
172 | | - | |
173 | | - | |
174 | | - | |
| 155 | + | |
175 | 156 | | |
176 | 157 | | |
177 | 158 | | |
| |||
246 | 227 | | |
247 | 228 | | |
248 | 229 | | |
249 | | - | |
| 230 | + | |
| 231 | + | |
250 | 232 | | |
251 | 233 | | |
252 | 234 | | |
| |||
276 | 258 | | |
277 | 259 | | |
278 | 260 | | |
279 | | - | |
280 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
281 | 266 | | |
282 | 267 | | |
283 | 268 | | |
0 commit comments