Repository navigation
feat(agent): dependency hooks in the Docker sandbox - #69
Merged
Merged
Conversation
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.
Problem
The dependency hook (
stashbase agent hooks, installed bystashbase agent hooks deps install) did not run in Docker sandbox sessions: the image has no Stashbase CLI, and Claude Code treats a missing hook command as non-blocking, so installs went unchecked without any error. Global hooks installed on the host were also invisible inside the container, whose home is thestashbase-agent-homevolume.Changes
/__stashbase/agent-hook(requiresallow_hooks = ["dependency_check"], Docker runs only). It runs the host's ownstashbase agent hookswith the agent's hook payload as stdin and returns its output (the allow/deny/warn JSON). Same confinement, scratchHOME/TMPDIR, API URL, serialization and output caps as the secret-scan route; payload capped at 1 MiB, 60 s timeout.stashbasestand-in in the container. When the route is served, a small script is mounted read-only at/usr/local/bin/stashbase. Existing hook configs keep working unchanged. It forwards onlystashbase agent hooksand exits 2 (blocking the command) if the broker is unreachable, so installs no longer pass unchecked. Any otherstashbasecommand is refused.--dockerforagent hooks deps install|check|uninstall. Writes the hook config into the Docker sandbox's home volume, shared by every Docker run, so it acts as a global install for Docker. The volume's files are staged on the host viadocker run --network nonewith the default image, edited by the existing install logic, and copied back. Install functions now take aHookScope(Project/Global/Docker) instead ofglobal: bool.dependency_checkunder Docker now requires the same confinement assecret_scan(Seatbelt on macOS, bubblewrap on Linux). The run refuses at startup before any Docker setup, andagent validateflags it.docs/agent-profiles.md(API Hooks),docs/sandboxing.md.Testing
dependency_check), stand-in mount and script behavior, Docker-only enablement and confinement, Docker hook scope install/check/uninstall.npm installin a sandboxed Claude Code session is checked through the host, with both a project-level hook and a--docker-installed hook.Notes
dependency_checkin the profile, the hook stays off as before (fail-open), unlike the secret scan.