mirror of
https://github.com/mandiant/capa.git
synced 2025-12-12 15:49:46 -08:00
main: fix rule content decoding
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user