Skip to content

armgit / strix

Public Imported from GitHub
0

Open-source AI penetration testing tool to find and fix your app’s vulnerabilities.

fix(proxy): log Caido timeouts as warnings

Ianc5854e7be27d
diff --git a/strix/tools/proxy/tools.py b/strix/tools/proxy/tools.py
index 0dc2a03c..0cf3f11f 100644
--- a/strix/tools/proxy/tools.py
+++ b/strix/tools/proxy/tools.py
@@ -124,7 +124,11 @@ def _no_client() -> str:
def _err(name: str, exc: Exception) -> str:
- logger.exception("%s failed", name)
+ # The Caido SDK wraps its GraphQL timeout in an error with an empty message.
+ if isinstance(exc.__cause__, TimeoutError):
+ logger.warning("%s timed out", name)
+ else:
+ logger.exception("%s failed", name)
return json.dumps(
{"success": False, "error": f"{name} failed: {exc}"},
ensure_ascii=False,
diff --git a/tests/test_proxy_client.py b/tests/test_proxy_client.py
index ec21925c..a9c9660f 100644
--- a/tests/test_proxy_client.py
+++ b/tests/test_proxy_client.py
@@ -252,3 +252,15 @@ async def test_existing_request_ids_queries_current_project(
assert existing == {"1042"}
assert looked_up == ["1042", "1088"]
+
+
+def test_err_logs_caido_timeout_as_warning(caplog: pytest.LogCaptureFixture) -> None:
+ exc = RuntimeError()
+ exc.__cause__ = TimeoutError()
+
+ with caplog.at_level("WARNING", logger="strix.tools.proxy.tools"):
+ tools._err("list_requests", exc)
+
+ [record] = caplog.records
+ assert record.levelname == "WARNING"
+ assert record.exc_info is None