diff options
| author | dev <dev@example> | 2026-11-15 11:28:47 +0000 |
|---|---|---|
| committer | dev <dev@example> | 2026-11-15 11:28:47 +0000 |
| commit | c2b95afc6aefbab69133a202cab95a50a2df82fc (patch) | |
| tree | 4788b1b9302ef77b244c4107de2f3da15982f303 /README | |
| parent | 5a9afae082f36812a2e7c9e61d8662628b798f41 (diff) | |
| download | access-control-c2b95afc6aefbab69133a202cab95a50a2df82fc.tar.gz access-control-c2b95afc6aefbab69133a202cab95a50a2df82fc.zip | |
Drop grant/revoke and validate's host-wiring checks
Two features out, to answer a size target: src/ and cmd/ go from 2,306
non-blank lines to 1,495.
`grant` and `revoke` were a convenience wrapper over a file that is a
read-only mount in production by design, so they sat outside the
enforcement path. src/edit.c is gone; both names now report an unknown
command with exit 64.
`validate` keeps the policy checks - parse errors with their line
numbers, an unreadable policy, the @all-whole-repo and not-readable-by-
the-git-account warnings - and stops cross-checking the machine around
it. The repository cross-check, hook/hooksPath, sshd, the git account's
shell and the key/htpasswd identity checks are deleted, along with
--root, --hook-dir, --gitconfig, --sshd-config, --passwd, --keys,
--htpasswd and --no-host; plain `validate` is what `validate --no-host`
used to be. The container's build gate and the test suite are updated to
match, since both called the removed flag.
Orphaned by the removals and deleted with them: authz_repo_reachable,
and authz_rule_validate's ref_ok parameter, which existed only so grant
could interleave its own ref-pattern test.
Surviving behaviour is unchanged. A 1,370-invocation differential run
against the pre-removal binary - the check matrix, every authorize path,
the hook reached through its own name, fake-git ancestry and HEAD,
policy-only validate, the failure modes - differs only in the usage text
that documented the removed surface. make strict, make test and
make sanitizer are all clean, with ASan and UBSan silent.
Also folded in from the same effort, since it touched the same files:
authz_rule_validate as the single grammar, rule_covers() as the single
answer for rule/ref coverage, vmsgv() behind the validate message tags,
one kv reader for gitconfig and sshd_config while both were still there,
and `sanitizer:` in the Makefile appending to CFLAGS rather than
replacing it.
Diffstat (limited to 'README')
| -rw-r--r-- | README | 54 |
1 files changed, 10 insertions, 44 deletions
@@ -21,12 +21,9 @@ Commands git-authz [--policy PATH] check <user> <repo> <write|force|admin> [ref] git-authz [--policy PATH] authorize [options] git-authz [--policy PATH] validate [options] - git-authz [--policy PATH] grant <user> <repo> <level> [ref ...] - git-authz [--policy PATH] revoke <user> <repo> `check` answers one question and is for humans and scripts. `authorize` is what -git invokes. `validate` asks whether the host is wired to run the policy at all. -The last two edit the file. +git invokes. `validate` asks whether the policy is one the hook can use. Exit status is the interface, and it does not change: @@ -159,41 +156,12 @@ Wiring git-authz validate || exit 1 -It reports a policy that does not parse, a policy no user can push to any -repository with, a repository nobody can push to, a missing or non-executable -hook, a `core.hooksPath` pointing somewhere else, `PermitUserEnvironment no`, no -`ForceCommand`, a `git` account with a real shell, key identities with no rule, -and htpasswd users with no rule. Warnings do not stop it; errors do, and -`--strict` makes warnings stop it too. `--no-host` checks the policy without -looking at the machine, which is what you want from CI on a checkout. - -The point of that last set of checks is the failure mode where the policy is -fine, the server is up, and every push is anonymous - because ssh was not told to -accept environment variables, or the hook path moved, and nothing said so. - - -Editing the file ----------------- - - git-authz grant bob team write refs/heads/feature/* - git-authz revoke bob team - -Each writes the file atomically - a temporary in the same directory, then a -rename, keeping the mode and owner - and preserves everything else in the file, -comments and blank lines included, so a grant does not undo the ordering an -operator laid out. `grant` collapses several rules for the same user and -repository into one line, in the place of the first, because the strongest wins -and a second rule that does nothing is a trap for the next reader. - -A file that does not exist yet is started, with the grammar written at the top of -it; a file that does not parse is refused, because editing something the parser -cannot read would rewrite the parts that parse and keep the damage. - -The deployed file is a read-only mount - a ConfigMap - by design: the hook should -not be able to change who can push, and neither should whatever else runs as uid -1000. These commands are for the copy in git. Pointed at a read-only file they -fail with that explanation rather than writing somewhere surprising, and `--out` -or `--stdout` writes the result elsewhere without touching the input. +It reports a policy that does not parse, with the line numbers the parser already +printed, and a policy that cannot be read at all. Either one denies every push, +which is why both are errors and not warnings: nothing is allowed on a policy +the hook cannot read. It warns when a rule gives `@all` the whole of a +repository, and when the file is not readable by the account the hook runs as. +Warnings do not stop it; errors do, and `--strict` makes warnings stop it too. Reading this as an operator @@ -231,11 +199,10 @@ Layout ci/ the pipeline src/glob.c the pattern matching, such as it is - src/util.c allocation, string buffers, writing a file atomically + src/util.c allocation, string buffers, reading a file src/policy.c reading the file, and answering from it src/hook.c the mode git calls, and the only one a push depends on - src/validate.c does this policy, and the host around it, add up - src/edit.c grant and revoke, without losing the file + src/validate.c does this policy add up Everything compiles into `obj/`, test runners included, so a build leaves the tree as it found it apart from the binary. `git-authz` is one program rather @@ -254,8 +221,7 @@ ladder, `@all`, scope, the sentences - and are where the semantics are pinned. the environment, `old new ref` lines on stdin, the repository as the working directory, the hook reached through its own name. It uses no git at all, so it runs anywhere a compiler does, and it tests the real binary rather than a model -of it: argument parsing, exit codes, messages, and the editing commands writing -files. +of it: argument parsing, exit codes, and messages. Two facts do not come out of the line git passes, and the hook asks git for them: which branch `HEAD` is, and whether `old` is an ancestor of `new`. Those |
