Repository navigation
ci: Repo-level hook that enforces soldr over bare cargo/rustup (#691) - #715
Merged
Merged
Conversation
ci/hooks/tool_guard.py, ported from soldr's tool_guard.py, denies bare Rust tools and bare python/pip in agent shell commands. It parses the command: FOO=bar, env/exec/sudo prefixes, bash -c strings and every line and pipe segment are checked, while quoted bodies, echo arguments and heredoc bodies are allowed. It is silent in clud sessions, which enforce the same rule. .claude/settings.json wires it (anchored on CLAUDE_PROJECT_DIR, guarded by [ -f ]); .clud/settings.json turns on clud's soldr shims. ci/test_tool_guard.py also fails on bare Rust tools in ci/ and rust/tools/ shell scripts. Fixes #691
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #691
Refs #699
ci/hooks/tool_guard.py(uv script, ported from soldr's.claude/hooks/tool_guard.py) is a PreToolUse hook that denies barecargo/rustup/rustc/... with asoldr <tool>hint, and bare python/pip with a uv hint.shlexinstead of matching substrings.FOO=1 cargo build,env [-u X] cargo build,exec/time/sudo/commandprefixes,bash -c "cargo build"(checked recursively), and every newline,;,&&,||and|segment.gh issue create --body "... bare rustup",echo cargo:warning,git commit -m 'cargo ...', heredoc bodies, anddocker/ssharguments..claude/settings.jsonwires it onBash|Shell|PowerShell, anchored on$CLAUDE_PROJECT_DIRand guarded by[ -f ci/hooks/tool_guard.py ](fbuild's pattern)..gitignorenow tracks only the two shared settings files, so other local agent state stays ignored.CLUD_SESSION_IDis set..clud/settings.jsonsetsrust.use_soldr, so clud users also get the shims.ci/test_tool_guard.pyruns in./lint(ci/test_*.py). It also scans tracked shell scripts underci/andrust/tools/for bare Rust tools. Two container-internal scripts, which run in images without soldr, are allowlisted with reasons.RED → GREEN
FileNotFoundError: ci/hooks/tool_guard.py)../lintis ok. End to end, I ran the settings command withCLUD_SESSION_IDunset:cargo testandbash -c "cargo build"are denied, whilesoldr cargo testandgh issue create --body "bare rustup"produce no output (allowed).