fix 109
This commit is contained in:
@@ -161,6 +161,7 @@ class SubprocessAnalyzer(ABC):
|
|||||||
self.update_result(result)
|
self.update_result(result)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.update_result({"status": "error", "error": str(e)})
|
self.update_result({"status": "error", "error": str(e)})
|
||||||
|
raise
|
||||||
|
|
||||||
def is_error(self, returncode: int, stdout: str, stderr: str, zip_exist: bool) -> bool:
|
def is_error(self, returncode: int, stdout: str, stderr: str, zip_exist: bool) -> bool:
|
||||||
"""Check if the result is an error."""
|
"""Check if the result is an error."""
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ class DecomposerAnalyzer(SubprocessAnalyzer):
|
|||||||
|
|
||||||
def get_results(self, _: Optional[str] = None) -> dict[str, Any]:
|
def get_results(self, _: Optional[str] = None) -> dict[str, Any]:
|
||||||
"""Analyze an image submission using bits decomposition."""
|
"""Analyze an image submission using bits decomposition."""
|
||||||
try:
|
|
||||||
img = Image.open(self.input_img)
|
img = Image.open(self.input_img)
|
||||||
converted = False
|
converted = False
|
||||||
|
|
||||||
@@ -85,8 +84,6 @@ class DecomposerAnalyzer(SubprocessAnalyzer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return output
|
return output
|
||||||
except Exception as e:
|
|
||||||
return {"status": "error", "error": str(e)}
|
|
||||||
|
|
||||||
|
|
||||||
def analyze_decomposer(input_img: Path, output_dir: Path) -> None:
|
def analyze_decomposer(input_img: Path, output_dir: Path) -> None:
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ class ResizeAnalyzer(SubprocessAnalyzer):
|
|||||||
"""
|
"""
|
||||||
logs = []
|
logs = []
|
||||||
|
|
||||||
try:
|
|
||||||
with self.input_img.open("rb") as image:
|
with self.input_img.open("rb") as image:
|
||||||
img_bytes = bytearray(image.read())
|
img_bytes = bytearray(image.read())
|
||||||
try:
|
try:
|
||||||
@@ -160,8 +159,6 @@ class ResizeAnalyzer(SubprocessAnalyzer):
|
|||||||
"png_images": saved_img_urls,
|
"png_images": saved_img_urls,
|
||||||
}
|
}
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
return {"status": "error", "error": str(e)}
|
|
||||||
|
|
||||||
|
|
||||||
def analyze_image_resize(input_img: Path, output_dir: Path) -> None:
|
def analyze_image_resize(input_img: Path, output_dir: Path) -> None:
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class OpenStegoAnalyzer(SubprocessAnalyzer):
|
|||||||
self.update_result(result)
|
self.update_result(result)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.update_result({"status": "error", "error": str(e)})
|
self.update_result({"status": "error", "error": str(e)})
|
||||||
|
raise
|
||||||
|
|
||||||
def process_output(self, stdout: str, stderr: str) -> str | list[str] | dict[str, str]:
|
def process_output(self, stdout: str, stderr: str) -> str | list[str] | dict[str, str]:
|
||||||
"""Process the stdout/stderr."""
|
"""Process the stdout/stderr."""
|
||||||
|
|||||||
+16
-2
@@ -77,11 +77,25 @@ def analyze_image(submission_hash: str) -> None:
|
|||||||
|
|
||||||
def run_analyzer(analyzer_func: Any, *args: Any) -> None:
|
def run_analyzer(analyzer_func: Any, *args: Any) -> None:
|
||||||
"""Run an analyzer function in a separate thread."""
|
"""Run an analyzer function in a separate thread."""
|
||||||
|
analyzer_name = analyzer_func.__name__.replace("analyze_", "")
|
||||||
try:
|
try:
|
||||||
analyzer_func(*args)
|
analyzer_func(*args)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sentry_sdk.capture_exception(e)
|
print(f"Error in {analyzer_name}: {e}")
|
||||||
print(f"Error in {analyzer_func.__name__}: {e}")
|
with sentry_sdk.push_scope() as scope:
|
||||||
|
scope.set_tag("analyzer", analyzer_name)
|
||||||
|
scope.set_tag("submission_hash", submission_hash)
|
||||||
|
scope.set_context(
|
||||||
|
"analyzer_info",
|
||||||
|
{
|
||||||
|
"tool": analyzer_name,
|
||||||
|
"image_path": str(img_path),
|
||||||
|
"result_path": str(result_path),
|
||||||
|
"filename": submission.filename,
|
||||||
|
"deep_analysis": submission.deep_analysis,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
scope.fingerprint = ["analyzer-error", analyzer_name]
|
||||||
sentry_sdk.capture_exception(e)
|
sentry_sdk.capture_exception(e)
|
||||||
|
|
||||||
analyzers = [
|
analyzers = [
|
||||||
|
|||||||
Reference in New Issue
Block a user