summaryrefslogtreecommitdiffstats
path: root/README
diff options
context:
space:
mode:
authordev <dev@example>2026-11-15 12:10:23 +0000
committerdev <dev@example>2026-11-15 12:10:23 +0000
commit85b7fa7f8456c84f65a0d81b760c430098ae7fd8 (patch)
treed941ae68672ff71d2181fcb1a0e168f9314f135c /README
parent2e6dd4a8e9e5302efae6b7532f7f4609882fc21d (diff)
downloadaccess-control-85b7fa7f8456c84f65a0d81b760c430098ae7fd8.tar.gz
access-control-85b7fa7f8456c84f65a0d81b760c430098ae7fd8.zip
Denials to the pusher: one line, and the reason moved to check
The person pushing used to get a sentence about a file they cannot read: deny: bob holds write on team, but not on refs/heads/main; that ref needs write It is true, and it is not theirs. The level they hold, the level the ref costs and why are all facts about somebody else's configuration, and quoting them at a terminal sends a colleague to a file that is not theirs to edit while telling a monitor nothing the exit status did not. A refusal is now one line naming the input it refused: git-authz: permission denied [user=bob, obj=refs/heads/main] git-authz: permission denied [obj=refs/heads/main] # no identity and `check` is where whoever owns the policy reads the reason out, unchanged. `authorize --explain` prints the same sentence in the hook's own seat, for the operator who is already standing there. The other two denials got the same treatment and a reclassification: invalid policy file exit 3, for an unreadable policy and an unparsable one alike - no path, no line number, no errno invalid operation exit 3, was 1, for a stdin line that is not an update: not three fields, not object ids, not a ref under refs/ Exit 3 now means "the host is broken, not this person" and covers both, which is what the split was always for: no real git writes those lines, so a hook that rejects one has a pipe, a wrapper or a debugging session behind it, not a pusher. Nothing about enforcement changed - a non-zero pre-receive exit stops the push either way - only which status it is and what the line says. To keep the pusher's output to one line, policy_load writes its findings to p->log, stderr by default and NULL for the hook and for authorize mode: the mode is the audience, not the name it was reached by. check and validate still print line numbers and errno, so nothing an operator needs has gone missing. src/ and cmd/ are 1,488 non-blank lines. make strict, make test and make sanitizer are clean - 128 assertions, up from 113, now pinning the exact terse line, that a denial is one line, that no policy prose leaks to the pusher, and that nothing of a rejected line is echoed back.
Diffstat (limited to 'README')
-rw-r--r--README44
1 files changed, 33 insertions, 11 deletions
diff --git a/README b/README
index 1f6eb30..eee46fa 100644
--- a/README
+++ b/README
@@ -28,14 +28,17 @@ git invokes. `validate` asks whether the policy is one the hook can use.
Exit status is the interface, and it does not change:
0 allowed
- 1 denied
- 3 no usable policy - the host is broken, not this person
+ 1 denied - this person may not
+ 3 the host is broken, not this person
64 usage error
-Three is separate from one on purpose. A push refused because the policy file
-was not mounted produces one line in a log somewhere; a push refused because the
-user is not allowed produces a message to a colleague. They must not sound the
-same, and a monitor must not have to parse prose to tell them apart.
+Three is separate from one on purpose, and it covers two different breakages: a
+policy the hook cannot use says `invalid policy file`, and a hook handed
+something that is not a push - which no real git ever does - says `invalid
+operation`. A push refused because the person is not allowed is theirs, and says
+`permission denied` with the name they came as and the ref they were refused.
+They must not sound the same, and a monitor must not have to parse prose to tell
+them apart - which is also why each of them is one line.
The policy
@@ -167,25 +170,44 @@ Warnings do not stop it; errors do, and `--strict` makes warnings stop it too.
Reading this as an operator
---------------------------
+A refused push says one line, and it says only the input it refused:
+
+ git-authz: permission denied [user=bob, obj=refs/heads/main]
+
+That is the whole of what the person pushing is told, on purpose: the reason is
+a sentence about a file they cannot read, and quoting it at them sends them to
+somebody else's configuration. The reason is here instead:
+
who may write to team?
git-authz check bob team write refs/heads/feature/login
- why was my push refused?
+ why was that push refused?
- Because the message ends with what it would have taken:
+ git-authz check bob team write refs/heads/main
deny: bob holds write on team, but not on refs/heads/main;
that ref needs write
or, when the ref is covered by a rule but costs more than it looks:
+ git-authz check bob team write refs/notes/x
+
deny: bob has write on team refs/notes/x; it needs admin
(neither a branch nor a tag)
- which is the whole design in one line: a refusal that names the level held,
- the ref, the level required and why, so the fix is obvious to the person who
- hit it instead of a ticket to whoever set this up.
+ which is the whole design in two lines: the refusal names who and what, the
+ answer names the level held, the ref, the level required and why, so the fix
+ is obvious to whoever owns the policy and the person who hit it is not left
+ guessing either.
+
+`authorize --explain` prints that sentence in the hook's own seat, for when the
+operator is the one standing there. A policy the hook cannot use says `invalid
+policy file` and nothing else at exit 3; `validate` is what says what is wrong
+with it, with the line numbers. Exit 3 has one other cause: `invalid operation`,
+for a hook handed a line that is not an update - three fields, two object ids and
+a ref under `refs/`. No git writes that, so it is the pipe, the wrapper or
+whoever was debugging, and never the person pushing.
Layout