Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/lint-requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ruff==0.17.6
shellcheck-py==0.11.0.1
29 changes: 29 additions & 0 deletions .github/lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file was autogenerated by uv via the following command:
# uv pip compile --python-version 3.12 --python-platform x86_64-manylinux_2_28 --generate-hashes --no-emit-index-url --output-file .github/lint-requirements.txt .github/lint-requirements.in
ruff==0.17.6 \
--hash=sha256:0692088e6b33455572fb18465e891b443f196e98dc1986825685c77ff6f4c5ac \
--hash=sha256:084d9c8f5ec718e7eba007dba339e7cb4f7571d2f267558ae080bf428fb6a69b \
--hash=sha256:1939b3d701c7b6981b7cf93473de5bf88b129b9ba84efaed5154cc517c44634d \
--hash=sha256:1a0bea6aa1216e0ec4cd35d3dbccec0d772a7c2aad28ec9c6e82571dff2c20b0 \
--hash=sha256:2b04276561331300325040bdca21460770029ec574d4c479099e39e8ad1ed43c \
--hash=sha256:3db61f5015600543a581b07fa7f6f64afa0eeedefe16034cadd88c4074087582 \
--hash=sha256:435241c61af5909a022f76219d3d1bf24730dc1bf0acabb5ddf4b569ab3cbb30 \
--hash=sha256:6a12c50a33936dc00db2be21ba25fb168a8b95c55eda2a3ac85005af69885e4b \
--hash=sha256:9cd2fd9923e9806b8b6b67a3469e2258e84bd4d21e45d5a1a690afdfb9c8e57d \
--hash=sha256:9d44ef2140402043fd6f689ef541858b80883a8b0a02e38539ef0614ebe57d0c \
--hash=sha256:9fbddc08577592e283c265d865e0182de6e33db185494db7b06290d989d888e5 \
--hash=sha256:aa3b08254a732acba246891089a152c47c5733dc36b8ecb76ce8602f8326e5e4 \
--hash=sha256:b5aba93b3db4b70c5697e4fee6e0d5b9c8452a9a3a03679611cadc25915a2173 \
--hash=sha256:c2f4af6670b7a0501904e881bb3f1f24bd0d964dec1eedbd85f0eb73786e1128 \
--hash=sha256:d006bbb2945edb17b0ce6a0c1b5f5a8d81ba11dbac294a0a925effa22ce34feb \
--hash=sha256:d8b14e1473dc86ab9069cf7a2ba5041dc012f59110201844ed04cfddf07055a0 \
--hash=sha256:fb589e032806bb942e4fb526f30b80a1a64112147ed9f1d38cc3de2e255b6f45 \
--hash=sha256:fd661702202a89c00a4c9d0339008805fa5876bfa1c57e165495c2e62230dfbf
# via -r .github/lint-requirements.in
shellcheck-py==0.11.0.1 \
--hash=sha256:1b274df81de5b000ff78db433e7328b87e52e3c38481c60f8e488c3095beef05 \
--hash=sha256:5c620c88901e8f1d3be5934b31ea99e3310065e1245253741eafd0a275c8c9cc \
--hash=sha256:6b88d0a244c82ed07e06a53e444da841f69330ca59ae15d4a66c391655dae7a0 \
--hash=sha256:784156289ecb17e91c692cd783ab5152333309588cabb10032a047331c63e759 \
--hash=sha256:b6a3fee28efda2e16e38d6e6d59faf7224300256456639727370d404730849e8
# via -r .github/lint-requirements.in
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,48 @@ jobs:
run: |
cargo fmt --all -- --check
cargo fmt --manifest-path gui/linux/Cargo.toml -- --check
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- name: Install lint tools
run: |
python -m pip install --disable-pip-version-check --only-binary=:all: --require-hashes -r .github/lint-requirements.txt
- name: Lint shell scripts
run: |
set -euo pipefail
git ls-files -z -- '*.sh' | xargs -0 shellcheck
- name: Lint Python
run: ruff check .
- name: Lint PowerShell
env:
PSSA_VERSION: "1.25.0"
PSSA_SHA256: 14e634c828eb98efb9f40b2918ba90f139ed5eccdf663a2a747736d996995d60
run: |
set -euo pipefail
package="$RUNNER_TEMP/PSScriptAnalyzer.$PSSA_VERSION.nupkg"
curl --fail --location --proto '=https' --tlsv1.2 \
--connect-timeout 15 --max-time 120 --retry 3 \
--output "$package" \
"https://www.powershellgallery.com/api/v2/package/PSScriptAnalyzer/$PSSA_VERSION"
echo "$PSSA_SHA256 $package" | sha256sum --check --strict
python -m zipfile -e "$package" "$RUNNER_TEMP/PSScriptAnalyzer"
# shellcheck disable=SC2016 # The single quotes pass the PowerShell script through unexpanded.
pwsh -NoProfile -Command '
$ErrorActionPreference = "Stop"
Import-Module "$env:RUNNER_TEMP/PSScriptAnalyzer/PSScriptAnalyzer.psd1"
$files = @(git ls-files -- "*.ps1")
if ($LASTEXITCODE -ne 0 -or $files.Count -eq 0) {
throw "No tracked PowerShell files found"
}
$findings = @($files | ForEach-Object {
Invoke-ScriptAnalyzer -Path $_ -Settings PSScriptAnalyzerSettings.psd1
})
foreach ($finding in $findings) {
"{0}:{1}: {2} {3}: {4}" -f $finding.ScriptPath, $finding.Line, $finding.Severity, $finding.RuleName, $finding.Message
}
if ($findings.Count -gt 0) { exit 1 }
"Checked $($files.Count) PowerShell files, no findings"
'

gui-release-validation:
name: GUI release validation
Expand Down
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ checks the link out as a plain file unless `core.symlinks` is on.
file's comment syntax (`//` for Rust and TypeScript, `#` for shell, Python and
PowerShell), after the shebang line if there is one.
- Match the surrounding code; do not reformat files you did not change.
- Fix a lint finding in shell, Python, or PowerShell code. Where the code is
right, suppress that one finding with a stated reason (`# shellcheck disable=`,
`# noqa:`, `SuppressMessage` with a justification). Where a rule is wrong for
a whole class of files, not just for the file in front of you, the only other
route is excluding that rule in the lint config (see **Ask first**). Never
exclude a file, and never turn a rule off only to make a finding go away.
- When the `node_modules/vite` entry in `gui/shared/package-lock.json`
changes, update its reviewed pin in `reviewedShippedDevPackages`
(`gui/shared/scripts/generate-third-party-notices.mjs`, which checks what
Expand All @@ -139,6 +145,9 @@ checks the link out as a plain file unless `core.symlinks` is on.
**Ask first**
- Adding a dependency or changing `Cargo.lock` beyond what the change needs.
- Changing a backend default or a bundled policy in `policies/`.
- Adding or widening a rule exclusion in the lint config (`ruff.toml`,
`PSScriptAnalyzerSettings.psd1`, or a ShellCheck rc file). Write the reason
beside the exclusion, as the existing ones do, and state it in the PR.
- Editing `.github/workflows/`, `scripts/verify_workflow_structure.py`, or
`scripts/release_tools.py`. If a release, nightly, or GUI release job
changes, update its pinned digest in the same PR and explain why the job
Expand Down
46 changes: 45 additions & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,48 @@ cargo test --locked
bash scripts/test_security_tier0.sh
```

- Shell, Python, or PowerShell files: lint them as the Format job does. Install
the hash-locked ruff and ShellCheck packages into a virtual environment
outside the repository, then run:

```bash
python3 -m venv "$HOME/.venvs/axis-lint" && . "$HOME/.venvs/axis-lint/bin/activate"
python -m pip install --disable-pip-version-check --only-binary=:all: --require-hashes -r .github/lint-requirements.txt
git ls-files -z -- '*.sh' | xargs -0 shellcheck
ruff check .
```

`ruff` reads `ruff.toml`. `shellcheck-py` has no Linux arm64 wheel, so on
that platform the `pip install` above fails as a whole and installs neither
tool. There, install `ruff` on its own at the version pinned in
`.github/lint-requirements.in` (pip does not check its hash this way):

```bash
python -m pip install --disable-pip-version-check --only-binary=:all: "$(grep '^ruff==' .github/lint-requirements.in)"
```

Then install ShellCheck from the `linux.aarch64` asset of the matching
release on [koalaman/shellcheck](https://github.com/koalaman/shellcheck/releases)
(`shellcheck-v<version>.linux.aarch64.tar.xz`), where `<version>` is the
first three components of the `shellcheck-py` version in
`.github/lint-requirements.in`. Run `shellcheck --version` to confirm it
reports that version; a distribution package can be older.

For PowerShell, install PSScriptAnalyzer at the version `PSSA_VERSION` sets
in the "Lint PowerShell" step of `.github/workflows/ci.yml`
(`Install-Module PSScriptAnalyzer -RequiredVersion <version>`). CI also
checks the downloaded package against `PSSA_SHA256` in that step;
`Install-Module` does not. Run, from the repository root:

```powershell
git ls-files -- '*.ps1' | ForEach-Object { Invoke-ScriptAnalyzer -Path $_ -Settings PSScriptAnalyzerSettings.psd1 }
```

Any output is a finding. To change the ruff or `shellcheck-py` version, edit
`.github/lint-requirements.in` and regenerate `.github/lint-requirements.txt`
with the command in its header, which needs [uv](https://docs.astral.sh/uv/).
To change the PSScriptAnalyzer version, edit `PSSA_VERSION` and `PSSA_SHA256`
together in the CI step.
- GUI: from `gui/shared`, run `npm ci`, `npm test`, `npm run typecheck`,
`npm run build`, and `npm run audit:deps`. The last one runs `npm audit` and
fails on any high or critical advisory not listed in
Expand Down Expand Up @@ -258,7 +300,9 @@ Every PR automatically runs the following checks:

1. **Lint & format** — `cargo fmt --all -- --check`,
`cargo fmt --manifest-path gui/linux/Cargo.toml -- --check`, and
`cargo clippy --locked --all-targets -- -D warnings`.
`cargo clippy --locked --all-targets -- -D warnings`. The Format job also
runs ShellCheck, `ruff check .`, and PSScriptAnalyzer over every tracked
shell, Python, and PowerShell file (see Local Checks).
2. **Correctness tests** — `cargo test --locked`, the security tier 0/1 tests,
the Linux, macOS and Windows test jobs, e2e tests, and policy validation.
3. **Security checks** — dependency audit and review, secret scan, CodeQL, and
Expand Down
30 changes: 30 additions & 0 deletions PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@{
# A finding of any listed severity fails CI. Information-level rules are
# left out because they give style advice (positional parameters, missing
# output-type declarations) and do not point at defects. ParseError is
# listed because PSScriptAnalyzer drops a syntax error from the results
# when the severity filter does not name it, and several of these scripts
# are neither run nor parsed anywhere else in CI.
Severity = @('Error', 'Warning', 'ParseError')

# Each exclusion turns a rule off for every script, so add one only with a
# reason that holds for the whole class of files, and state it here.
ExcludeRules = @(
# These are console scripts and installers, where Write-Host is the
# intended user-facing output.
'PSAvoidUsingWriteHost',

# This rule protects callers of exported cmdlets that take -WhatIf and
# -Confirm. The functions it flags are private helpers inside e2e and
# installer scripts (they build specs, command lines and wrapper files
# or start a test process); nothing calls them with -WhatIf, so
# SupportsShouldProcess would add a switch that nothing reads.
'PSUseShouldProcessForStateChangingFunctions',

# This rule keeps exported cmdlet nouns singular so that command names
# stay predictable for users. The helpers in these scripts are
# private, and a name such as Assert-InstallFails describes what the
# helper checks.
'PSUseSingularNouns'
)
}
10 changes: 5 additions & 5 deletions e2e/agents/install_agents.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ New-Item -ItemType Directory -Path $ToolsDir -Force | Out-Null
New-Item -ItemType Directory -Path $BinDir -Force | Out-Null
New-Item -ItemType Directory -Path $PoliciesDir -Force | Out-Null

# ── Agent definitions ────────────────────────────────────────────────────
# -- Agent definitions ----------------------------------------------------

$AgentDefs = @{
"claude-code" = @{ Binary = "claude"; Policy = "claude-code.yaml"; Install = "Install-ClaudeCode" }
Expand All @@ -47,7 +47,7 @@ $AgentDefs = @{

$AllAgents = @("claude-code", "codex", "openclaw", "ironclaw", "aider", "goose", "gemini-cli", "opencode")

# ── Install functions ────────────────────────────────────────────────────
# -- Install functions ----------------------------------------------------

function Install-ClaudeCode {
$dir = "$ToolsDir\claude-code"
Expand Down Expand Up @@ -160,7 +160,7 @@ function Install-Aider {
if ($pythonCmd) {
Write-Host " Creating venv..."
& $pythonCmd -m venv "$dir\venv" 2>&1 | Out-Null
# Upgrade pip and install setuptools first — required for building native deps
# Upgrade pip and install setuptools first - required for building native deps
Write-Host " Upgrading pip and installing build deps..."
& "$dir\venv\Scripts\python.exe" -m pip install --upgrade pip setuptools wheel 2>&1 | Out-Null
Write-Host " Installing aider-chat..."
Expand Down Expand Up @@ -247,7 +247,7 @@ function Install-OpenCode {
return ""
}

# ── Wrapper generator ────────────────────────────────────────────────────
# -- Wrapper generator ----------------------------------------------------

function Get-AgentDefaultFlags {
param([string]$AgentName)
Expand Down Expand Up @@ -304,7 +304,7 @@ if (`$env:AXIS_NO_DEFAULT_FLAGS) {
Write-Host " Wrapper: $ps1Wrapper"
}

