mirror of
https://github.com/mandiant/capa.git
synced 2026-01-03 00:11:26 -08:00
render: capture and display matched regex string
This commit is contained in:
@@ -46,6 +46,8 @@ def convert_statement_to_result_document(statement):
|
||||
return {
|
||||
'type': 'regex',
|
||||
'pattern': statement.pattern,
|
||||
# the string that was matched
|
||||
'match': statement.match,
|
||||
}
|
||||
elif isinstance(statement, capa.engine.Subscope):
|
||||
return {
|
||||
|
||||
@@ -23,7 +23,10 @@ def render_statement(ostream, statement, indent=0):
|
||||
ostream.write(statement['subscope'])
|
||||
ostream.writeln(':')
|
||||
elif statement['type'] == 'regex':
|
||||
ostream.writeln('string: /%s/' % (statement['pattern']))
|
||||
# regex is a `Statement` not a `Feature`
|
||||
# this is because it doesn't get extracted, but applies to all strings in scope.
|
||||
# so we have to handle it here
|
||||
ostream.writeln('string: %s' % (statement['match']))
|
||||
else:
|
||||
raise RuntimeError("unexpected match statement type: " + str(statement))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user