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: lint errors and code style improvements

0xallam1edd8eda01a6
diff --git a/strix/interface/main.py b/strix/interface/main.py
index 54f29418..6d48227d 100644
--- a/strix/interface/main.py
+++ b/strix/interface/main.py
@@ -98,7 +98,8 @@ def validate_environment() -> None: # noqa: PLR0912, PLR0915
error_text.append("• ", style="white")
error_text.append("LLM_API_KEY", style="bold cyan")
error_text.append(
- " - API key for the LLM provider (not needed for local models, Vertex AI, AWS, etc.)\n",
+ " - API key for the LLM provider "
+ "(not needed for local models, Vertex AI, AWS, etc.)\n",
style="white",
)
elif var == "LLM_API_BASE":
@@ -123,7 +124,8 @@ def validate_environment() -> None: # noqa: PLR0912, PLR0915
for var in missing_optional_vars:
if var == "LLM_API_KEY":
error_text.append(
- "export LLM_API_KEY='your-api-key-here' # not needed for local models, Vertex AI, AWS, etc.\n",
+ "export LLM_API_KEY='your-api-key-here' "
+ "# not needed for local models, Vertex AI, AWS, etc.\n",
style="dim white",
)
elif var == "LLM_API_BASE":
diff --git a/strix/llm/llm.py b/strix/llm/llm.py
index 6ea67767..50e0003e 100644
--- a/strix/llm/llm.py
+++ b/strix/llm/llm.py
@@ -392,26 +392,27 @@ class LLM:
if not self.config.model_name:
return False
try:
- return supports_vision(model=self.config.model_name)
+ return bool(supports_vision(model=self.config.model_name))
except Exception: # noqa: BLE001
return False
- def _filter_images_from_messages(
- self, messages: list[dict[str, Any]]
- ) -> list[dict[str, Any]]:
+ def _filter_images_from_messages(self, messages: list[dict[str, Any]]) -> list[dict[str, Any]]:
filtered_messages = []
for msg in messages:
content = msg.get("content")
+ updated_msg = msg
if isinstance(content, list):
filtered_content = []
for item in content:
if isinstance(item, dict):
if item.get("type") == "image_url":
- filtered_content.append({
- "type": "text",
- "text": "[Screenshot removed - model does not support vision. "
- "Use view_source or execute_js to interact with the page instead.]",
- })
+ filtered_content.append(
+ {
+ "type": "text",
+ "text": "[Screenshot removed - model does not support "
+ "vision. Use view_source or execute_js instead.]",
+ }
+ )
else:
filtered_content.append(item)
else:
@@ -421,13 +422,17 @@ class LLM:
item.get("text", "") if isinstance(item, dict) else str(item)
for item in filtered_content
]
- if all(isinstance(item, dict) and item.get("type") == "text" for item in filtered_content):
- msg = {**msg, "content": "\n".join(text_parts)}
+ all_text = all(
+ isinstance(item, dict) and item.get("type") == "text"
+ for item in filtered_content
+ )
+ if all_text:
+ updated_msg = {**msg, "content": "\n".join(text_parts)}
else:
- msg = {**msg, "content": filtered_content}
+ updated_msg = {**msg, "content": filtered_content}
else:
- msg = {**msg, "content": ""}
- filtered_messages.append(msg)
+ updated_msg = {**msg, "content": ""}
+ filtered_messages.append(updated_msg)
return filtered_messages
async def _make_request(
diff --git a/strix/runtime/docker_runtime.py b/strix/runtime/docker_runtime.py
index 63cb7a03..7ba04f88 100644
--- a/strix/runtime/docker_runtime.py
+++ b/strix/runtime/docker_runtime.py
@@ -203,7 +203,7 @@ class DockerRuntime(AbstractRuntime):
all=True, filters={"label": f"strix-scan-id={scan_id}"}
)
if containers:
- container = cast("Container", containers[0])
+ container = containers[0]
if container.status != "running":
container.start()
time.sleep(2)