From 890870bf452a70fe83eb227c84ed933599a4a2a0 Mon Sep 17 00:00:00 2001 From: Willi Ballenthin Date: Mon, 28 Mar 2022 12:54:54 -0600 Subject: [PATCH] rules: let subscope blocks have descriptions --- capa/engine.py | 4 ++-- capa/rules.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/capa/engine.py b/capa/engine.py index 19207afc..b28a15a2 100644 --- a/capa/engine.py +++ b/capa/engine.py @@ -235,8 +235,8 @@ class Subscope(Statement): the engine should preprocess rules to extract subscope statements into their own rules. """ - def __init__(self, scope, child): - super(Subscope, self).__init__() + def __init__(self, scope, child, description=None): + super(Subscope, self).__init__(description=description) self.scope = scope self.child = child diff --git a/capa/rules.py b/capa/rules.py index 18bfa061..b57e7b51 100644 --- a/capa/rules.py +++ b/capa/rules.py @@ -426,7 +426,7 @@ def build_statements(d, scope: str): if len(d[key]) != 1: raise InvalidRule("subscope must have exactly one child statement") - return ceng.Subscope(FUNCTION_SCOPE, build_statements(d[key][0], FUNCTION_SCOPE)) + return ceng.Subscope(FUNCTION_SCOPE, build_statements(d[key][0], FUNCTION_SCOPE), description=description) elif key == "basic block": if scope != FUNCTION_SCOPE: @@ -435,7 +435,7 @@ def build_statements(d, scope: str): if len(d[key]) != 1: raise InvalidRule("subscope must have exactly one child statement") - return ceng.Subscope(BASIC_BLOCK_SCOPE, build_statements(d[key][0], BASIC_BLOCK_SCOPE)) + return ceng.Subscope(BASIC_BLOCK_SCOPE, build_statements(d[key][0], BASIC_BLOCK_SCOPE), description=description) elif key.startswith("count(") and key.endswith(")"): # e.g.: