From 6e0dc83451e6c3d3281a20735bcf87a00a72cc07 Mon Sep 17 00:00:00 2001 From: Mike Hunhoff Date: Fri, 19 Jul 2024 11:51:16 -0600 Subject: [PATCH] vmray: refactor global_.py --- capa/features/extractors/vmray/global_.py | 26 +++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/capa/features/extractors/vmray/global_.py b/capa/features/extractors/vmray/global_.py index 82ab2458..95f7cc90 100644 --- a/capa/features/extractors/vmray/global_.py +++ b/capa/features/extractors/vmray/global_.py @@ -28,15 +28,15 @@ logger = logging.getLogger(__name__) def extract_arch(analysis: VMRayAnalysis) -> Iterator[Tuple[Feature, Address]]: - sample_type: str = analysis.sv2.analysis_metadata.sample_type + file_type: str = analysis.file_type - if "x86-32" in sample_type: + if "x86-32" in file_type: yield Arch(ARCH_I386), NO_ADDRESS - elif "x86-64" in sample_type: + elif "x86-64" in file_type: yield Arch(ARCH_AMD64), NO_ADDRESS else: - logger.warning("unrecognized arch: %s", sample_type) - raise ValueError(f"unrecognized arch from the VMRay report: {sample_type}") + logger.warning("unrecognized arch: %s", file_type) + raise ValueError(f"unrecognized arch from the VMRay report: {file_type}") def extract_format(analysis: VMRayAnalysis) -> Iterator[Tuple[Feature, Address]]: @@ -46,22 +46,20 @@ def extract_format(analysis: VMRayAnalysis) -> Iterator[Tuple[Feature, Address]] elif analysis.sample_file_static_data.elf: yield Format(FORMAT_ELF), NO_ADDRESS else: - logger.warning("unrecognized file format: %s", analysis.sv2.analysis_metadata.sample_type) - raise ValueError( - f"unrecognized file format from the VMRay report: {analysis.sv2.analysis_metadata.sample_type}" - ) + logger.warning("unrecognized file format: %s", analysis.file_type) + raise ValueError(f"unrecognized file format from the VMRay report: {analysis.file_type}") def extract_os(analysis: VMRayAnalysis) -> Iterator[Tuple[Feature, Address]]: - sample_type: str = analysis.sv2.analysis_metadata.sample_type + file_type: str = analysis.file_type - if "windows" in sample_type.lower(): + if "windows" in file_type.lower(): yield OS(OS_WINDOWS), NO_ADDRESS - elif "linux" in sample_type.lower(): + elif "linux" in file_type.lower(): yield OS(OS_LINUX), NO_ADDRESS else: - logger.warning("unrecognized OS: %s", sample_type) - raise ValueError(f"unrecognized OS from the VMRay report: {sample_type}") + logger.warning("unrecognized OS: %s", file_type) + raise ValueError(f"unrecognized OS from the VMRay report: {file_type}") def extract_features(analysis: VMRayAnalysis) -> Iterator[Tuple[Feature, Address]]: