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
32 changes: 24 additions & 8 deletions host-setup/agent-safety/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,30 @@ text says, because the harm it covers was never in the text.
write's positional argument is one too, as in a pull request or issue URL, and so is the
repository `gh repo edit` or `gh issue transfer` takes. On a `gh api` write, an owner named by an
`orgs/`, `users/`, or `user/...` path counts, as in `orgs/<owner>/...` or `user/starred/<owner>/<repo>`. A
`[HOST/]OWNER/REPO` value is read by its middle owner as well as by its first part. A gh write
run through a run-time command word, as in `G=gh; $G pr comment ...`, is read as one. One
exception departs from that stance. A write whose repository owner is a run-time word fails
closed, since it leaves nothing to compare. That covers `--repo "$T"`, `GH_REPO="$T"`,
`repos/$O/...`, a run-time repository positional, and a `gh api` write whose endpoint opens
with a run-time word. It also covers a run-time word before gh's command that may hold a repo
flag, as in `gh "$R" pr comment`. A `--repo "example/$R"` names its owner and is compared as
usual.
`[HOST/]OWNER/REPO` value is read by its middle owner as well as by its first part. An
`--org`, `--owner`, or `--target-owner` value names an owner the way an `orgs/<owner>` path
does. So does `-o` on a secret, variable, or ruleset command. An issue-linking flag such as
`--parent`, `--add-sub-issue`, or `--duplicate-of` names a repository by a URL or
`OWNER/REPO#N` value. A gh write run through a run-time command word, as in
`G=gh; $G pr comment ...`, is read as one. Behind such a word, a run-time command or
subcommand counts as a possible write where a repo flag names a literal `OWNER/REPO`. The words
beside it must then be a literal one some write takes, as in `$G "$C" comment`, or a second
run-time word. Writes whose target the hook cannot compare depart from that stance and fail
closed. A write whose repository owner is a run-time word is one, since it leaves nothing to
compare. That covers `--repo "$T"`, `GH_REPO="$T"`, `repos/$O/...`, and `--org "$O"`. It
covers a run-time repository positional and a `gh api` write whose endpoint opens with a
run-time word. It also covers a run-time word before gh's command that may hold a repo flag,
as in `gh "$R" pr comment`. A `--repo "example/$R"` names its owner and is compared as usual.
A write whose target the hook does not read is the other, rather than the hook modeling the
shell further. That is a gh write an `eval` runs. It is a `gh api` write to a
`repositories/<id>` endpoint, or one through a `..` segment, which GitHub resolves. It is also
a write taking its repository from a `GH_REPO` that a builtin other than `export` may set.
Such builtins include `declare`, `read`, `printf -v`, `builtin export`, an `eval`, and
`set -a`. An append such as `GH_REPO+=...` counts the same way. An
`export GH_REPO` in a subshell, a loop, or behind `&&` may not run where it sits. Where one
may not, every value the command sets is read as reaching its gh write. A run-time segment past a
literal owner in a `gh api` endpoint is compared by that owner, though it may hold a `..`
segment.
4. **A git operation that would only succeed by bypassing an active branch rule is denied**: a
direct push to a branch whose rules require a pull request, a force-push where history is
protected, a delete where deletion is blocked, or an explicit-bypass flag (`--admin` on a merge,
Expand Down
Loading
Loading