From 35443987763d5b65ddd6a3797dcdfab5240ac1b4 Mon Sep 17 00:00:00 2001 From: johannayang-amd Date: Thu, 19 Nov 2026 21:45:51 +0100 Subject: [PATCH 1/2] docs(agents): add .agents/skills with an axis-e2e skill Agents testing AXIS on a real host kept rediscovering the same traps: MXC refusing helpers in a group-writable directory, an lxc-exec built at the wrong MXC revision, a shared target directory silently reusing one build, Ctrl-C sent as a signal instead of typed, and timeout(1) failing inside the sandbox. The code and docs do not say any of this. Add .agents/skills/, linked from .claude/skills for Claude Code, with an axis-e2e skill that records these findings and links to the existing docs for the rest. Its scripts record the host (preflight.sh), build revisions side by side with their pinned lxc-exec (build.sh), and run a terminal program in a PTY, type Ctrl-C and report whether it came up, exited and left processes behind (run-tui.sh). AGENTS.md gets a Skills section with the rules for keeping skills short and current, and DEVELOPMENT.md points to the skill. --- .agents/skills/axis-e2e/SKILL.md | 67 +++++++++ .agents/skills/axis-e2e/scripts/build.sh | 139 +++++++++++++++++++ .agents/skills/axis-e2e/scripts/preflight.sh | 75 ++++++++++ .agents/skills/axis-e2e/scripts/run-tui.sh | 130 +++++++++++++++++ .claude/skills | 1 + .gitignore | 3 +- AGENTS.md | 17 ++- DEVELOPMENT.md | 5 + 8 files changed, 435 insertions(+), 2 deletions(-) create mode 100644 .agents/skills/axis-e2e/SKILL.md create mode 100755 .agents/skills/axis-e2e/scripts/build.sh create mode 100755 .agents/skills/axis-e2e/scripts/preflight.sh create mode 100755 .agents/skills/axis-e2e/scripts/run-tui.sh create mode 120000 .claude/skills diff --git a/.agents/skills/axis-e2e/SKILL.md b/.agents/skills/axis-e2e/SKILL.md new file mode 100644 index 00000000..2f5330cb --- /dev/null +++ b/.agents/skills/axis-e2e/SKILL.md @@ -0,0 +1,67 @@ +--- +name: axis-e2e +description: Run AXIS on a real Linux host to verify a change end to end - gated real-runtime tests, MXC and native launches, an agent or TUI inside the sandbox, or main against a pull request in the same harness - and report the result. Use when a change touches launch, seccomp, Landlock, MXC, the proxy or policy translation and unit tests are not enough, or when reproducing a runtime issue. Not for the local checks in DEVELOPMENT.md, or for benchmark numbers (docs/runtime-performance-benchmarks.md). +--- + +# AXIS end to end on a real host + +Read these first; they are the source of truth and this skill does not repeat them: + +- [docs/security-test-tiers.md](../../../docs/security-test-tiers.md): gated tests, their environment variables, skip rules. +- [docs/linux-setup.md](../../../docs/linux-setup.md): what each backend and network mode needs from the host, and how `auto` picks a backend. +- [docs/runtime-performance-benchmarks.md](../../../docs/runtime-performance-benchmarks.md): numbers for launch-path and proxy changes. + +## Scripts + +`scripts/` has helpers for the steps below; each prints its usage with `-h`. Run them from an AXIS checkout and keep their output for the report. + +- `preflight.sh --require mxc,strace,tty --out host.txt`: records the host and fails when a requirement is missing. +- `build.sh WORK base=origin/main pr=pr-123@origin/main`: builds each revision in its own worktree and target directory, with the `lxc-exec` its `ci.yml` pins, into `WORK/bin/NAME`. It checks the paths AXIS will accept and refuses identical binaries from different commits. `build.sh --clean WORK` removes everything it created. +- `run-tui.sh --axis WORK/bin/pr/axis --policy p.yaml --out runs/pr-1 --expect TEXT -- PROGRAM`: runs a terminal program in a PTY with a fresh home, types Ctrl-C, and writes `result.txt` (came up, exited, leftovers). A leftover is a process that names the run directory or PROGRAM and did not exist before the run; the script lists and stops it, and leaves your other processes alone. `--axis none` runs it without AXIS, which is how to pick `--expect`. `--strace` adds `denied.txt`. + +Alternate the builds over several runs, for example `for i in 1 2 3; do for b in base pr; do run-tui.sh --axis WORK/bin/$b/axis --out runs/$b-$i ...; done; done`. + +## Build what you test + +- Build the helpers too: `cargo build --release --locked -p axis-cli -p axis-sandbox --bins`. Without `-p axis-sandbox --bins` there is no `axis-seccomp-launcher`, and MXC refuses to start. +- MXC needs `lxc-exec` built at the `MXC_REF` pinned in `.github/workflows/ci.yml`. Another revision fails with "Config schema version ... is newer than supported". +- When you compare builds (main against a pull request, or variants), give each source tree its own `CARGO_TARGET_DIR` and check that the binaries differ (`md5sum */axis`). Trees unpacked with `git archive` carry commit-time mtimes, so a shared target directory silently reuses the first build. + +## Where the binaries live + +AXIS looks for `axis-seccomp-launcher` and `lxc-exec` beside `axis`, then in its install directories, then in absolute `PATH` entries. It skips a candidate unless every path component is owned by root or the effective user, is not a symlink, and is not group- or world-writable. The error only says "no safe ... found", so check the components first (`namei -l`): + +- Not under `/tmp`, and not in a directory created under `umask 002`: `chmod -R go-w` the bin directory. +- A root caller needs root-owned directories, for example a new directory under `/opt`, not a user's home. + +## Choose the backend and network mode on purpose + +- The bundled agent policies use `network.mode: proxy`, and `auto` runs strict proxy on the native backend. To test MXC, copy the policy and set `runtime.provider: mxc`; confirm the backend in the log or the process tree (`lxc-exec`, `bwrap`). +- MXC proxy needs unprivileged user and network namespaces; native proxy needs `CAP_NET_ADMIN` or the netns helper. +- MXC `block` mode denies every socket domain except `AF_UNIX`, so a program that serves on TCP loopback (agent TUIs often start a local server) fails there for that reason alone. Use `allow` for those and say which mode you tested. + +## Running + +- Give each run its own fake `HOME` and a short workspace path. Never point a test at a real `~/.config`, `~/.ssh` or agent state. The PTY bridge socket lives under the workspace and its path must stay under 108 bytes. +- Run with a clean environment (`env -i PATH=/usr/bin:/bin HOME=...`), as CI does. Extra tools on `PATH`, such as another `python3`, change results. +- `axis run` first tries axisd at `$XDG_RUNTIME_DIR/axis/axisd.sock` or `/tmp/axis-axisd.sock`, which on a shared host can be someone else's. Pass `--socket` with a path that does not exist to keep the run standalone. +- Interactive programs need a terminal: `script -qfec "" /dev/null`, or tmux. Ctrl-C reaches the program only as the byte `0x03` through the PTY bridge, so type it (`printf '\003'` into the script's stdin, or `tmux send-keys C-c`); a signal sent to `script` is not what a user does. To stop a stuck run, send SIGTERM to `axis`, which tears the sandbox down. +- Do not wrap the command inside the sandbox with `timeout`: seccomp denies `timer_create`. Put `timeout` outside `axis run`. +- To see what seccomp denies: `strace -f -qq --status=failed -o trace.log axis run ...` and count `= -1 EPERM` by syscall. `prctl(PR_CAPBSET_DROP)` and `setsockopt(SO_*BUFFORCE)` failures come from Bubblewrap and MXC setup, not from the payload. Judge behavior only from runs without strace. +- To find which allowed syscall matters, add it to `process.blocked_syscalls` in a copy of the policy and rerun; no rebuild needed. A name AXIS does not know fails the launch. +- Run MXC as a non-root user. As root, Bubblewrap failed to set up its uid map on a host where the same non-root user could run it. + +## Shared hosts + +Work in a private directory (`chmod 700`), do not use sudo unless the person you work for agreed, do not touch other users' processes or sockets, and remove what you created, including stray clones and network namespaces. + +## Report + +| Item | Detail | +|---|---| +| Commits | Head SHA, the `main` it was tested on, and any local merge or patch | +| Host | Distribution, kernel, caller (root or not), backend, network mode | +| Commands | The exact commands, or the script that ran them | +| Results | Pass, fail and ignored counts; for a launch, what the program showed, over several alternating runs | +| Comparison | The same harness on `main`, when the claim is "fixed" or "no change" | +| Not run | Each skipped case and why. A skip is not a pass. | diff --git a/.agents/skills/axis-e2e/scripts/build.sh b/.agents/skills/axis-e2e/scripts/build.sh new file mode 100755 index 00000000..869b9400 --- /dev/null +++ b/.agents/skills/axis-e2e/scripts/build.sh @@ -0,0 +1,139 @@ +#!/usr/bin/env bash +# Copyright 2026 Advanced Micro Devices, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# Build AXIS revisions side by side for end-to-end runs, each with the +# lxc-exec its ci.yml pins, into bin directories AXIS accepts. +# +# build.sh WORK NAME=REF[@BASE] [NAME=REF[@BASE] ...] +# build.sh --clean WORK +# +# Run it inside an AXIS checkout. REF is anything `git rev-parse` accepts; +# fetch a pull request first (git fetch origin pull/N/head:pr-N). +# NAME=REF@BASE builds REF merged onto BASE, for testing a PR on current main. +# Binaries land in WORK/bin/NAME with a BUILD_INFO file. +# MXC_SRC= avoids a fresh clone; NO_MXC=1 skips lxc-exec. + +set -euo pipefail + +die() { echo "build: $*" >&2; exit 1; } +repo=$(git rev-parse --show-toplevel 2>/dev/null) || die "run inside an AXIS git checkout" + +if [ "${1:-}" = "--clean" ]; then + work=${2:?usage: build.sh --clean WORK} + for src in "$work"/src/*/; do + [ -d "$src" ] && git -C "$repo" worktree remove --force "$src" 2>/dev/null || true + done + git -C "$repo" worktree prune + rm -rf "$work" + echo "removed $work" + exit 0 +fi + +[ $# -ge 2 ] || { sed -n '5,16p' "$0" >&2; exit 2; } +work=$(realpath -m "$1"); shift +for spec in "$@"; do + case "$spec" in ?*=?*) ;; *) die "expected NAME=REF[@BASE], got '$spec'" ;; esac +done +umask 022 +mkdir -p "$work"/{src,target,bin,mxc} +chmod 700 "$work" + +ci_value() { sed -n "s/^ $1: \(.*\)\$/\1/p" "$2/.github/workflows/ci.yml" | head -1; } + +build_lxc_exec() { # MXC_REF MXC_REPOSITORY -> path + local ref=$1 url=$2 dir=$work/mxc/$1 + if [ ! -x "$dir/lxc-exec" ]; then + local src=$dir/src + if [ -n "${MXC_SRC:-}" ]; then + git -C "$MXC_SRC" worktree add --detach "$src" "$ref" >&2 + else + git clone -q --filter=blob:none "$url" "$src" >&2 + git -C "$src" checkout -q "$ref" + fi + cargo build --release --locked --manifest-path "$src/src/Cargo.toml" -p lxc --no-default-features >&2 + install -m 755 "$src/src/target/release/lxc-exec" "$dir/lxc-exec" + fi + echo "$dir/lxc-exec" +} + +# Mirrors validate_safe_executable_path in crates/axis-sandbox/src/linux/mxc.rs; +# keep the two in step. +check_safe_path() { # path: every component owned by root or us, no symlink, not group/world-writable + local path=$1 current="" part + IFS=/ read -ra parts <<< "${path#/}" + for part in "${parts[@]}"; do + current="$current/$part" + [ -L "$current" ] && die "$current is a symlink; AXIS will not use helpers under it" + read -r uid mode <<< "$(stat -c '%u %a' "$current")" + if [ "$uid" != 0 ] && [ "$uid" != "$(id -u)" ]; then + die "$current is owned by uid $uid; AXIS needs root or the effective user" + fi + if (( 8#$mode & 8#022 )); then + die "$current is group- or world-writable (mode $mode); AXIS will not use helpers under it" + fi + done +} + +declare -a names=() +for spec in "$@"; do + name=${spec%%=*}; refs=${spec#*=} + [ "$name" != "$spec" ] && [ -n "$name" ] || die "expected NAME=REF[@BASE], got '$spec'" + ref=${refs%%@*}; base=""; [ "$refs" != "$ref" ] && base=${refs#*@} + src=$work/src/$name; bin=$work/bin/$name + [ -e "$src" ] && die "$src exists; use another NAME or build.sh --clean" + + head=$(git -C "$repo" rev-parse --verify "$ref^{commit}") || die "unknown ref '$ref'" + if [ -n "$base" ]; then + basec=$(git -C "$repo" rev-parse --verify "$base^{commit}") || die "unknown ref '$base'" + git -C "$repo" worktree add -q --detach "$src" "$basec" + git -C "$src" -c user.name=axis-e2e -c user.email=axis-e2e@invalid merge -q --no-edit --no-ff "$head" \ + || { git -C "$src" merge --abort; die "$ref does not merge cleanly onto $base"; } + else + git -C "$repo" worktree add -q --detach "$src" "$head" + fi + commit=$(git -C "$src" rev-parse HEAD) + + echo "== $name: building $commit" >&2 + (cd "$src" && CARGO_TARGET_DIR=$work/target/$name cargo build --release --locked -p axis-cli -p axis-sandbox --bins >&2) + + install -d -m 755 "$bin" + for f in axis axis-seccomp-launcher axis-netns-helper; do + if [ -x "$work/target/$name/release/$f" ]; then + install -m 755 "$work/target/$name/release/$f" "$bin/$f" + fi + done + [ -x "$bin/axis-seccomp-launcher" ] || die "$name: axis-seccomp-launcher was not built" + + mxc_ref=$(ci_value MXC_REF "$src") + if [ -z "${NO_MXC:-}" ]; then + [ -n "$mxc_ref" ] || die "$name: no MXC_REF in .github/workflows/ci.yml" + install -m 755 "$(build_lxc_exec "$mxc_ref" "$(ci_value MXC_REPOSITORY "$src")")" "$bin/lxc-exec" + fi + + { + echo "name=$name" + echo "ref=$ref" + echo "base=${base:-none}" + echo "head_commit=$head" + echo "built_commit=$commit" + echo "mxc_ref=${mxc_ref:-none}" + echo "rustc=$(cd "$src" && rustc --version)" + (cd "$bin" && sha256sum ./*) + } > "$bin/BUILD_INFO" + names+=("$name") +done + +check_safe_path "$work/bin" +for name in "${names[@]}"; do check_safe_path "$work/bin/$name"; done + +declare -A by_hash=() +for name in "${names[@]}"; do + commit=$(sed -n 's/^built_commit=//p' "$work/bin/$name/BUILD_INFO") + hash=$(sha256sum "$work/bin/$name/axis" | cut -d' ' -f1) + if [ -n "${by_hash[$hash]:-}" ] && [ "${by_hash[$hash]%%:*}" != "$commit" ]; then + die "$name and ${by_hash[$hash]#*:} have the same axis binary from different commits; a build was reused" + fi + by_hash[$hash]="$commit:$name" + printf '%-16s %s axis %s\n' "$name" "${commit:0:12}" "${hash:0:12}" +done diff --git a/.agents/skills/axis-e2e/scripts/preflight.sh b/.agents/skills/axis-e2e/scripts/preflight.sh new file mode 100755 index 00000000..9b6f0188 --- /dev/null +++ b/.agents/skills/axis-e2e/scripts/preflight.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash +# Copyright 2026 Advanced Micro Devices, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# Record what this host offers AXIS end-to-end runs, and fail when a +# requirement given with --require is missing. +# +# preflight.sh [--require mxc,strace,tty] [--out FILE] + +set -uo pipefail + +require="" +out="" +while [ $# -gt 0 ]; do + case "$1" in + --require) require="$2"; shift 2 ;; + --out) out="$2"; shift 2 ;; + -h|--help) sed -n '5,9p' "$0"; exit 0 ;; + *) echo "preflight: unknown argument: $1" >&2; exit 2 ;; + esac +done + +report="" +missing=() +record() { report+="$1=$2"$'\n'; } +need() { case ",$require," in *",$1,"*) missing+=("$1: $2") ;; esac; } +tool() { PATH="$PATH:/usr/sbin:/usr/bin:/sbin:/bin" command -v "$1" 2>/dev/null || true; } + +record date "$(date -u +%Y-%m-%dT%H:%M:%SZ)" +record kernel "$(uname -r)" +record distro "$(sed -n 's/^PRETTY_NAME="\{0,1\}\([^"]*\)"\{0,1\}$/\1/p' /etc/os-release 2>/dev/null)" +record arch "$(uname -m)" +record uid "$(id -u)" +record lsm "$(cat /sys/kernel/security/lsm 2>/dev/null || echo unreadable)" +record apparmor_restrict_unprivileged_userns "$(cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns 2>/dev/null || echo absent)" +record ptrace_scope "$(cat /proc/sys/kernel/yama/ptrace_scope 2>/dev/null || echo absent)" +record rustc "$(rustc --version 2>/dev/null || echo missing)" + +for t in git cargo bwrap slirp4netns unshare nsenter iptables ip6tables iptables-restore ip6tables-restore script strace; do + record "tool_$t" "$(tool "$t")" +done + +if [ -n "$(tool bwrap)" ] && bwrap --unshare-user --uid 0 --gid 0 --ro-bind / / -- true 2>/dev/null; then + record bwrap_userns ok +else + record bwrap_userns failed + need mxc "bwrap cannot create a user namespace (see apparmor_restrict_unprivileged_userns)" +fi +for t in bwrap slirp4netns unshare nsenter iptables; do + [ -n "$(tool "$t")" ] || need mxc "$t is not installed" +done +[ -c /dev/net/tun ] || need mxc "/dev/net/tun is missing" + +if [ -n "$(tool strace)" ]; then + if strace --status=failed -qq -o /dev/null true 2>/dev/null; then record strace_status_filter ok; else record strace_status_filter unsupported; fi + case "$(cat /proc/sys/kernel/yama/ptrace_scope 2>/dev/null || echo 0)" in + 0|1) ;; + *) need strace "kernel.yama.ptrace_scope does not allow tracing" ;; + esac +else + need strace "strace is not installed" +fi +[ -n "$(tool script)" ] || need tty "script (util-linux) is not installed" + +if [ "$(id -u)" = 0 ]; then + record note "running as root; MXC runs should use a non-root user" +fi + +printf '%s' "$report" +[ -n "$out" ] && printf '%s' "$report" > "$out" + +if [ ${#missing[@]} -gt 0 ]; then + printf 'preflight: missing %s\n' "${missing[@]}" >&2 + exit 1 +fi diff --git a/.agents/skills/axis-e2e/scripts/run-tui.sh b/.agents/skills/axis-e2e/scripts/run-tui.sh new file mode 100755 index 00000000..8574d1e5 --- /dev/null +++ b/.agents/skills/axis-e2e/scripts/run-tui.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env bash +# Copyright 2026 Advanced Micro Devices, Inc. +# SPDX-License-Identifier: Apache-2.0 + +# Run a terminal program under `axis run` in a PTY, type Ctrl-C as a user +# would, and record whether it came up, whether it exited, and what it left. +# +# run-tui.sh --axis BIN|none --policy FILE --out DIR --expect TEXT +# [--home-template DIR] [--ctrl-c-after S] [--second-ctrl-c S] +# [--max S] [--strace] -- PROGRAM [ARGS...] +# +# --axis none runs PROGRAM without AXIS, to see what it shows when it works. +# --expect is text PROGRAM prints once it is up. Ctrl-C (0x03) is typed after +# --ctrl-c-after seconds (default 20, 0 for never) and again --second-ctrl-c +# seconds later (default 2). The run is stopped after --max seconds (default 60). +# DIR must not exist; it gets home/, ws/, tty.log and result.txt. + +set -euo pipefail + +die() { echo "run-tui: $*" >&2; exit 2; } +now() { date +%s.%N; } +since() { awk -v a="$1" -v b="$2" 'BEGIN { printf "%.1f", b - a }'; } + +axis="" policy="" out="" expect="" template="" use_strace="" +ctrl_after=20 second_after=2 max=60 +while [ $# -gt 0 ]; do + case "$1" in + --axis) axis="$2"; shift 2 ;; + --policy) policy="$2"; shift 2 ;; + --out) out="$2"; shift 2 ;; + --expect) expect="$2"; shift 2 ;; + --home-template) template="$2"; shift 2 ;; + --ctrl-c-after) ctrl_after="$2"; shift 2 ;; + --second-ctrl-c) second_after="$2"; shift 2 ;; + --max) max="$2"; shift 2 ;; + --strace) use_strace=1; shift ;; + -h|--help) sed -n '5,16p' "$0"; exit 0 ;; + --) shift; break ;; + *) die "unknown argument: $1" ;; + esac +done +[ $# -gt 0 ] || die "missing PROGRAM after --" +[ -n "$axis" ] && [ -n "$out" ] && [ -n "$expect" ] || die "--axis, --out and --expect are required" +[ "$axis" = none ] || { [ -n "$policy" ] || die "--policy is required with an AXIS binary"; axis=$(realpath "$axis"); policy=$(realpath "$policy"); } +[ ! -e "$out" ] || die "$out exists" + +out=$(realpath -m "$out") +home=$out/home ws=$out/ws +# The PTY bridge socket is /.axis-pty//stdio.sock and must stay under 108 bytes. +[ $(( ${#ws} + 58 )) -lt 108 ] || die "workspace path $ws is too long for the PTY socket; use a shorter --out" +mkdir -p "$home" "$ws" +[ -z "$template" ] || cp -a "$template/." "$home/" + +run=() +[ -z "$use_strace" ] || run+=(strace -f -qq --status=failed -o "$out/strace.log") +if [ "$axis" != none ]; then + # A path that does not exist keeps `axis run` standalone instead of reaching another user's axisd. + run+=("$axis" --socket "$out/no-axisd.sock" run --policy "$policy" --) +fi +run+=("$@") +inner="cd $(printf %q "$ws") && exec env -i PATH=/usr/bin:/bin HOME=$(printf %q "$home") TERM=xterm-256color LANG=C.UTF-8 $(printf '%q ' "${run[@]}")" + +# Leftovers are processes that name this run's directory or PROGRAM and did not exist before it. +regex() { printf '%s' "$1" | sed 's/[][\.*^$+?(){}|]/\\&/g'; } +match="$(regex "$out")|$(regex "$1")" +candidates() { pgrep -u "$(id -u)" -af -- "$match" | grep -v -e run-tui -e pgrep | cut -d' ' -f1 || true; } +mapfile -t before < <(candidates) + +mkfifo "$out/stdin" +start=$(now) +timeout -k 5 "$max" script -qfec "$inner" /dev/null < "$out/stdin" > "$out/tty.log" 2>&1 & +pid=$! +exec 3> "$out/stdin" + +up_at="" ctrl_at="" second_at="" +while kill -0 "$pid" 2>/dev/null; do + t=$(now) + if [ -z "$up_at" ] && sed 's/\x1b\[[0-9;?]*[ -\/]*[@-~]//g' "$out/tty.log" | grep -qF -- "$expect"; then + up_at=$t + fi + if [ "$ctrl_after" != 0 ] && [ -z "$ctrl_at" ] && [ "$(since "$start" "$t" | cut -d. -f1)" -ge "$ctrl_after" ]; then + printf '\003' >&3; ctrl_at=$t + elif [ -n "$ctrl_at" ] && [ -z "$second_at" ] && [ "$(since "$ctrl_at" "$t" | cut -d. -f1)" -ge "$second_after" ]; then + printf '\003' >&3 2>/dev/null || true; second_at=$t + fi + sleep 0.2 +done +end=$(now) +rc=0; wait "$pid" || rc=$? +exec 3>&- +if [ -z "$up_at" ] && sed 's/\x1b\[[0-9;?]*[ -\/]*[@-~]//g' "$out/tty.log" | grep -qF -- "$expect"; then up_at=$end; fi + +sleep 2 +leftover=() +while read -r p; do + [ "$p" = $$ ] && continue + case " ${before[*]} " in *" $p "*) continue ;; esac + leftover+=("$p") +done < <(candidates) +leftover_count=${#leftover[@]} +if [ "$leftover_count" -gt 0 ]; then + ps -o pid=,args= -p "$(IFS=,; echo "${leftover[*]}")" > "$out/leftovers.txt" || true + kill -TERM "${leftover[@]}" 2>/dev/null || true; sleep 2; kill -KILL "${leftover[@]}" 2>/dev/null || true +fi +pty_left=no; [ -e "$ws/.axis-pty" ] && [ -n "$(ls -A "$ws/.axis-pty" 2>/dev/null)" ] && pty_left=yes + +# timeout(1) exits 124 when it had to stop the run, 137 when it had to kill it. +stopped=no; case "$rc" in 124|137) stopped=yes ;; esac +{ + echo "program=$*" + echo "axis=$axis" + echo "policy=${policy:-none}" + echo "up=$([ -n "$up_at" ] && echo yes || echo no)" + echo "up_after_s=$([ -n "$up_at" ] && since "$start" "$up_at" || echo -)" + echo "ctrl_c_after_s=$([ -n "$ctrl_at" ] && since "$start" "$ctrl_at" || echo -)" + echo "second_ctrl_c=$([ -n "$second_at" ] && echo yes || echo no)" + echo "stopped_by_timeout=$stopped" + echo "exit_code=$rc" + echo "exit_after_ctrl_c_s=$([ -n "$ctrl_at" ] && [ "$stopped" = no ] && since "$ctrl_at" "$end" || echo -)" + echo "leftover_processes=$leftover_count" + echo "leftover_pty_socket=$pty_left" +} > "$out/result.txt" + +if [ -n "$use_strace" ] && [ -f "$out/strace.log" ]; then + # Bubblewrap and MXC setup fail these on purpose; they are not the payload's. + grep -E '= -1 EPERM' "$out/strace.log" | grep -vE 'PR_CAPBSET_DROP|SO_(SND|RCV)BUFFORCE' \ + | sed -E 's/^[0-9]+ +(<\.\.\. )?([a-z0-9_]+).*/\2/' | sort | uniq -c | sort -rn > "$out/denied.txt" || true +fi + +sed 's/^/ /' "$out/result.txt" diff --git a/.claude/skills b/.claude/skills new file mode 120000 index 00000000..2b7a412b --- /dev/null +++ b/.claude/skills @@ -0,0 +1 @@ +../.agents/skills \ No newline at end of file diff --git a/.gitignore b/.gitignore index df8b203c..eea62cae 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,8 @@ __pycache__/ *.py[cod] .idea/ .vscode/ -.claude/ +.claude/* +!.claude/skills .codex/ .cursor/ gui/macos/.build/ diff --git a/AGENTS.md b/AGENTS.md index d9a8be5d..417a5689 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,6 +44,7 @@ To iterate on one crate: `cargo test --locked -p axis-core capability`. | `docs/axis-isolation-contract.md` | What every policy field must mean on every backend | | `docs/security-test-tiers.md` | Test tiers and when a test may skip | | `scripts/` | Release tooling and its tests | +| `.agents/skills/` | Skills for agents working on this repository (see [Skills](#skills)) | ## Fail closed @@ -88,13 +89,27 @@ design document in `docs/` (see DEVELOPMENT.md). - A skipped test is not a passing test. Tier 2–4 tests skip on hosts without the runtime, kernel feature, or privilege they need; real-runtime tests are named `gated_*`. A PR in these areas includes a run on a capable host in its - Test Result ([Security Test Tiers](docs/security-test-tiers.md)). + Test Result ([Security Test Tiers](docs/security-test-tiers.md)); the + `axis-e2e` skill covers how to run one. - A PR that changes a backend default, the launch path, or the proxy includes runtime benchmark numbers ([Runtime Performance Benchmarks](docs/runtime-performance-benchmarks.md)). - Do not weaken an assertion, delete a test, or add `#[ignore]` to get CI green. Fix the code, or stop and explain the failure. +## Skills + +`.agents/skills/` holds skills for working on AXIS: `axis-e2e` (running AXIS on +a real host and reporting the result). Cursor loads them from there, and +`.claude/skills` links to the same folder for Claude Code. On Windows, git +checks the link out as a plain file unless `core.symlinks` is on. + +- A skill records what the code and docs do not show, such as what only a run + on a real host reveals. Link to `docs/` for the rest instead of copying it. +- When a change alters what a skill describes (a command, a flag, a path, a + default), update the skill in the same PR. +- This repository is public: no host names, accounts, or internal details. + ## Code conventions - New source files start with the SPDX header from DEVELOPMENT.md, in the diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 6a03de0c..34a040d4 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -243,6 +243,11 @@ bash scripts/test_security_tier0.sh Report any check you could not run, and read the skip count: a skip is not a pass. +To run AXIS on a real host beyond these checks, for example an agent or a +terminal program inside the sandbox, or `main` against a pull request in the +same harness, see [.agents/skills/axis-e2e](.agents/skills/axis-e2e/SKILL.md) +and its scripts. + ## CI/CD ### PR CI (triggered on every PR to `main`) From 91de838cc16fe36351003ad9cc555f1447274137 Mon Sep 17 00:00:00 2001 From: johannayang-amd Date: Fri, 20 Nov 2026 13:38:36 +0100 Subject: [PATCH 2/2] docs(agents): check all MXC private-network tools in preflight preflight.sh --require mxc checked only four of the seven tools MXC runs for private networking, so a host missing ip6tables, iptables-restore or ip6tables-restore passed preflight and then failed the run. Check the same list as MXC_PRIVATE_NETWORK_TOOLS, and list all seven in the DEVELOPMENT.md MXC test prerequisites. Co-authored-by: Cursor --- .agents/skills/axis-e2e/scripts/preflight.sh | 2 +- DEVELOPMENT.md | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.agents/skills/axis-e2e/scripts/preflight.sh b/.agents/skills/axis-e2e/scripts/preflight.sh index 9b6f0188..a1310917 100755 --- a/.agents/skills/axis-e2e/scripts/preflight.sh +++ b/.agents/skills/axis-e2e/scripts/preflight.sh @@ -46,7 +46,7 @@ else record bwrap_userns failed need mxc "bwrap cannot create a user namespace (see apparmor_restrict_unprivileged_userns)" fi -for t in bwrap slirp4netns unshare nsenter iptables; do +for t in bwrap slirp4netns unshare nsenter iptables ip6tables iptables-restore ip6tables-restore; do [ -n "$(tool "$t")" ] || need mxc "$t is not installed" done [ -c /dev/net/tun ] || need mxc "/dev/net/tun is missing" diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 34a040d4..2b348026 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -228,9 +228,11 @@ bash scripts/test_security_tier0.sh The `test_sandbox.sh` cases that run on MXC fail without an `lxc-exec`: build one and copy it next to `target/release/axis`, as the `Build MXC Linux executor` step in `ci.yml` does. The MXC tests also need - `iptables`, `slirp4netns`, and the TUN device (`/dev/net/tun`); without them - they fail rather than skip. CI also runs three gated tests that skip, and - still count as passed, unless their environment variable is set: + `slirp4netns`, `unshare`, `nsenter`, `iptables`, `ip6tables`, + `iptables-restore`, `ip6tables-restore`, and the TUN device + (`/dev/net/tun`); without them they fail rather than skip. CI also runs + three gated tests that skip, and still count as passed, unless their + environment variable is set: ```bash AXIS_TEST_SECCOMP_NOTIFY_ATTRIBUTION=1 \