mirror of
https://github.com/mandiant/capa.git
synced 2026-02-04 11:07:53 -08:00
mypy
This commit is contained in:
@@ -312,7 +312,7 @@ def render_node(ostream, layout: rd.Layout, rule: rd.RuleMatches, match: rd.Matc
|
||||
if isinstance(node, rd.StatementNode):
|
||||
render_statement(ostream, layout, match, node.statement, indent=indent)
|
||||
elif isinstance(node, rd.FeatureNode):
|
||||
render_feature(ostream, layout, match, rule, node.feature, indent=indent)
|
||||
render_feature(ostream, layout, rule, match, node.feature, indent=indent)
|
||||
else:
|
||||
raise RuntimeError("unexpected node type: " + str(node))
|
||||
|
||||
@@ -357,7 +357,7 @@ def render_match(ostream, layout: rd.Layout, rule: rd.RuleMatches, match: rd.Mat
|
||||
else:
|
||||
raise RuntimeError("unexpected mode: " + mode)
|
||||
|
||||
render_node(ostream, layout, match, rule, match.node, indent=indent)
|
||||
render_node(ostream, layout, rule, match, match.node, indent=indent)
|
||||
|
||||
for child in match.children:
|
||||
render_match(ostream, layout, rule, child, indent=indent + 1, mode=child_mode)
|
||||
|
||||
@@ -160,6 +160,33 @@ def test_render_vverbose_feature(feature, expected):
|
||||
|
||||
layout = capa.render.result_document.StaticLayout(functions=())
|
||||
|
||||
capa.render.vverbose.render_feature(ostream, layout, matches, feature, indent=0)
|
||||
src = textwrap.dedent(
|
||||
"""
|
||||
rule:
|
||||
meta:
|
||||
name: test rule
|
||||
authors:
|
||||
- user@domain.com
|
||||
scopes:
|
||||
static: function
|
||||
dynamic: process
|
||||
examples:
|
||||
- foo1234
|
||||
- bar5678
|
||||
features:
|
||||
- and:
|
||||
- number: 1
|
||||
- number: 2
|
||||
"""
|
||||
)
|
||||
rule = capa.rules.Rule.from_yaml(src)
|
||||
|
||||
rm = capa.render.result_document.RuleMatches(
|
||||
meta=rule.meta,
|
||||
source=src,
|
||||
matches=(),
|
||||
)
|
||||
|
||||
capa.render.vverbose.render_feature(ostream, layout, rm, matches, feature, indent=0)
|
||||
|
||||
assert ostream.getvalue().strip() == expected
|
||||
|
||||
Reference in New Issue
Block a user