The trust model
Executing scripts declared in a repo on entry is an attack vector: check
out a pull-request branch, type tw pr-branch, and an attacker-supplied
twig.toml would run arbitrary code. twig copies
direnv’s answer.
How it works
Section titled “How it works”- The first time twig sees a given
twig.toml, it refuses to use it, prints the full contents, and asks for approval. Interactively that’s a y/N prompt; otherwise you get instructions to runtwig trust. - Approval is recorded as
sha256(absolute path + file content). Any edit to the file, or moving it, invalidates the approval and the gate trips again. - The gate covers the whole manifest. An untrusted
twig.tomlcontributes neither scripts nor its[open]section, because repo-defined openers are arbitrary commands too.
Managing approvals
Section titled “Managing approvals”twig trust # approve the manifest governing the current dirtwig trust <fragment> # approve another worktree's manifesttwig trust --show # print it without approvingtwig trust --list # every approval, newest firsttwig trust --revoke # withdraw approvalApprovals live in ~/.local/share/twig/trust/ (XDG data dir), one JSON
file per approved content version, written atomically.
What this protects (and what it doesn’t)
Section titled “What this protects (and what it doesn’t)”The gate ensures nothing executes that you haven’t read and approved at that exact content. It does not sandbox approved scripts: approval means you trust the script with everything your user account can do. Read before you approve.