From 93e7206bb2a5105214f1e1e38f2fbd7f23233f20 Mon Sep 17 00:00:00 2001 From: Michael Hunhoff Date: Fri, 3 Jul 2020 14:32:41 -0600 Subject: [PATCH] removing circular import --- capa/features/extractors/__init__.py | 13 ------------- capa/features/extractors/ida/__init__.py | 8 +++++--- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/capa/features/extractors/__init__.py b/capa/features/extractors/__init__.py index 85d1bd49..fed476f2 100644 --- a/capa/features/extractors/__init__.py +++ b/capa/features/extractors/__init__.py @@ -1,18 +1,5 @@ import abc -try: - import ida -except (ImportError, SyntaxError): - pass - -try: - import viv -except (ImportError, SyntaxError): - pass - -__all__ = ["ida", "viv"] - - class FeatureExtractor(object): """ FeatureExtractor defines the interface for fetching features from a sample. diff --git a/capa/features/extractors/ida/__init__.py b/capa/features/extractors/ida/__init__.py index 5091fb34..c89ac82f 100644 --- a/capa/features/extractors/ida/__init__.py +++ b/capa/features/extractors/ida/__init__.py @@ -5,9 +5,9 @@ import idaapi import capa.features.extractors.ida.file import capa.features.extractors.ida.insn -import capa.features.extractors.ida.helpers import capa.features.extractors.ida.function import capa.features.extractors.ida.basicblock + from capa.features.extractors import FeatureExtractor @@ -51,7 +51,8 @@ class IdaFeatureExtractor(FeatureExtractor): yield feature, va def get_functions(self): - for f in capa.features.extractors.ida.helpers.get_functions(ignore_thunks=True, ignore_libs=True): + import capa.features.extractors.ida.helpers as ida_helpers + for f in ida_helpers.get_functions(ignore_thunks=True, ignore_libs=True): yield add_va_int_cast(f) def extract_function_features(self, f): @@ -67,7 +68,8 @@ class IdaFeatureExtractor(FeatureExtractor): yield feature, va def get_instructions(self, f, bb): - for insn in capa.features.extractors.ida.helpers.get_instructions_in_range(bb.start_ea, bb.end_ea): + import capa.features.extractors.ida.helpers as ida_helpers + for insn in ida_helpers.get_instructions_in_range(bb.start_ea, bb.end_ea): yield add_va_int_cast(insn) def extract_insn_features(self, f, bb, insn):