Skip to content

Commit d6106ea

Browse files
sequence: add test showing multiple sequences overlapping a single event
1 parent e29a370 commit d6106ea

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/test_dynamic_sequence_scope.py

+42
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,45 @@ def test_dynamic_sequence_example():
212212
matches, features = capa.capabilities.dynamic.find_dynamic_capabilities(ruleset, extractor, disable_progress=True)
213213
assert r.name in matches
214214
assert 14 in get_call_ids(matches[r.name])
215+
216+
217+
# show how sequences that overlap a single event are handled.
218+
# TODO(williballenthin): but I think we really just want one match for this, not copies of the same thing.
219+
#
220+
# proc: 0000A65749F5902C4D82.exe (ppid=2456, pid=3052)
221+
# thread: 3064
222+
# ...
223+
# call 10: ...
224+
# call 11: LdrGetProcedureAddress(2010595649, 0, AddVectoredExceptionHandler, 1974337536, kernel32.dll)
225+
# call 12: ...
226+
# call 13: ...
227+
# call 14: ...
228+
# call 15: ...
229+
# ...
230+
def test_dynamic_sequence_multiple_matches_in_one_sequence():
231+
extractor = get_0000a657_thread3064()
232+
233+
rule = textwrap.dedent(
234+
"""
235+
rule:
236+
meta:
237+
name: test rule
238+
scopes:
239+
static: unsupported
240+
dynamic: sequence
241+
features:
242+
- and:
243+
- call:
244+
- and:
245+
- api: LdrGetProcedureAddress
246+
- string: "AddVectoredExceptionHandler"
247+
"""
248+
)
249+
250+
r = capa.rules.Rule.from_yaml(rule)
251+
ruleset = capa.rules.RuleSet([r])
252+
253+
matches, features = capa.capabilities.dynamic.find_dynamic_capabilities(ruleset, extractor, disable_progress=True)
254+
assert r.name in matches
255+
assert [11, 12, 13, 14, 15] == list(get_call_ids(matches[r.name]))
256+

0 commit comments

Comments
 (0)