diff --git a/capa/main.py b/capa/main.py index d88722a2..d6817f8b 100644 --- a/capa/main.py +++ b/capa/main.py @@ -620,7 +620,7 @@ def get_rules(rule_paths: List[str], disable_progress=False) -> RuleSet: for path, content in pbar(zip(rule_file_paths, rule_contents), desc="parsing ", unit=" rules"): try: - rule = capa.rules.Rule.from_yaml(content) + rule = capa.rules.Rule.from_yaml(content.decode("utf-8")) except capa.rules.InvalidRule: raise else: diff --git a/capa/rules/__init__.py b/capa/rules/__init__.py index ac344334..028f023a 100644 --- a/capa/rules/__init__.py +++ b/capa/rules/__init__.py @@ -743,7 +743,7 @@ class Rule: return self.statement.evaluate(features, short_circuit=short_circuit) @classmethod - def from_dict(cls, d, definition) -> "Rule": + def from_dict(cls, d: Dict[str, Any], definition: str) -> "Rule": meta = d["rule"]["meta"] name = meta["name"] # if scope is not specified, default to function scope. @@ -813,7 +813,7 @@ class Rule: return y @classmethod - def from_yaml(cls, s, use_ruamel=False) -> "Rule": + def from_yaml(cls, s: str, use_ruamel=False) -> "Rule": if use_ruamel: # ruamel enables nice formatting and doc roundtripping with comments doc = cls._get_ruamel_yaml_parser().load(s)