From e7c0bea6e57f35b0db5de24dc8a8c1c1be0d95d1 Mon Sep 17 00:00:00 2001 From: Yacine Elhamer Date: Fri, 18 Aug 2023 15:05:15 +0200 Subject: [PATCH] Match.from_capa(): remove reliance on the meta field to get the scope --- capa/render/result_document.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/capa/render/result_document.py b/capa/render/result_document.py index 09e04c7f..87790e53 100644 --- a/capa/render/result_document.py +++ b/capa/render/result_document.py @@ -169,7 +169,7 @@ class RangeStatement(StatementModel): class SubscopeStatement(StatementModel): type: Literal["subscope"] = "subscope" description: Optional[str] = None - scopes: capa.rules.Scopes + scope: capa.rules.Scope Statement = Union[ @@ -358,9 +358,11 @@ class Match(FrozenModel): # e.g. `contain loop/30c4c78e29bf4d54894fc74f664c62e8` -> `basic block` # # note! replace `node` + # subscopes cannot have both a static and dynamic scope set + assert None in (rule.scopes.static, rule.scopes.dynamic) node = StatementNode( statement=SubscopeStatement( - scopes=rule.meta["scopes"], + scope=rule.scopes.static or rule.scopes.dynamic, ) )