Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 34 additions & 7 deletions host-setup/agent-safety/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,13 @@ text says, because the harm it covers was never in the text.
subcommand whose aliases reach a `!` shell alias is denied in any checkout, whatever that alias
runs. The hook does not read its shell text. A
persisted alias is read from the directory git runs in. It is also read from a `--git-dir` or
`GIT_DIR` repository, through a linked worktree's `.git` file as git reads it. A git command nested past the wrapper reading cap is denied
`GIT_DIR` repository, through a linked worktree's `.git` file as git reads it. A `GIT_DIR` or
`GIT_WORK_TREE` on a wrapper shell's prefix, or exported before it, reaches the git commands in
its body. An alias expansion is read past the global options it leads with, such as `-p` or
`-c`, and a `-c alias.<name>` among them is followed. An include or a `--config-env` among them
is denied. So is a command key whose program the hook does not read or whose command runs
git. A `core.hooksPath` among them is judged as it is on a command line. A persisted alias read that times out or cannot run is denied
where the name may be an alias. A git command nested past the wrapper reading cap is denied
where its subcommand may be an alias. An alias set by `--config-env` for the subcommand it runs is denied too. An `eval`
argument holding an include key is read as the command it runs. It also covers a bare push or a
`HEAD`/`@` refspec whose directory or branch may change before it runs. Such a push's local
Expand Down Expand Up @@ -167,7 +173,25 @@ text says, because the harm it covers was never in the text.
`core.fsmonitor`, and `GIT_EDITOR`. Such a value is denied where it names its program by a
path or an expansion, or comes from `--config-env`. The hook does not read that program. An
`include.path`/`includeIf` override is denied on any git command. So is a `GIT_CONFIG_GLOBAL`
or `GIT_CONFIG_SYSTEM` file other than `/dev/null`. Either file may set any of those keys.
or `GIT_CONFIG_SYSTEM` file other than `/dev/null`. Either file may set any of those keys. So
is a `HOME` or `XDG_CONFIG_HOME` other than `/dev/null`, which names the directory holding the
global config file. Config set through `GIT_CONFIG_COUNT` is read per git command, so a later
command reusing an index cannot hide an earlier one's key. A `core.hooksPath` override is
denied on any git command, since a checkout, a branch, and any other command that updates a
ref run hooks too. A `/dev/null` value holds no hook and is allowed. It is still denied on a
commit, a push, or a subcommand that may be an alias, where it skips the hooks. An empty value
is denied, since git then looks for hooks in the filesystem root. Some commands before a push
may rewrite its remote config. One is a `git config` or `git remote` that does not only read.
A lone key or `--get` reads, unless a write action such as `--unset` names it. A value, or an
argument holding a substitution, writes.
Others are a git subcommand that may be an alias and a `gh` command whose group may touch git
config. That is any group outside a list of reads such as `gh issue`. A `gh pr` counts only for
`checkout`, and a `gh repo` for anything but a read like `view`. So is a
run-time command word, which may expand to any of them. A wrapper shell or a substitution
running one counts, and so does a shell running a script file or its input.
After one, the push reads its remote's `mirror` setting and its checkout's origin as
undetermined. The hook reads both before the command runs, and a checkout or a switch changes
neither.
A shell whose command string runs git is denied where its prefix or an earlier `export` sets
such a file, or config through `GIT_CONFIG_COUNT`. A variable git runs as a command, set
there, counts too, unless it names a plain program that runs no git. The hook reads that
Expand Down Expand Up @@ -251,11 +275,14 @@ text says, because the harm it covers was never in the text.
custom alias that expands to a denied builtin (`git -c alias.wipe='reset --hard' wipe`, or the
same `wipe` alias persisted in the checkout's own config) is denied exactly as the builtin itself
would be. A `!`-prefixed alias hands git an arbitrary shell string rather than naming another git
subcommand, and this requirement does not and cannot safely interpret one, so it denies that
shape outright against a primary checkout. This is one of two places this requirement departs
from its own fail-open stance. The alias definition itself is concrete evidence of an attempt to
run something via git in exactly the directory this requirement protects. The other place is a
directory value holding a `..` component, below.
subcommand. This requirement does not and cannot safely interpret one, so it denies that shape
outright against a primary checkout. That departs from this requirement's own fail-open
stance. The alias definition itself is concrete evidence of an attempt to run something via
git in exactly the directory this requirement protects. A directory value holding a `..`
component departs from it too, below. The persisted alias is read from the repository git runs
in, which a `--work-tree` does not move, and from the work tree as well. An expansion is read
past its leading global options, such as `-p`, to the subcommand it runs. An alias read that
times out or cannot run is denied too, where the name may be an alias.

Resolve the target directory the way real git itself does, not by a last-option-wins scan across
every directory-naming option: any `-C <dir>` options on the invocation compose sequentially (an
Expand Down
Loading
Loading