Skip to content

Commit 7ecf292

Browse files
authored
render: don't assume prior matches exist within thread (#2612)
* render: don't assume prior matches exist within thread * update CHANGELOG * update comments
1 parent 45ea683 commit 7ecf292

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- only parse CAPE fields required for analysis @mike-hunhoff #2607
1818
- main: render result document without needing associated rules @williballenthin #2610
1919
- vmray: only verify process OS and monitor IDs match @mike-hunhoff #2613
20+
- render: don't assume prior matches exist within a thread @mike-hunhoff #2612
2021

2122
### capa Explorer Web
2223

capa/render/result_document.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,9 @@ def from_capa(
418418
and a.id <= location.id
419419
]
420420
)
421-
_, most_recent_match = matches_in_thread[-1]
422-
children.append(Match.from_capa(rules, capabilities, most_recent_match))
421+
if matches_in_thread:
422+
_, most_recent_match = matches_in_thread[-1]
423+
children.append(Match.from_capa(rules, capabilities, most_recent_match))
423424

424425
else:
425426
children.append(Match.from_capa(rules, capabilities, rule_matches[location]))
@@ -478,8 +479,11 @@ def from_capa(
478479
and a.id <= location.id
479480
]
480481
)
481-
_, most_recent_match = matches_in_thread[-1]
482-
children.append(Match.from_capa(rules, capabilities, most_recent_match))
482+
# namespace matches may not occur within the same thread as the result, so only
483+
# proceed if a match within the same thread is found
484+
if matches_in_thread:
485+
_, most_recent_match = matches_in_thread[-1]
486+
children.append(Match.from_capa(rules, capabilities, most_recent_match))
483487
else:
484488
if location in rule_matches:
485489
children.append(Match.from_capa(rules, capabilities, rule_matches[location]))

0 commit comments

Comments
 (0)