Skip to content

fix(setup): allow static.rust-lang.org; correct the rust-toolchain paths in the doc - #1183

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:fix-rust-toolchain-sandbox-paths
Sep 9, 2026
Merged

fix(setup): allow static.rust-lang.org; correct the rust-toolchain paths in the doc#1183
potiuk merged 1 commit into
apache:mainfrom
potiuk:fix-rust-toolchain-sandbox-paths

Conversation

@potiuk

@potiuk potiuk commented Sep 9, 2026

Copy link
Copy Markdown
Member

Two related defects in how the framework's own sandbox config describes and permits the lychee rust hook. Both originate in #501, which rewrote the annotated block in docs/setup/secure-agent-setup.md but applied only the domain removals to .claude/settings.json and tools/sandbox-lint/expected.json.

1. static.rust-lang.org is required but was never allowed

The lychee hook is language: rust with additional_dependencies: ["cli:lychee"], so prek bootstraps its own toolchain on first run. It downloads rustup-init from static.rust-lang.org:

// crates/prek/src/languages/rust/rustup.rs:115
let url = format!("https://static.rust-lang.org/rustup/dist/{triple}/{filename}");

That host was not in allowedDomains, so a contributor with a cold prek cache cannot build the hook env in-sandbox. *.crates.io was allowed, which is why this looked fine — crate deps resolve, but the toolchain that consumes them can never be fetched.

2. The doc over-stated the framework's home-directory reach

The annotated block claimed the framework needs ~/.rustup/ and ~/.cargo/ in both allowRead and allowWrite. It does not. prek redirects everything into its own cache:

~/.cache/prek/tools/rustup/rustup       # prek's own rustup + toolchains
~/.cache/prek/cache/cargo/registry/     # CARGO_HOME
~/.cache/prek/hooks/rust-*/bin/lychee   # the built binary

All under the ~/.cache/ entries that were already present. The user's own ~/.rustup / ~/.cargo are never read or written — verified on a machine where both exist and neither contains a lychee binary.

Since those four lines were never in the real .claude/settings.json, the doc has been describing a config that does not exist, and claiming more home-directory access than the framework actually takes.

Also

The doc's allowedDomains list omitted api.bitbucket.org, which the real file has. Added so the block matches what it claims to reproduce.

Verification

  • sandbox-lint: OK (.claude/settings.json matches expected.json)
  • prek run --files <the three changed files>: all green
  • pytest tools/sandbox-lint: 111 passed

Generated-by: Claude Code (Opus 5)

…ths in the doc

The lychee prek hook is `language: rust` with `additional_dependencies:
["cli:lychee"]`, so prek bootstraps its own toolchain on first run. It
fetches `rustup-init` from static.rust-lang.org, which was never in
`allowedDomains` — a contributor with a cold prek cache cannot build the
hook env in-sandbox.

The annotated block in the setup doc also claimed the framework needs
`~/.rustup/` and `~/.cargo/`. It does not: prek installs its rustup and
toolchains under `~/.cache/prek/tools/rustup/` and points CARGO_HOME at
`~/.cache/prek/cache/cargo/`, both already covered by `~/.cache/`. Those
lines were added to the doc in apache#501 and never applied to the settings
file or the sandbox-lint baseline, so the doc has been describing a
config that does not exist and over-stating the framework's reach into
the home directory.

Generated-by: Claude Code (Opus 5)
@potiuk
potiuk merged commit f22d0a4 into apache:main Sep 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant