refactor: remove STRIX_IMAGE constant, use Config.get() instead
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,7 +34,7 @@ from strix.interface.utils import (
|
|||||||
rewrite_localhost_targets,
|
rewrite_localhost_targets,
|
||||||
validate_llm_response,
|
validate_llm_response,
|
||||||
)
|
)
|
||||||
from strix.runtime.docker_runtime import HOST_GATEWAY_HOSTNAME, STRIX_IMAGE
|
from strix.runtime.docker_runtime import HOST_GATEWAY_HOSTNAME
|
||||||
from strix.telemetry import posthog
|
from strix.telemetry import posthog
|
||||||
from strix.telemetry.tracer import get_global_tracer
|
from strix.telemetry.tracer import get_global_tracer
|
||||||
|
|
||||||
@@ -467,11 +467,11 @@ def pull_docker_image() -> None:
|
|||||||
console = Console()
|
console = Console()
|
||||||
client = check_docker_connection()
|
client = check_docker_connection()
|
||||||
|
|
||||||
if image_exists(client, STRIX_IMAGE):
|
if image_exists(client, Config.get("strix_image")): # type: ignore[arg-type]
|
||||||
return
|
return
|
||||||
|
|
||||||
console.print()
|
console.print()
|
||||||
console.print(f"[bold cyan]🐳 Pulling Docker image:[/] {STRIX_IMAGE}")
|
console.print(f"[bold cyan]🐳 Pulling Docker image:[/] {Config.get('strix_image')}")
|
||||||
console.print("[dim yellow]This only happens on first run and may take a few minutes...[/]")
|
console.print("[dim yellow]This only happens on first run and may take a few minutes...[/]")
|
||||||
console.print()
|
console.print()
|
||||||
|
|
||||||
@@ -480,7 +480,7 @@ def pull_docker_image() -> None:
|
|||||||
layers_info: dict[str, str] = {}
|
layers_info: dict[str, str] = {}
|
||||||
last_update = ""
|
last_update = ""
|
||||||
|
|
||||||
for line in client.api.pull(STRIX_IMAGE, stream=True, decode=True):
|
for line in client.api.pull(Config.get("strix_image"), stream=True, decode=True):
|
||||||
last_update = process_pull_line(line, layers_info, status, last_update)
|
last_update = process_pull_line(line, layers_info, status, last_update)
|
||||||
|
|
||||||
except DockerException as e:
|
except DockerException as e:
|
||||||
@@ -489,7 +489,7 @@ def pull_docker_image() -> None:
|
|||||||
error_text.append("❌ ", style="bold red")
|
error_text.append("❌ ", style="bold red")
|
||||||
error_text.append("FAILED TO PULL IMAGE", style="bold red")
|
error_text.append("FAILED TO PULL IMAGE", style="bold red")
|
||||||
error_text.append("\n\n", style="white")
|
error_text.append("\n\n", style="white")
|
||||||
error_text.append(f"Could not download: {STRIX_IMAGE}\n", style="white")
|
error_text.append(f"Could not download: {Config.get('strix_image')}\n", style="white")
|
||||||
error_text.append(str(e), style="dim red")
|
error_text.append(str(e), style="dim red")
|
||||||
|
|
||||||
panel = Panel(
|
panel = Panel(
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ from . import SandboxInitializationError
|
|||||||
from .runtime import AbstractRuntime, SandboxInfo
|
from .runtime import AbstractRuntime, SandboxInfo
|
||||||
|
|
||||||
|
|
||||||
STRIX_IMAGE: str = Config.get("strix_image") # type: ignore[assignment]
|
|
||||||
HOST_GATEWAY_HOSTNAME = "host.docker.internal"
|
HOST_GATEWAY_HOSTNAME = "host.docker.internal"
|
||||||
DOCKER_TIMEOUT = 60 # seconds
|
DOCKER_TIMEOUT = 60 # seconds
|
||||||
TOOL_SERVER_HEALTH_REQUEST_TIMEOUT = 5 # seconds per health check request
|
TOOL_SERVER_HEALTH_REQUEST_TIMEOUT = 5 # seconds per health check request
|
||||||
@@ -123,7 +122,7 @@ class DockerRuntime(AbstractRuntime):
|
|||||||
|
|
||||||
for attempt in range(max_retries):
|
for attempt in range(max_retries):
|
||||||
try:
|
try:
|
||||||
self._verify_image_available(STRIX_IMAGE)
|
self._verify_image_available(Config.get("strix_image")) # type: ignore[arg-type]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
existing_container = self.client.containers.get(container_name)
|
existing_container = self.client.containers.get(container_name)
|
||||||
@@ -144,27 +143,30 @@ class DockerRuntime(AbstractRuntime):
|
|||||||
self._tool_server_port = tool_server_port
|
self._tool_server_port = tool_server_port
|
||||||
self._tool_server_token = tool_server_token
|
self._tool_server_token = tool_server_token
|
||||||
|
|
||||||
container = self.client.containers.run(
|
container = cast(
|
||||||
STRIX_IMAGE,
|
"Container",
|
||||||
command="sleep infinity",
|
self.client.containers.run( # type: ignore[call-overload]
|
||||||
detach=True,
|
Config.get("strix_image"),
|
||||||
name=container_name,
|
command="sleep infinity",
|
||||||
hostname=f"strix-scan-{scan_id}",
|
detach=True,
|
||||||
ports={
|
name=container_name,
|
||||||
f"{caido_port}/tcp": caido_port,
|
hostname=f"strix-scan-{scan_id}",
|
||||||
f"{tool_server_port}/tcp": tool_server_port,
|
ports={
|
||||||
},
|
f"{caido_port}/tcp": caido_port,
|
||||||
cap_add=["NET_ADMIN", "NET_RAW"],
|
f"{tool_server_port}/tcp": tool_server_port,
|
||||||
labels={"strix-scan-id": scan_id},
|
},
|
||||||
environment={
|
cap_add=["NET_ADMIN", "NET_RAW"],
|
||||||
"PYTHONUNBUFFERED": "1",
|
labels={"strix-scan-id": scan_id},
|
||||||
"CAIDO_PORT": str(caido_port),
|
environment={
|
||||||
"TOOL_SERVER_PORT": str(tool_server_port),
|
"PYTHONUNBUFFERED": "1",
|
||||||
"TOOL_SERVER_TOKEN": tool_server_token,
|
"CAIDO_PORT": str(caido_port),
|
||||||
"HOST_GATEWAY": HOST_GATEWAY_HOSTNAME,
|
"TOOL_SERVER_PORT": str(tool_server_port),
|
||||||
},
|
"TOOL_SERVER_TOKEN": tool_server_token,
|
||||||
extra_hosts=self._get_extra_hosts(),
|
"HOST_GATEWAY": HOST_GATEWAY_HOSTNAME,
|
||||||
tty=True,
|
},
|
||||||
|
extra_hosts=self._get_extra_hosts(),
|
||||||
|
tty=True,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
self._scan_container = container
|
self._scan_container = container
|
||||||
|
|||||||
Reference in New Issue
Block a user