Skip to main content

Module publish_scan

Module publish_scan 

Source
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=1 in a container’s commands on a machine whose guard can judge a container’s push, =0 on one that has no guard, and =older-gh-agent on one whose gh-agent is too old to judge it. The hook does nothing and says nothing for 0. 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§

Answer
What srv said.
Guard 🔒
What this machine has for a push in this shell.

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 guards repo).
changeset_paths
The .changesets/*.md files named in git log -z --name-status output: only the guard decides which of them the push added, so every path of that shape is sent (at most MAX_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_push with 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 sha is once the annotated tags around it are peeled: the message of those tags, joined in order (None when sha is no tag object), and the type of what is left (commit, blob, tree, or tag for 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); None for 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 object line of git cat-file tag output.

Type Aliases§

Git
Runs git with these arguments in the current directory: its stdout, or what failed.