diff --git a/scripts/capa_as_library.py b/scripts/capa_as_library.py index 5d97d2b6..f15ca3b4 100644 --- a/scripts/capa_as_library.py +++ b/scripts/capa_as_library.py @@ -14,7 +14,7 @@ import capa.render.default import capa.render.result_document as rd import capa.features.freeze.features as frzf from capa.engine import * -from capa.features.common import OS_AUTO +from capa.features.common import OS_AUTO, FORMAT_AUTO # == Render dictionary helpers @@ -166,12 +166,12 @@ def capa_details(rules_path, file_path, output_format="dictionary"): # extract features and find capabilities extractor = capa.main.get_extractor( - file_path, "auto", OS_AUTO, capa.main.BACKEND_VIV, [], False, disable_progress=True + file_path, FORMAT_AUTO, OS_AUTO, capa.main.BACKEND_VIV, [], False, disable_progress=True ) capabilities, counts = capa.main.find_capabilities(rules, extractor, disable_progress=True) # collect metadata (used only to make rendering more complete) - meta = capa.main.collect_metadata([], file_path, "auto", OS_AUTO, rules_path, extractor) + meta = capa.main.collect_metadata([], file_path, FORMAT_AUTO, OS_AUTO, rules_path, extractor) meta["analysis"].update(counts) meta["analysis"]["layout"] = capa.main.compute_layout(rules, extractor, capabilities) diff --git a/scripts/profile-time.py b/scripts/profile-time.py index 9b97b767..09d125d8 100644 --- a/scripts/profile-time.py +++ b/scripts/profile-time.py @@ -99,7 +99,9 @@ def main(argv=None): logger.error("%s", str(e)) return -1 - if (args.format == "freeze") or (args.format == "auto" and capa.features.freeze.is_freeze(taste)): + if (args.format == "freeze") or ( + args.format == capa.features.common.FORMAT_AUTO and capa.features.freeze.is_freeze(taste) + ): with open(args.sample, "rb") as f: extractor = capa.features.freeze.load(f.read()) else: diff --git a/scripts/show-capabilities-by-function.py b/scripts/show-capabilities-by-function.py index a7dea657..3f37269b 100644 --- a/scripts/show-capabilities-by-function.py +++ b/scripts/show-capabilities-by-function.py @@ -68,6 +68,7 @@ import capa.render.verbose import capa.features.freeze import capa.render.result_document as rd from capa.helpers import get_file_taste +from capa.features.common import FORMAT_AUTO from capa.features.freeze import Address logger = logging.getLogger("capa.show-capabilities-by-function") @@ -156,7 +157,7 @@ def main(argv=None): logger.error("%s", str(e)) return -1 - if (args.format == "freeze") or (args.format == "auto" and capa.features.freeze.is_freeze(taste)): + if (args.format == "freeze") or (args.format == FORMAT_AUTO and capa.features.freeze.is_freeze(taste)): format_ = "freeze" with open(args.sample, "rb") as f: extractor = capa.features.freeze.load(f.read()) diff --git a/scripts/show-features.py b/scripts/show-features.py index 365a6d70..bb83bad9 100644 --- a/scripts/show-features.py +++ b/scripts/show-features.py @@ -113,7 +113,9 @@ def main(argv=None): logger.error("%s", str(e)) return -1 - if (args.format == "freeze") or (args.format == "auto" and capa.features.freeze.is_freeze(taste)): + if (args.format == "freeze") or ( + args.format == capa.features.common.FORMAT_AUTO and capa.features.freeze.is_freeze(taste) + ): with open(args.sample, "rb") as f: extractor = capa.features.freeze.load(f.read()) else: diff --git a/tests/fixtures.py b/tests/fixtures.py index 5fb31539..f482f4f4 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -33,6 +33,7 @@ from capa.features.common import ( ARCH_AMD64, FORMAT_ELF, OS_WINDOWS, + FORMAT_AUTO, FORMAT_DOTNET, Arch, Format, @@ -105,7 +106,7 @@ def get_viv_extractor(path): elif "raw64" in path: vw = capa.main.get_workspace(path, "sc64", sigpaths=sigpaths) else: - vw = capa.main.get_workspace(path, "auto", sigpaths=sigpaths) + vw = capa.main.get_workspace(path, FORMAT_AUTO, sigpaths=sigpaths) vw.saveWorkspace() extractor = capa.features.extractors.viv.extractor.VivisectFeatureExtractor(vw, path, OS_AUTO) fixup_viv(path, extractor)