From c2516e7453ef5f339040031734a2926ba710ab29 Mon Sep 17 00:00:00 2001 From: William Ballenthin Date: Wed, 23 Sep 2020 11:19:01 -0600 Subject: [PATCH] main: fix reported total rule count closes #325 --- capa/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/capa/main.py b/capa/main.py index 910e3f31..474a435a 100644 --- a/capa/main.py +++ b/capa/main.py @@ -536,7 +536,13 @@ def main(argv=None): try: rules = get_rules(rules_path, disable_progress=args.quiet) rules = capa.rules.RuleSet(rules) - logger.debug("successfully loaded %s rules", len(rules)) + logger.debug( + "successfully loaded %s rules", + # during the load of the RuleSet, we extract subscope statements into their own rules + # that are subsequently `match`ed upon. this inflates the total rule count. + # so, filter out the subscope rules when reporting total number of loaded rules. + len(filter(lambda r: "capa/subscope-rule" not in r.meta, rules.rules.values())), + ) if args.tag: rules = rules.filter_rules_by_meta(args.tag) logger.debug("selected %s rules", len(rules))