From 139dcc430c9c947bca118d87c740fca95a7ccc95 Mon Sep 17 00:00:00 2001 From: Mike Hunhoff Date: Mon, 29 Jul 2024 12:16:05 -0600 Subject: [PATCH] vmray: improve logging --- capa/features/extractors/vmray/__init__.py | 8 ++++---- capa/features/extractors/vmray/global_.py | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/capa/features/extractors/vmray/__init__.py b/capa/features/extractors/vmray/__init__.py index 95f1f3e0..88d2a8e2 100644 --- a/capa/features/extractors/vmray/__init__.py +++ b/capa/features/extractors/vmray/__init__.py @@ -39,7 +39,7 @@ class VMRayAnalysis: if self.flog.analysis.log_version not in SUPPORTED_FLOG_VERSIONS: raise UnsupportedFormatError( - "VMRay feature extractor does not support flog version %s", self.flog.analysis.log_version + "VMRay feature extractor does not support flog version %s" % self.flog.analysis.log_version ) self.exports: Dict[int, str] = {} @@ -57,14 +57,14 @@ class VMRayAnalysis: self._find_sample_file() if self.sample_file_name is None or self.sample_file_analysis is None: - raise UnsupportedFormatError("VMRay archive does not contain sample file (file_type: %s)", self.file_type) + raise UnsupportedFormatError("VMRay archive does not contain sample file (file_type: %s)" % self.file_type) if not self.sample_file_static_data: - raise UnsupportedFormatError("VMRay archive does not contain static data (file_type: %s)", self.file_type) + raise UnsupportedFormatError("VMRay archive does not contain static data (file_type: %s)" % self.file_type) if not self.sample_file_static_data.pe and not self.sample_file_static_data.elf: raise UnsupportedFormatError( - "VMRay feature extractor only supports PE and ELF at this time (file_type: %s)", self.file_type + "VMRay feature extractor only supports PE and ELF at this time (file_type: %s)" % self.file_type ) # VMRay does not store static strings for the sample file so we must use the source file diff --git a/capa/features/extractors/vmray/global_.py b/capa/features/extractors/vmray/global_.py index 95f7cc90..a42ce511 100644 --- a/capa/features/extractors/vmray/global_.py +++ b/capa/features/extractors/vmray/global_.py @@ -35,8 +35,7 @@ def extract_arch(analysis: VMRayAnalysis) -> Iterator[Tuple[Feature, Address]]: elif "x86-64" in file_type: yield Arch(ARCH_AMD64), NO_ADDRESS else: - logger.warning("unrecognized arch: %s", file_type) - raise ValueError(f"unrecognized arch from the VMRay report: {file_type}") + raise ValueError("unrecognized arch from the VMRay report: %s" % file_type) def extract_format(analysis: VMRayAnalysis) -> Iterator[Tuple[Feature, Address]]: @@ -46,8 +45,7 @@ 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.file_type) - raise ValueError(f"unrecognized file format from the VMRay report: {analysis.file_type}") + raise ValueError("unrecognized file format from the VMRay report: %s" % analysis.file_type) def extract_os(analysis: VMRayAnalysis) -> Iterator[Tuple[Feature, Address]]: @@ -58,8 +56,7 @@ def extract_os(analysis: VMRayAnalysis) -> Iterator[Tuple[Feature, Address]]: elif "linux" in file_type.lower(): yield OS(OS_LINUX), NO_ADDRESS else: - logger.warning("unrecognized OS: %s", file_type) - raise ValueError(f"unrecognized OS from the VMRay report: {file_type}") + raise ValueError("unrecognized OS from the VMRay report: %s" % file_type) def extract_features(analysis: VMRayAnalysis) -> Iterator[Tuple[Feature, Address]]: