Expand description
A container agent’s push, judged by the host’s publish guard.
The pre-push hook (git_hooks.rs) collects what the push publishes with the container’s own git: per ref update
the commits’ messages, the added paths and the added lines, as the text git prints. ask posts it to srv
(POST /api/v1/github/push-scan), which gives it as data to the host’s gh-agent scan-push. The host never opens
the container’s clone; the material is all it sees.
- A machine with no publish guard, and a native agent’s shell, never reach srv: srv says
AGENTMUX_PUBLISH_GUARD=1in a container’s commands on a machine whose guard can judge a container’s push,=0on one that has no guard, and=older-gh-agenton one whose gh-agent is too old to judge it. The hook does nothing and says nothing for0. Where srv says nothing (an AgentMux older than the check), the hook says once per push that it was checked for credentials only, and lets it go on: nothing on that host can judge it. - With
older-gh-agent, a push to a GitHub repository is refused, saying to update gh-agent on the host and to have it rewrite its hooks (the version is read from the hooks’ header). - With
1, an AgentMux that has no route to ask (404 or 405) refuses the push, and says to update AgentMux. - A push to a repository the guard finds private is not collected at all.
- On a machine that has the guard, a public repository’s push whose check cannot run (srv unreachable, too slow, too large, refused) is refused, with what to do.
The git commands are the ones gh-agent’s own pre-push hook runs; the two judge the same text.
Structs§
- Changeset
- Part
- The material of one ref update, as srv takes it.
- RefUpdate
- One ref update of the push.
- Request 🔒
Enums§
Constants§
- ASK_
TIMEOUT 🔒 - srv runs the guard for up to a minute (a first read of the pattern list, a visibility lookup, the scan).
- MAX_
CHANGESETS 🔒 - MAX_
MATERIAL_ 🔒BYTES - The most material one push may send; the same figure srv enforces.
- MAX_
PUSH_ 🔒COMMITS - Past this many commits a push is refused by the guard without being read.
- MAX_
TAG_ 🔒DEPTH - Most annotated tags one pushed object may be wrapped in (a tag of a tag of …); more fails the check.
- ZERO 🔒
Functions§
- ask 🔒
- Ask srv to judge
parts(empty: only whether this machine guardsrepo). - changeset_
paths - The
.changesets/*.mdfiles named ingit log -z --name-statusoutput: only the guard decides which of them the push added, so every path of that shape is sent (at mostMAX_CHANGESETS). - check_
push - The publish guard’s part of
pre-push <remote> <url>: 0 to go on, anything else refuses the push. - check_
with 🔒 check_pushwith its surroundings given: what the machine has, the override, srv, and git.- collect
- The material of each ref update. The commands are the ones gh-agent’s own pre-push hook runs, so both judge the same text.
- guard_
here 🔒 - parse_
updates - The ref updates on the hook’s stdin (
<local ref> <local sha> <remote ref> <remote sha>), deletions left out. - peel_
tags 🔒 - What
shais once the annotated tags around it are peeled: the message of those tags, joined in order (Nonewhenshais no tag object), and the type of what is left (commit,blob,tree, ortagfor a tag git could not follow). - read_
answer - Read srv’s answer: its status and body.
- real_
git 🔒 - git in the current directory.
- refuse_
no_ 🔒route - What to do when the machine has the guard but its AgentMux cannot be asked: not a thing to try again.
- refuse_
unavailable 🔒 - What to do after a check that could not run.
- repo_
of_ remote_ url owner/repo, lowercase, of a github.com remote URL (https, ssh or scp form);Nonefor anything else.- show 🔒
- tag_
body - The body of an annotated tag’s message from
git cat-file tag: everything after the first blank line. - tag_
target 🔒 - The object a tag points at: the
objectline ofgit cat-file tagoutput.
Type Aliases§
- Git
- Runs git with these arguments in the current directory: its stdout, or what failed.