From 34819b289d67aac0bf2f80d669fb730da4b86320 Mon Sep 17 00:00:00 2001 From: William Ballenthin Date: Wed, 11 Aug 2021 15:08:31 -0600 Subject: [PATCH] pep8 --- capa/features/common.py | 9 +++++---- capa/features/extractors/common.py | 1 - capa/features/extractors/elf.py | 2 +- capa/features/extractors/ida/extractor.py | 4 ++-- capa/helpers.py | 2 +- scripts/detect-elf-os.py | 1 + scripts/show-features.py | 2 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/capa/features/common.py b/capa/features/common.py index 59bf5009..c2851c8c 100644 --- a/capa/features/common.py +++ b/capa/features/common.py @@ -285,9 +285,10 @@ def is_global_feature(feature): is this a feature that is extracted at every scope? today, this are OS and file format features. """ - if (isinstance(feature, Characteristic) + if ( + isinstance(feature, Characteristic) and isinstance(feature.value, str) - and (feature.value.startswith("os/") - or feature.value.startswith("format/"))): + and (feature.value.startswith("os/") or feature.value.startswith("format/")) + ): return True - return False \ No newline at end of file + return False diff --git a/capa/features/extractors/common.py b/capa/features/extractors/common.py index fb47f303..b42ebe13 100644 --- a/capa/features/extractors/common.py +++ b/capa/features/extractors/common.py @@ -6,7 +6,6 @@ import contextlib import capa.features.extractors.elf from capa.features.common import CHARACTERISTIC_PE, CHARACTERISTIC_ELF, CHARACTERISTIC_WINDOWS, Characteristic - logger = logging.getLogger(__name__) diff --git a/capa/features/extractors/elf.py b/capa/features/extractors/elf.py index 45388003..d8d80159 100644 --- a/capa/features/extractors/elf.py +++ b/capa/features/extractors/elf.py @@ -221,4 +221,4 @@ def detect_elf_os(f: BinaryIO) -> str: # so we can get the debugging output of subsequent strategies ret = OS.LINUX if ret is None else ret - return ret.value if ret is not None else "unknown" \ No newline at end of file + return ret.value if ret is not None else "unknown" diff --git a/capa/features/extractors/ida/extractor.py b/capa/features/extractors/ida/extractor.py index c5f3850a..6c4747f9 100644 --- a/capa/features/extractors/ida/extractor.py +++ b/capa/features/extractors/ida/extractor.py @@ -9,16 +9,16 @@ import logging import functools import contextlib -import ida_loader import idaapi +import ida_loader import capa.ida.helpers import capa.features.extractors.elf -from capa.features.common import CHARACTERISTIC_PE, CHARACTERISTIC_ELF, Characteristic import capa.features.extractors.ida.file import capa.features.extractors.ida.insn import capa.features.extractors.ida.function import capa.features.extractors.ida.basicblock +from capa.features.common import CHARACTERISTIC_PE, CHARACTERISTIC_ELF, Characteristic from capa.features.extractors.base_extractor import FeatureExtractor diff --git a/capa/helpers.py b/capa/helpers.py index eaee04bd..1bdad425 100644 --- a/capa/helpers.py +++ b/capa/helpers.py @@ -29,4 +29,4 @@ def is_runtime_ida(): except ImportError: return False else: - return True \ No newline at end of file + return True diff --git a/scripts/detect-elf-os.py b/scripts/detect-elf-os.py index dd8c4d74..c01990f4 100644 --- a/scripts/detect-elf-os.py +++ b/scripts/detect-elf-os.py @@ -27,6 +27,7 @@ logger = logging.getLogger("capa.detect-elf-os") def main(argv=None): if capa.helpers.is_runtime_ida(): from capa.ida.helpers import IDAIO + f: BinaryIO = IDAIO() else: diff --git a/scripts/show-features.py b/scripts/show-features.py index 44808aad..6d69ea7f 100644 --- a/scripts/show-features.py +++ b/scripts/show-features.py @@ -75,8 +75,8 @@ import capa.rules import capa.engine import capa.helpers import capa.features -import capa.features.freeze import capa.features.common +import capa.features.freeze logger = logging.getLogger("capa.show-features")