From 0cf8b154a415f4a3f2db3970848f2bce65a0ddbf Mon Sep 17 00:00:00 2001 From: Willi Ballenthin Date: Tue, 21 Mar 2023 13:53:59 +0100 Subject: [PATCH] pep8 --- capa/features/extractors/common.py | 15 +++++++++++++-- capa/main.py | 28 ++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/capa/features/extractors/common.py b/capa/features/extractors/common.py index 89f70e56..3c1145ce 100644 --- a/capa/features/extractors/common.py +++ b/capa/features/extractors/common.py @@ -10,7 +10,18 @@ import capa.features import capa.features.extractors.elf import capa.features.extractors.pefile import capa.features.extractors.strings -from capa.features.common import OS, FORMAT_PE, FORMAT_ELF, OS_AUTO, OS_WINDOWS, FORMAT_FREEZE, Arch, Format, String, Feature +from capa.features.common import ( + OS, + OS_AUTO, + FORMAT_PE, + FORMAT_ELF, + OS_WINDOWS, + FORMAT_FREEZE, + Arch, + Format, + String, + Feature, +) from capa.features.freeze import is_freeze from capa.features.address import NO_ADDRESS, Address, FileOffsetAddress @@ -73,7 +84,7 @@ def extract_arch(buf) -> Iterator[Tuple[Feature, Address]]: return -def extract_os(buf, os = OS_AUTO) -> Iterator[Tuple[Feature, Address]]: +def extract_os(buf, os=OS_AUTO) -> Iterator[Tuple[Feature, Address]]: if os != OS_AUTO: yield OS(os), NO_ADDRESS diff --git a/capa/main.py b/capa/main.py index 1e893451..a6e70d26 100644 --- a/capa/main.py +++ b/capa/main.py @@ -58,17 +58,17 @@ from capa.helpers import ( ) from capa.exceptions import UnsupportedOSError, UnsupportedArchError, UnsupportedFormatError, UnsupportedRuntimeError from capa.features.common import ( + OS_AUTO, + OS_LINUX, + OS_MACOS, FORMAT_PE, FORMAT_ELF, + OS_WINDOWS, FORMAT_AUTO, FORMAT_SC32, FORMAT_SC64, FORMAT_DOTNET, FORMAT_FREEZE, - OS_AUTO, - OS_LINUX, - OS_MACOS, - OS_WINDOWS ) from capa.features.address import NO_ADDRESS, Address from capa.features.extractors.base_extractor import BBHandle, InsnHandle, FunctionHandle, FeatureExtractor @@ -494,7 +494,13 @@ def get_workspace(path, format_, sigpaths): # TODO get_extractors -> List[FeatureExtractor]? def get_extractor( - path: str, format_: str, os: str, backend: str, sigpaths: List[str], should_save_workspace=False, disable_progress=False + path: str, + format_: str, + os: str, + backend: str, + sigpaths: List[str], + should_save_workspace=False, + disable_progress=False, ) -> FeatureExtractor: """ raises: @@ -830,7 +836,7 @@ def install_common_args(parser, wanted=None): # # - sample # - format - # - os + # - os # - rules # - tag # @@ -870,7 +876,7 @@ def install_common_args(parser, wanted=None): choices=(BACKEND_VIV,), default=BACKEND_VIV, ) - + if "os" in wanted: oses = [ (OS_AUTO, "detect OS automatically - default"), @@ -1165,7 +1171,13 @@ def main(argv=None): try: extractor = get_extractor( - args.sample, format_, args.os, args.backend, sig_paths, should_save_workspace, disable_progress=args.quiet + args.sample, + format_, + args.os, + args.backend, + sig_paths, + should_save_workspace, + disable_progress=args.quiet, ) except UnsupportedFormatError: log_unsupported_format_error()