From a37b5b702525e3b5b98f9e93f7bb406cd77ca9a0 Mon Sep 17 00:00:00 2001 From: BaaRai <130491490+BaaRai@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:34:59 +0100 Subject: [PATCH 1/2] release: package the sandbox images for the 0.7.1 default The panel refuses tasks when artex-runner is unavailable, so the runner, worker and egress proxy are now part of docker-compose.yml and docker-compose.ghcr.yml. install.sh and update.sh generate ARTEX_RUNNER_TOKEN and build the three images; the release workflow publishes them beside the panel image. The changelog records the security fixes, the upgrade steps and the scope re-approval. --- .env.example | 6 ++++ .github/workflows/release.yml | 65 +++++++++++++++++++++++++++++++++-- CHANGELOG.md | 27 +++++++++++---- README.md | 28 +++++++++++++-- docker-compose.ghcr.yml | 52 ++++++++++++++++++++++++++++ docker-compose.sandbox.yml | 11 +++--- docker-compose.yml | 59 +++++++++++++++++++++++++++++++ docs/SANDBOX.md | 28 ++++++++++++--- install.sh | 18 ++++++++-- update.sh | 26 ++++++++++---- 10 files changed, 293 insertions(+), 27 deletions(-) diff --git a/.env.example b/.env.example index 1fdae676d..73f0fc8d1 100644 --- a/.env.example +++ b/.env.example @@ -17,6 +17,12 @@ POSTGRES_USER=artex # because Compose reads this file that way. POSTGRES_PASSWORD=change-me-please POSTGRES_DB=artex +# Shared secret between the panel and artex-runner for the internal execution +# API. install.sh and update.sh generate it when empty. Keep it private. +ARTEX_RUNNER_TOKEN= +# Agent execution isolation: required (default, one worker per task) or off +# (explicit degraded mode, loud warning). docker-compose.yml includes the runner. +# ARTEX_SANDBOX=required # Prebuilt GHCR image tag for docker-compose.ghcr.yml. Unset uses latest. # ARTEX_IMAGE_TAG=latest # Build identity shown in the UI and the startup banner. update.sh refreshes both diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f13e366d4..fad56da15 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,7 +82,7 @@ jobs: # ③ Collect all zips → create the GitHub Release release: - needs: binaries + needs: [binaries, sandbox-images] runs-on: ubuntu-latest permissions: contents: write # create the Release (softprops/action-gh-release) @@ -152,7 +152,68 @@ jobs: generate_release_notes: false body_path: ${{ runner.temp }}/release-body.md - # ④ Multi-arch image → push to GitHub Container Registry (and optionally Docker Hub + # ④ Sandbox images: the runner, the per-task worker and the egress proxy. + # The panel image above is useless for agent execution without them when + # ARTEX_SANDBOX=required, so they are published from the same tag. + sandbox-images: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + strategy: + matrix: + include: + - { name: runner, dockerfile: Dockerfile.runner } + - { name: worker, dockerfile: Dockerfile.worker } + - { name: egress-proxy, dockerfile: Dockerfile.egress-proxy } + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 + - uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0 + - name: Log in to GitHub Container Registry + if: github.event_name == 'push' + uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 + id: meta + with: + images: ghcr.io/baarai/artex-${{ matrix.name }} + tags: | + type=ref,event=tag + type=semver,pattern={{version}} + type=raw,value=latest + - uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2 + with: + context: . + file: ${{ matrix.dockerfile }} + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name == 'push' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + ARTEX_VERSION=${{ github.ref_name }} + ARTEX_REVISION=${{ github.sha }} + provenance: true + sbom: true + - name: Verify the image pulls anonymously + if: github.event_name == 'push' + run: | + tag="${GITHUB_REF_NAME}" + image="ghcr.io/baarai/artex-${{ matrix.name }}:${tag}" + cfg="$(mktemp -d)" + for attempt in 1 2 3; do + if DOCKER_CONFIG="$cfg" docker manifest inspect "$image" >/dev/null; then + exit 0 + fi + sleep 10 + done + echo "anonymous pull of $image is denied; set the package visibility to Public" >&2 + exit 1 + + # ⑤ Multi-arch image → push to GitHub Container Registry (and optionally Docker Hub # when DOCKERHUB_ENABLED is set to 'true' alongside DOCKERHUB_IMAGE and # DOCKERHUB_USERNAME / DOCKERHUB_TOKEN secrets). Dry runs (workflow_dispatch) # build both platforms without logging in or pushing. diff --git a/CHANGELOG.md b/CHANGELOG.md index d5fe70a05..907900e77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,28 @@ +# Changelog + +All notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). + ## [Unreleased] +## [0.7.1] - 2026-11-30 + +### Security + +- **Per-task execution sandbox is the default.** `Bash`, custom command and script tools, and stdio MCP servers run in a disposable `artex-worker` container created by `artex-runner`, never in the panel container. The worker has uid/gid 10001, a read-only rootfs, `cap-drop ALL`, no key or database mount, only its task workspace, and only an internal task network. A per-task `artex-egress-proxy` enforces a deny-by-default domain and CIDR allowlist with DNS pinning, HTTP/HTTPS CONNECT and SOCKS5, blocks IMDS, RFC1918, loopback, link-local and IPv6 unless explicitly approved, and writes its audit log outside the worker workspace. The runner and the three images are part of `docker-compose.yml`, `docker-compose.ghcr.yml`, `install.sh` and `update.sh`; the release publishes the runner, worker and egress-proxy images beside the panel. `ARTEX_SANDBOX=off` is the explicit, loud degraded mode. +- **The sandbox egress allowlist is operator-owned, not agent-writable.** Migration `0023_task_scope_operator_approval.sql` adds `task_scope.approved_by_operator`. Only operator-approved rows (Task Scope UI, operator-selected companies, operator retarget) grant egress; `add_task_scope`, `insert_assets`, agent-spawned company scope and expanded rows are coverage-only. `WebFetch` and the shared browser use the same policy. Existing `source='manual'` rows are backfilled; goal-derived (`source='agent'`) and auto (`source='auto'`) scopes must be re-approved once in Task Scope. Target-gate approval clears only the tool-call gate, and the denial message says so. +- **Startup is fail-closed and key permissions are enforced.** The isolation self-test stops the server on every platform unless `ARTEX_ALLOW_UNISOLATED=1` is explicitly set. The key directory is tightened to 0700 and existing key files to 0600 at startup, so a host bind mount cannot mask the image permissions. +- **Secret rotation is atomic.** `db.RotateSecretKey`, `artex -rotate-secrets` and `scripts/rotate-secrets.sh` re-encrypt every sealed database value and bump `auth.password_version` in one transaction before the new key is moved into place. Existing sessions are invalidated. +- **Target gate backfill and a real kill switch.** Migration `0022_target_gate_backfill.sql` enables the gate on active scoped tasks that did not opt out, with `tasks.target_gate_opt_out` for the explicit opt-out. `Engine.Pause` and `Engine.BeginDelete` set `PR_SET_CHILD_SUBREAPER` and terminate the executor UID or task descendants from `/proc`; the sandbox kill scans `/proc` for uid 10001 and never trusts agent-writable state, with a container-removal fallback. +- **Chat bridge approval buttons recheck access.** A member removed, a chat unlisted or the bridge disabled while a batch was queued can no longer spend a valid button. The handler re-reads the bridge, refuses when access or the enabled state changed, and the consume statement requires the current `config_version`. Reported privately by @jamesKhor. + ### Breaking Changes -- **Upgrade note (migration `0023_task_scope_operator_approval.sql`)**: Existing `source = 'manual'` `task_scope` rows are backfilled to `approved_by_operator = TRUE`, while goal-derived/agent (`source = 'agent'`) and auto (`source = 'auto'`) scopes remain `FALSE` and must be re-approved once via the Task Scope UI to grant sandbox egress. Target-gate approval clears only the tool gate; worker egress still requires operator-approved Task Scope. -- **Container sandbox required by default (`ARTEX_SANDBOX=required`)**: agent execution (`Bash`, custom command/script tools) now routes to disposable per-task `artex-worker` containers via `artex-runner` (`docker-compose.sandbox.yml`) with an `internal: true` per-task network and DNS-pinning HTTP/SOCKS5 egress allowlist proxy (`artex-egress-proxy`). Tasks refuse to start or pause when the runner is unavailable (no silent local fallback). Pass `ARTEX_SANDBOX=off` for explicit degraded local mode (logs a loud startup warning and records `sandbox=off` in every task event log). -# Changelog +- **`ARTEX_SANDBOX=required` by default.** If `artex-runner` is unavailable, ARTEX refuses to start tasks and pauses running tasks, with no local fallback. `ARTEX_SANDBOX=off` is the explicit degraded mode and writes `sandbox=off` into each task event log. The runner needs access to the Docker socket; `install.sh` and `update.sh` generate `ARTEX_RUNNER_TOKEN` and build the runner, worker and egress-proxy images. GHCR users pull the sandbox profile from the same release tag. +- **Existing task scopes need one re-approval.** Operator-entered `source='manual'` scopes are backfilled by migration 0023. Goal-derived and auto-discovered scopes remain coverage-only and must be re-approved once in Task Scope before sandbox egress is granted. -All notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +### Credits -## [Unreleased] +The execution-scope gap and its remediation were tracked in public before the November 2026 writeup: #421 and #423 by @youssefmedhatl, #554, #555 and #553 by @renaesop, with the two-sources-of-truth analysis by @Dukotah in #421. The chat bridge advisory was reported by @jamesKhor. The public writeup is by Kevin Joensen. Thank you. ### Added @@ -1285,7 +1299,8 @@ First release of this fork. The engine underneath is still upstream's, but this - [@Autumn-27](https://github.com/Autumn-27) - [@neouks](https://github.com/neouks) -[Unreleased]: https://github.com/BaaRai/ARTEX/compare/v0.7.0...HEAD +[Unreleased]: https://github.com/BaaRai/ARTEX/compare/v0.7.1...HEAD +[0.7.1]: https://github.com/BaaRai/ARTEX/compare/v0.7.0...v0.7.1 [0.7.0]: https://github.com/BaaRai/ARTEX/compare/v0.6.0...v0.7.0 [0.6.0]: https://github.com/BaaRai/ARTEX/compare/v0.5.1...v0.6.0 [0.5.1]: https://github.com/BaaRai/ARTEX/compare/v0.5.0...v0.5.1 diff --git a/README.md b/README.md index 4c20b3622..be0122480 100644 --- a/README.md +++ b/README.md @@ -1178,12 +1178,34 @@ using this project means you have read, understood and agreed to all of the abov > development, set `ARTEX_SANDBOX=off` (logs a loud startup banner and writes > `sandbox=off` into each task's event log). -Launch with the sandbox overlay: +The runner, worker and proxy services are part of `docker-compose.yml` and the +GHCR compose file. `install.sh` and `update.sh` generate `ARTEX_RUNNER_TOKEN` and +build the three images: ```bash -docker compose -f docker-compose.yml -f docker-compose.sandbox.yml --profile build-only build -docker compose -f docker-compose.yml -f docker-compose.sandbox.yml up -d +./install.sh # first install +./update.sh # existing checkout ``` +Manual, from a source checkout: + +```bash +# Put ARTEX_RUNNER_TOKEN=$(openssl rand -hex 32) in .env once. +docker compose build artex artex-runner +docker compose --profile build-only build artex-worker artex-egress-proxy +docker compose up -d +``` + +From the published images: + +```bash +# ARTEX_RUNNER_TOKEN must be set in .env. +docker compose -f docker-compose.ghcr.yml --profile build-only pull +docker compose -f docker-compose.ghcr.yml up -d +``` + +`docker-compose.sandbox.yml` remains as a compatibility overlay for existing +commands; it is no longer required. + See [`docs/SANDBOX.md`](docs/SANDBOX.md) for the runner API, per-task internal network, HTTP/SOCKS5 egress allowlist proxy, and security boundary. diff --git a/docker-compose.ghcr.yml b/docker-compose.ghcr.yml index 8ae32eed1..e0ecc13d3 100644 --- a/docker-compose.ghcr.yml +++ b/docker-compose.ghcr.yml @@ -37,6 +37,11 @@ services: depends_on: postgres: condition: service_healthy + artex-runner: + condition: service_healthy + networks: + - default + - runner-net environment: # Parts, not a pasted URL. PostgresDSN percent-encodes the password, so a # value with / ? % @ : or a space still connects. @@ -71,6 +76,11 @@ services: ARTEX_TASK_BUDGET_TURNS: ${ARTEX_TASK_BUDGET_TURNS:-} ARTEX_INTENT_BUDGET_TOKENS: ${ARTEX_INTENT_BUDGET_TOKENS:-} ARTEX_INTENT_BUDGET_TURNS: ${ARTEX_INTENT_BUDGET_TURNS:-} + # Agent execution runs in disposable per-task worker containers. The + # sandbox images are published beside the panel image. + ARTEX_SANDBOX: ${ARTEX_SANDBOX:-required} + ARTEX_RUNNER_URL: ${ARTEX_RUNNER_URL:-http://artex-runner:8789} + ARTEX_RUNNER_TOKEN: ${ARTEX_RUNNER_TOKEN:?Please set ARTEX_RUNNER_TOKEN in .env} ports: - "${ARTEX_BIND_ADDR:-127.0.0.1}:8787:8787" - "127.0.0.1:8788:8788" @@ -79,5 +89,47 @@ services: - ./keys:/app/keys restart: unless-stopped + artex-runner: + image: ghcr.io/baarai/artex-runner:${ARTEX_IMAGE_TAG:-latest} + networks: + - runner-net + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./data/tasks:/app/data/tasks + - ./data/egress-audit:/app/data/egress-audit + environment: + ARTEX_RUNNER_TOKEN: ${ARTEX_RUNNER_TOKEN:?Please set ARTEX_RUNNER_TOKEN in .env} + ARTEX_WORKER_IMAGE: ${ARTEX_WORKER_IMAGE:-ghcr.io/baarai/artex-worker:${ARTEX_IMAGE_TAG:-latest}} + ARTEX_EGRESS_PROXY_IMAGE: ${ARTEX_EGRESS_PROXY_IMAGE:-ghcr.io/baarai/artex-egress-proxy:${ARTEX_IMAGE_TAG:-latest}} + ARTEX_WORKSPACE_ROOT: /app/data/tasks + ARTEX_HOST_WORKSPACE_ROOT: ${ARTEX_HOST_WORKSPACE_ROOT:-./data/tasks} + ARTEX_AUDIT_ROOT: /app/data/egress-audit + ARTEX_HOST_AUDIT_ROOT: ${ARTEX_HOST_AUDIT_ROOT:-./data/egress-audit} + ARTEX_TASK_NET_PREFIX: ${ARTEX_TASK_NET_PREFIX:-artex-task-} + ARTEX_EGRESS_NET: ${ARTEX_EGRESS_NET:-egress-net} + healthcheck: + test: ["CMD-SHELL", "curl -fsS -H \"Authorization: Bearer $$ARTEX_RUNNER_TOKEN\" http://127.0.0.1:8789/v1/health"] + interval: 5s + timeout: 3s + retries: 10 + restart: unless-stopped + + # Images the runner instantiates per task. They are pulled with + # `docker compose -f docker-compose.ghcr.yml --profile build-only pull`. + artex-worker: + image: ghcr.io/baarai/artex-worker:${ARTEX_IMAGE_TAG:-latest} + profiles: ["build-only"] + + artex-egress-proxy: + image: ghcr.io/baarai/artex-egress-proxy:${ARTEX_IMAGE_TAG:-latest} + profiles: ["build-only"] + +networks: + runner-net: + internal: true + egress-net: + name: ${ARTEX_EGRESS_NET:-egress-net} + driver: bridge + volumes: pgdata: diff --git a/docker-compose.sandbox.yml b/docker-compose.sandbox.yml index 84ae90f8e..a4d4d72b4 100644 --- a/docker-compose.sandbox.yml +++ b/docker-compose.sandbox.yml @@ -1,7 +1,10 @@ -# ARTEX Sandbox MVP overlay (CONTRACT.md §§1-6). -# Usage: -# docker compose -f docker-compose.yml -f docker-compose.sandbox.yml build -# docker compose -f docker-compose.yml -f docker-compose.sandbox.yml up -d +# ARTEX sandbox compatibility overlay. +# +# Since 0.7.1 the runner, worker and egress proxy are part of +# docker-compose.yml and docker-compose.ghcr.yml, so a plain +# `docker compose up -d` runs the sandbox. This file is kept so existing +# `-f docker-compose.yml -f docker-compose.sandbox.yml` commands keep working; +# it is no longer required. # # Security boundary: # - artex (panel): holds DB credentials, keys, LLM keys; never mounts docker.sock; diff --git a/docker-compose.yml b/docker-compose.yml index e09c8425a..46f9e71f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -39,6 +39,11 @@ services: depends_on: postgres: condition: service_healthy + artex-runner: + condition: service_healthy + networks: + - default + - runner-net environment: # Parts, not a pasted URL. PostgresDSN percent-encodes the password, so a # value with / ? % @ : or a space still connects. ARTEX_PG_DSN, when set, @@ -73,6 +78,11 @@ services: ARTEX_TASK_BUDGET_TURNS: ${ARTEX_TASK_BUDGET_TURNS:-} ARTEX_INTENT_BUDGET_TOKENS: ${ARTEX_INTENT_BUDGET_TOKENS:-} ARTEX_INTENT_BUDGET_TURNS: ${ARTEX_INTENT_BUDGET_TURNS:-} + # Agent execution runs in disposable per-task worker containers. The + # runner is part of this compose file; its token must be set in .env. + ARTEX_SANDBOX: ${ARTEX_SANDBOX:-required} + ARTEX_RUNNER_URL: ${ARTEX_RUNNER_URL:-http://artex-runner:8789} + ARTEX_RUNNER_TOKEN: ${ARTEX_RUNNER_TOKEN:?Please set ARTEX_RUNNER_TOKEN in .env} ports: - "${ARTEX_BIND_ADDR:-127.0.0.1}:8787:8787" - "127.0.0.1:8788:8788" @@ -88,5 +98,54 @@ services: - ./skills:/app/skills restart: unless-stopped + artex-runner: + build: + context: . + dockerfile: Dockerfile.runner + image: artex-runner:local + networks: + - runner-net + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - ./data/tasks:/app/data/tasks + - ./data/egress-audit:/app/data/egress-audit + environment: + ARTEX_RUNNER_TOKEN: ${ARTEX_RUNNER_TOKEN:?Please set ARTEX_RUNNER_TOKEN in .env} + ARTEX_WORKER_IMAGE: ${ARTEX_WORKER_IMAGE:-artex-worker:local} + ARTEX_EGRESS_PROXY_IMAGE: ${ARTEX_EGRESS_PROXY_IMAGE:-artex-egress-proxy:local} + ARTEX_WORKSPACE_ROOT: /app/data/tasks + ARTEX_HOST_WORKSPACE_ROOT: ${ARTEX_HOST_WORKSPACE_ROOT:-./data/tasks} + ARTEX_AUDIT_ROOT: /app/data/egress-audit + ARTEX_HOST_AUDIT_ROOT: ${ARTEX_HOST_AUDIT_ROOT:-./data/egress-audit} + ARTEX_TASK_NET_PREFIX: ${ARTEX_TASK_NET_PREFIX:-artex-task-} + ARTEX_EGRESS_NET: ${ARTEX_EGRESS_NET:-egress-net} + healthcheck: + test: ["CMD-SHELL", "curl -fsS -H \"Authorization: Bearer $$ARTEX_RUNNER_TOKEN\" http://127.0.0.1:8789/v1/health"] + interval: 5s + timeout: 3s + retries: 10 + restart: unless-stopped + + artex-worker: + build: + context: . + dockerfile: Dockerfile.worker + image: artex-worker:local + profiles: ["build-only"] + + artex-egress-proxy: + build: + context: . + dockerfile: Dockerfile.egress-proxy + image: artex-egress-proxy:local + profiles: ["build-only"] + +networks: + runner-net: + internal: true + egress-net: + name: ${ARTEX_EGRESS_NET:-egress-net} + driver: bridge + volumes: pgdata: diff --git a/docs/SANDBOX.md b/docs/SANDBOX.md index b13208619..6afe9f63c 100644 --- a/docs/SANDBOX.md +++ b/docs/SANDBOX.md @@ -28,13 +28,33 @@ from disposable per-task **worker** containers (`artex-worker:local`). ## Running with the sandbox +The runner, worker and proxy are part of `docker-compose.yml` and +`docker-compose.ghcr.yml`. `install.sh` and `update.sh` generate +`ARTEX_RUNNER_TOKEN` and build the three images: + +```bash +./install.sh # first install +./update.sh # existing checkout +``` + +Manual, from a source checkout (put `ARTEX_RUNNER_TOKEN` in `.env` once): + ```bash -export ARTEX_RUNNER_TOKEN="$(openssl rand -hex 32)" -docker compose -f docker-compose.yml -f docker-compose.sandbox.yml --profile build-only build -docker compose -f docker-compose.yml -f docker-compose.sandbox.yml build -docker compose -f docker-compose.yml -f docker-compose.sandbox.yml up -d +docker compose build artex artex-runner +docker compose --profile build-only build artex-worker artex-egress-proxy +docker compose up -d ``` +From the published images: + +```bash +docker compose -f docker-compose.ghcr.yml --profile build-only pull +docker compose -f docker-compose.ghcr.yml up -d +``` + +`docker-compose.sandbox.yml` is kept as a compatibility overlay; it is no longer +required. + ## Breaking change: `ARTEX_SANDBOX=required` by default Starting with this release, `ARTEX_SANDBOX` defaults to **`required`**. If diff --git a/install.sh b/install.sh index 505cd9469..02ef7fd43 100755 --- a/install.sh +++ b/install.sh @@ -43,6 +43,16 @@ stamp_version(){ fi ok "Build identity: ${BUILD_VERSION}${BUILD_REVISION:+ (${BUILD_REVISION:0:12})}" } +# ensure_runner_token fills ARTEX_RUNNER_TOKEN in .env once. The panel and the +# runner authenticate the internal execution API with it; an empty value makes +# the panel fail closed, so the token is generated with the rest of the setup. +ensure_runner_token(){ + [ -f .env ] || return 0 + grep -q '^ARTEX_RUNNER_TOKEN=.' .env && return 0 + set_env ARTEX_RUNNER_TOKEN "$(rand)" + ok "ARTEX_RUNNER_TOKEN generated" +} + # json_str prints $1 as a JSON string literal: backslash, double quote and the # control characters read -r can return are escaped. json_str(){ @@ -156,8 +166,12 @@ install_docker(){ info "reusing existing .env" fi stamp_version - info "building the image from this checkout and starting..." - docker compose up -d --build + ensure_runner_token + info "building the panel and the sandbox images from this checkout..." + docker compose build artex artex-runner + docker compose --profile build-only build artex-worker artex-egress-proxy + info "starting..." + docker compose up -d ok "started → http://localhost:8787" info "view logs: docker compose logs -f artex" } diff --git a/update.sh b/update.sh index f0c860830..d3bcd23d2 100755 --- a/update.sh +++ b/update.sh @@ -11,6 +11,7 @@ ok(){ printf '\033[32m[+]\033[0m %s\n' "$*"; } warn(){ printf '\033[33m[!]\033[0m %s\n' "$*"; } die(){ printf '\033[31m[x]\033[0m %s\n' "$*" >&2; exit 1; } ask(){ local p="$1" d="${2:-}" a; read -rp "$p${d:+ [$d]}: " a; echo "${a:-$d}"; } +rand(){ head -c 18 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' | head -c 24; } # ── Build identity: keep .env and the binary in step with the checkout ───────── BUILD_VERSION="dev" @@ -46,6 +47,16 @@ stamp_version(){ ok "Build identity: ${BUILD_VERSION}${BUILD_REVISION:+ (${BUILD_REVISION:0:12})}" } +# ensure_runner_token fills ARTEX_RUNNER_TOKEN in .env once. The panel and the +# runner authenticate the internal execution API with it; an empty value makes +# the panel fail closed, so an existing .env gets one before the upgrade. +ensure_runner_token(){ + [ -f .env ] || return 0 + grep -q '^ARTEX_RUNNER_TOKEN=.' .env && return 0 + set_env ARTEX_RUNNER_TOKEN "$(rand)" + ok "ARTEX_RUNNER_TOKEN generated" +} + # ── Optional: sync the repo to the latest code (compose/scripts/local build sources all update through it) ─────── sync_repo(){ [ -d .git ] && command -v git >/dev/null 2>&1 || { warn "not a git working copy, skipping git pull"; return 0; } @@ -73,12 +84,15 @@ update_docker(){ || die "docker buildx not detected; the image build needs it (see the Docker section of the README)" [ -f .env ] || die ".env not found; run ./install.sh first to complete the initial deployment" - # Touch only artex: postgres is pinned to 16-alpine and does not need upgrading along - # (pulling it wastes bandwidth, and a major version bump risks compatibility). artex - # declares depends_on postgres, so an up with the service name starts pg if needed and leaves a running one untouched. - info "Building the image from this checkout (artex only)…" - docker compose build artex - info "Recreating artex (schema migrates automatically on restart)…" + ensure_runner_token + # Touch only artex and artex-runner: postgres is pinned to 16-alpine and does not + # need upgrading along (pulling it wastes bandwidth, and a major version bump + # risks compatibility). The worker and proxy images are built locally because the + # runner creates one container of each per task. + info "Building the panel and the sandbox images from this checkout…" + docker compose build artex artex-runner + docker compose --profile build-only build artex-worker artex-egress-proxy + info "Recreating artex and artex-runner (schema migrates automatically on restart)…" docker compose up -d artex ok "Update complete → http://localhost:8787" info "View logs: docker compose logs -f artex" From b9f90d92162b3d87327dc5608d6fcdbd967c7bed Mon Sep 17 00:00:00 2001 From: BaaRai <130491490+BaaRai@users.noreply.github.com> Date: Mon, 30 Nov 2026 19:48:11 +0100 Subject: [PATCH 2/2] test(ghidra): set the runner token in the compose fixture The default compose now requires ARTEX_RUNNER_TOKEN for the panel, so the ghidra overlay config test must provide it like the sandbox compose test already does. --- ghidra/compose_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghidra/compose_test.go b/ghidra/compose_test.go index d25560a4f..76c99d95e 100644 --- a/ghidra/compose_test.go +++ b/ghidra/compose_test.go @@ -49,7 +49,7 @@ func TestComposeOverlayConfigHasInternalNetworkAndHardening(t *testing.T) { t.Skip("docker CLI not available; static overlay assertions passed") } cmd := exec.Command("docker", "compose", "-f", baseFile, "-f", overlayFile, "config", "--format", "json") - cmd.Env = append(os.Environ(), "POSTGRES_PASSWORD=test") + cmd.Env = append(os.Environ(), "POSTGRES_PASSWORD=test", "ARTEX_RUNNER_TOKEN=testtoken") out, err := cmd.CombinedOutput() if err != nil { t.Fatalf("docker compose config failed: %v\n%s", err, out)