Vault commands
vault_commands
¶
Executor-level vault helpers: route generation + credential-leak scan.
The vault is served per container: the supervisor spawns on container
start via the terok-sandbox OCI hook and reads the per-container
sidecar to bind its proxy. Sandbox owns the unlock / lock /
passphrase verbs (passphrase-tier CRUD on the DB).
What lives here:
routes— regenerateroutes.jsonfrom the YAML agent roster.clean— remove leaked credential files from shared config mounts.scan_leaked_credentials+ the_BENIGN_CREDENTIAL_CHECKSregistry of per-provider recognizers for credential files that are legitimately non-empty — primitives the scan + clean verbs share.
Both verbs operate on host-side files only.
SANDBOX_TREE = _build_sandbox_tree()
module-attribute
¶
SANDBOX_GROUP = CommandDef(name='sandbox', help='Sandbox subsystem (full deep tree — same verbs as terok-sandbox)', children=(SANDBOX_TREE.roots))
module-attribute
¶
VAULT_GROUP = SANDBOX_TREE.find_at(('vault',))
module-attribute
¶
VAULT_COMMANDS = (VAULT_GROUP,)
module-attribute
¶
scan_leaked_credentials(mounts_base)
¶
Return (provider, host_path) for credential files found in shared mounts.
When the vault is active, real secrets should only live in the vault's sqlite DB — not in the shared config directories that get mounted into containers. This function checks each routed provider's mount for credential files that would leak real tokens alongside phantom ones.
Non-empty files recognised as benign by the provider's
_BENIGN_CREDENTIAL_CHECKS entry — terok-injected phantoms, or
glab's settings-only config.yml — are skipped.
A credential file that does not exist is a definitive clean result, not a skipped check: an agent that ships in the image but was never authenticated on this host has nothing to leak. Only genuine read failures (permissions, I/O errors) warrant the skip warning.
Symlinks are rejected to prevent a container from tricking the scan into reading arbitrary host files via a crafted symlink in the shared mount.