FeatureExtractor alias: add type casts to either StaticFeatureExtractor or DynamicFeatureExtractor

This commit is contained in:
Yacine Elhamer
2023-06-26 01:23:01 +01:00
parent 172e7a7649
commit 94fc7b4e9a
5 changed files with 33 additions and 7 deletions

View File

@@ -46,6 +46,7 @@ import capa.helpers
import capa.features
import capa.features.common
import capa.features.freeze
from capa.features.extractors.base_extractor import FeatureExtractor
logger = logging.getLogger("capa.profile")
@@ -105,7 +106,7 @@ def main(argv=None):
with open(args.sample, "rb") as f:
extractor = capa.features.freeze.load(f.read())
else:
extractor = capa.main.get_extractor(
extractor: FeatureExtractor = capa.main.get_extractor(
args.sample, args.format, args.os, capa.main.BACKEND_VIV, sig_paths, should_save_workspace=False
)

View File

@@ -70,6 +70,7 @@ 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
from capa.features.extractors.base_extractor import FeatureExtractor
logger = logging.getLogger("capa.show-capabilities-by-function")
@@ -166,7 +167,7 @@ def main(argv=None):
should_save_workspace = os.environ.get("CAPA_SAVE_WORKSPACE") not in ("0", "no", "NO", "n", None)
try:
extractor = capa.main.get_extractor(
extractor: FeatureExtractor = capa.main.get_extractor(
args.sample, args.format, args.os, args.backend, sig_paths, should_save_workspace
)
except capa.exceptions.UnsupportedFormatError: