diff options
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 |
