fix 109
This commit is contained in:
@@ -161,6 +161,7 @@ class SubprocessAnalyzer(ABC):
|
||||
self.update_result(result)
|
||||
except Exception as e:
|
||||
self.update_result({"status": "error", "error": str(e)})
|
||||
raise
|
||||
|
||||
def is_error(self, returncode: int, stdout: str, stderr: str, zip_exist: bool) -> bool:
|
||||
"""Check if the result is an error."""
|
||||
|
||||
@@ -20,7 +20,6 @@ class DecomposerAnalyzer(SubprocessAnalyzer):
|
||||
|
||||
def get_results(self, _: Optional[str] = None) -> dict[str, Any]:
|
||||
"""Analyze an image submission using bits decomposition."""
|
||||
try:
|
||||
img = Image.open(self.input_img)
|
||||
converted = False
|
||||
|
||||
@@ -85,8 +84,6 @@ class DecomposerAnalyzer(SubprocessAnalyzer):
|
||||
)
|
||||
|
||||
return output
|
||||
except Exception as e:
|
||||
return {"status": "error", "error": str(e)}
|
||||
|
||||
|
||||
def analyze_decomposer(input_img: Path, output_dir: Path) -> None:
|
||||
|
||||
@@ -115,7 +115,6 @@ class ResizeAnalyzer(SubprocessAnalyzer):
|
||||
"""
|
||||
logs = []
|
||||
|
||||
try:
|
||||
with self.input_img.open("rb") as image:
|
||||
img_bytes = bytearray(image.read())
|
||||
try:
|
||||
@@ -160,8 +159,6 @@ class ResizeAnalyzer(SubprocessAnalyzer):
|
||||
"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:
|
||||
|
||||
@@ -44,6 +44,7 @@ class OpenStegoAnalyzer(SubprocessAnalyzer):
|
||||
self.update_result(result)
|
||||
except Exception as e:
|
||||
self.update_result({"status": "error", "error": str(e)})
|
||||
raise
|
||||
|
||||
def process_output(self, stdout: str, stderr: str) -> str | list[str] | dict[str, str]:
|
||||
"""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:
|
||||
"""Run an analyzer function in a separate thread."""
|
||||
analyzer_name = analyzer_func.__name__.replace("analyze_", "")
|
||||
try:
|
||||
analyzer_func(*args)
|
||||
except Exception as e:
|
||||
sentry_sdk.capture_exception(e)
|
||||
print(f"Error in {analyzer_func.__name__}: {e}")
|
||||
print(f"Error in {analyzer_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)
|
||||
|
||||
analyzers = [
|
||||
|
||||
Reference in New Issue
Block a user