diff --git a/capa/render/__init__.py b/capa/render/__init__.py index 1593fdf9..9de20bd5 100644 --- a/capa/render/__init__.py +++ b/capa/render/__init__.py @@ -244,6 +244,7 @@ def render_default(meta, rules, capabilities): doc = convert_capabilities_to_result_document(meta, rules, capabilities) return capa.render.default.render_default(doc) + class CapaJsonObjectEncoder(json.JSONEncoder): """JSON encoder that emits Python sets as sorted lists""" diff --git a/scripts/capa_as_library.py b/scripts/capa_as_library.py index 47290539..4b1de0ab 100644 --- a/scripts/capa_as_library.py +++ b/scripts/capa_as_library.py @@ -25,6 +25,7 @@ def render_meta(doc, ostream): ostream["sha256"] = doc["meta"]["sample"]["sha256"] ostream["path"] = doc["meta"]["sample"]["path"] + def find_subrule_matches(doc): """ collect the rule names that have been matched as a subrule match. @@ -83,6 +84,7 @@ def render_capabilities(doc, ostream): ostream["CAPABILITY"].setdefault(rule["meta"]["namespace"], list()) ostream["CAPABILITY"][rule["meta"]["namespace"]].append(capability) + def render_attack(doc, ostream): """ example:: @@ -174,6 +176,7 @@ def render_mbc(doc, ostream): raise RuntimeError("unexpected MBC spec format") ostream["MBC"].setdefault(objective.upper(), inner_rows) + def render_dictionary(doc): ostream = dict() render_meta(doc, ostream) @@ -183,8 +186,9 @@ def render_dictionary(doc): return ostream + # ==== render dictionary helpers -def capa_details(file_path: str, output_format: str="dictionary") -> dict: +def capa_details(file_path: str, output_format: str = "dictionary") -> dict: # extract features and find capabilities extractor = capa.main.get_extractor(file_path, "auto", disable_progress=True)