# ── Main ─────────────────────────────────────────────────────────────────
# -- Main -----------------------------------------------------------------

if ($List) {
Write-Host "Available agents:"
Expand Down
4 changes: 2 additions & 2 deletions e2e/agents/test_agents.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Test-Pass($msg) { Write-Host " PASS: $msg" -ForegroundColor Green; $sc
function Test-Fail($msg) { Write-Host " FAIL: $msg" -ForegroundColor Red; $script:fail++ }
function Test-Skip($msg) { Write-Host " SKIP: $msg" -ForegroundColor Yellow; $script:skip++ }

# ── Test each agent policy ────────────────────────────────────────────
# -- Test each agent policy --------------------------------------------

$agents = @(
@{ Name = "base-deny"; Policy = "base-deny.yaml" },
Expand Down Expand Up @@ -70,7 +70,7 @@ foreach ($agent in $agents) {
Write-Host ""
}

# ── Summary ──────────────────────────────────────────────────────────
# -- Summary ----------------------------------------------------------

Write-Host "=================================================="
$total = $pass + $fail
Expand Down
2 changes: 1 addition & 1 deletion e2e/agents/test_agents.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
POLICY_DIR="${SCRIPT_DIR}/../../policies/agents"
TMP_ROOT="$(mktemp -d /tmp/axis-agent-e2e-XXXXXX)"

# shellcheck disable=SC2317 # Invoked indirectly by the EXIT trap.
# shellcheck disable=SC2317,SC2329 # Invoked indirectly by the EXIT trap.
cleanup() {
rm -rf "$TMP_ROOT"
}
Expand Down
3 changes: 0 additions & 3 deletions e2e/linux/test_e2e_daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ else
else
fail "timeout sandbox child process is running"
fi
timeout_dir="$READY_WORKSPACE"
timeout_pid="$READY_PID"
if wait_for_absent "$timeout_id"; then
pass "timeout destroys sandbox and cleanup removes it from list"
Expand Down Expand Up @@ -398,7 +397,6 @@ if command -v python3 >/dev/null 2>&1; then
else
fail "block-mode sandbox child process is running"
fi
block_dir="$READY_WORKSPACE"
block_pid="$READY_PID"
set +e
axis_cli exec --sandbox "$block_id" -- python3 -c 'import socket, sys
Expand Down Expand Up @@ -450,7 +448,6 @@ else
else
fail "crash-cleanup sandbox child process is running"
fi
crash_dir="$READY_WORKSPACE"
crash_pid="$READY_PID"

if [ -n "$AXSD_PID" ]; then
Expand Down
1 change: 0 additions & 1 deletion e2e/linux/test_hip_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import ctypes.util
import os
import sys
import struct

def main():
# Load the hip-remote client library
Expand Down
4 changes: 2 additions & 2 deletions e2e/windows/bench_mxc_runtime.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Resolve-MxcExecutor {
Exit-Fail "set AXIS_TEST_MXC_EXECUTOR or provide wxc-exec, wxc, mxc-exec, or lxc-exec on PATH"
}

function Quote-Arg([string]$Value) {
function ConvertTo-QuotedArg([string]$Value) {
return '"' + $Value.Replace('"', '\"') + '"'
}

Expand Down Expand Up @@ -216,7 +216,7 @@ function Write-MxcConfig([string]$Path, [object]$Backend, [string]$Marker, [int]
function Start-MxcConfig([string]$ConfigPath, [string]$Marker, [string]$Containment) {
$psi = [System.Diagnostics.ProcessStartInfo]::new()
$psi.FileName = $executor
$psi.Arguments = "--experimental --config " + (Quote-Arg $ConfigPath)
$psi.Arguments = "--experimental --config " + (ConvertTo-QuotedArg $ConfigPath)
$psi.UseShellExecute = $false
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
Expand Down
5 changes: 5 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target-version = "py312"

[lint]
# Explicit on purpose: ruff's default rule set changes between releases.
select = ["E4", "E7", "E9", "F", "B"]
1 change: 1 addition & 0 deletions scripts/check_linux_mxc_packaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ assert_contains "$REPO_ROOT/crates/axis-daemon/Cargo.toml" 'usr/share/doc/axis/L
# MXC Bubblewrap allow and proxy modes need slirp4netns and the iptables tools.
# They are recommended rather than required; the pre-launch check rejects those
# policies when the tools are missing.
# shellcheck disable=SC2016 # Match the literal $auto in the expected TOML text.
assert_contains "$REPO_ROOT/crates/axis-daemon/Cargo.toml" 'depends = "$auto, bubblewrap"'
assert_contains "$REPO_ROOT/crates/axis-daemon/Cargo.toml" 'recommends = "iptables, slirp4netns"'
assert_contains "$REPO_ROOT/crates/axis-daemon/Cargo.toml" '[package.metadata.generate-rpm.recommends]'
Expand Down
1 change: 0 additions & 1 deletion scripts/test_generate_third_party_notices.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import json
import os
from pathlib import Path
import stat
import sys
import tarfile
import tempfile
Expand Down
4 changes: 3 additions & 1 deletion scripts/test_verify_release_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,9 @@ def test_trusted_package_tool_rejects_every_unsafe_metadata_case(self):
"stat",
autospec=True,
side_effect=lambda path: (
file_metadata if path == resolved else parent_metadata
# B023 is a false positive: the lambda runs inside this
# loop iteration, so it sees the current values.
file_metadata if path == resolved else parent_metadata # noqa: B023
),
), mock.patch.object(verifier.os, "access", return_value=executable):
with self.assertRaisesRegex(
Expand Down
1 change: 1 addition & 0 deletions scripts/verify_linux_package_manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ if ! diff -u "$expected" "$actual"; then
fail "$package_type payload does not match the expected path-and-mode manifest"
fi

# shellcheck disable=SC2043 # One file today; the loop takes more legal files.
for legal_file in LICENSE; do
packaged="$payload_root/usr/share/doc/axis/$legal_file"
if ! cmp -s "$REPO_ROOT/$legal_file" "$packaged"; then
Expand Down
4 changes: 2 additions & 2 deletions scripts/verify_release_archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ def create_parent_directories(destination: Path, path: PurePosixPath) -> None:
current.mkdir(mode=0o755)
except FileExistsError:
if not current.is_dir() or current.is_symlink():
raise ArchiveError(f"unsafe extraction parent: {path}")
raise ArchiveError(f"unsafe extraction parent: {path}") from None
except OSError as error:
raise ArchiveError(f"failed to create extraction parent: {path}") from error

Expand All @@ -691,7 +691,7 @@ def create_directory(destination: Path, path: PurePosixPath) -> None:
target.mkdir(mode=0o755)
except FileExistsError:
if not target.is_dir() or target.is_symlink():
raise ArchiveError(f"unsafe extraction directory: {path}")
raise ArchiveError(f"unsafe extraction directory: {path}") from None
except OSError as error:
raise ArchiveError(f"failed to create extraction directory: {path}") from error

Expand Down
Loading