<feed xmlns='http://www.w3.org/2005/Atom'>
<title>access-control/test, branch ai/test-branch</title>
<subtitle>Unnamed repository
</subtitle>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/'/>
<entry>
<title>Denials to the pusher: one line, and the reason moved to check</title>
<updated>2026-11-15T12:10:23+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-15T12:10:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=85b7fa7f8456c84f65a0d81b760c430098ae7fd8'/>
<id>85b7fa7f8456c84f65a0d81b760c430098ae7fd8</id>
<content type='text'>
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-&gt;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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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-&gt;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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Drop grant/revoke and validate's host-wiring checks</title>
<updated>2026-11-15T11:28:47+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-15T11:28:47+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=c2b95afc6aefbab69133a202cab95a50a2df82fc'/>
<id>c2b95afc6aefbab69133a202cab95a50a2df82fc</id>
<content type='text'>
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.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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.
</pre>
</div>
</content>
</entry>
<entry>
<title>Nine bugs the suite did not reach, and a test for each</title>
<updated>2026-11-14T11:16:29+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-14T11:16:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=a2a702cb81eaf73a8989cc31c682592c8acb769a'/>
<id>a2a702cb81eaf73a8989cc31c682592c8acb769a</id>
<content type='text'>
Every one was found by reading a module against what the program promises, or by
driving the built binary with input the suite never sends. None of them was
visible from a green run: the run was already green.

Two are validate saying "ok" about a machine that is wide open:

  ForceCommand none   is how a Match block turns a forced command back off. It
                      is the same state as having none at all, which is the
                      state this check exists to catch.
  sshd directives     sshd keeps the first value it reads for a keyword, not the
                      last. "PermitUserEnvironment no" with a later "yes" read
                      as yes, and every push arrives anonymous.

One is a grant that grants more than was typed. A ref argument went into the
file verbatim, so

  grant x team write 'refs/heads/a b'

landed as "x team write refs/heads/a b", which reads back as two patterns and
quietly grants refs/heads/b as well. A '#' argument was cut short at the comment
marker, and a newline argument wrote a file that no longer parses - which denies
every push there is. An argument that is not one field is refused now.

authorize did not accept the options its own usage text prints. The help says
"--user U" and "--ff auto|yes|no"; the parser took only --user=U, so the
documented spelling came back "unknown argument" while validate accepted both
forms. Both work now, and an option with no value says so.

Three are the boundary and status distinctions the exit codes are made of. A
rule with exactly MAX_FIELDS fields was refused as "too many", and a file that
does not parse denies every push. A directory passed as the policy read as a
policy that happens to be empty, so every push answered 1, person not allowed,
where the host is broken and the answer has to be 3. A gitconfig section name
was matched case-sensitively, so [CORE] reported a broken host that is not
broken; git folds section names without regard to case.

Two are smaller. "appended as line N" was printed when the pair's rule was the
last line and had been replaced rather than appended. And the Makefile tracked
no header dependencies, so editing src/authz.h rebuilt nothing and make test
passed against a binary that was not the code on disk.

Each fix went in as a failing test first, so the suite goes from 162 cases to
176 and no existing test was changed. Clean under -Werror and clean under
ASan/UBSan.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Every one was found by reading a module against what the program promises, or by
driving the built binary with input the suite never sends. None of them was
visible from a green run: the run was already green.

Two are validate saying "ok" about a machine that is wide open:

  ForceCommand none   is how a Match block turns a forced command back off. It
                      is the same state as having none at all, which is the
                      state this check exists to catch.
  sshd directives     sshd keeps the first value it reads for a keyword, not the
                      last. "PermitUserEnvironment no" with a later "yes" read
                      as yes, and every push arrives anonymous.

One is a grant that grants more than was typed. A ref argument went into the
file verbatim, so

  grant x team write 'refs/heads/a b'

landed as "x team write refs/heads/a b", which reads back as two patterns and
quietly grants refs/heads/b as well. A '#' argument was cut short at the comment
marker, and a newline argument wrote a file that no longer parses - which denies
every push there is. An argument that is not one field is refused now.

authorize did not accept the options its own usage text prints. The help says
"--user U" and "--ff auto|yes|no"; the parser took only --user=U, so the
documented spelling came back "unknown argument" while validate accepted both
forms. Both work now, and an option with no value says so.

Three are the boundary and status distinctions the exit codes are made of. A
rule with exactly MAX_FIELDS fields was refused as "too many", and a file that
does not parse denies every push. A directory passed as the policy read as a
policy that happens to be empty, so every push answered 1, person not allowed,
where the host is broken and the answer has to be 3. A gitconfig section name
was matched case-sensitively, so [CORE] reported a broken host that is not
broken; git folds section names without regard to case.

Two are smaller. "appended as line N" was printed when the pair's rule was the
last line and had been replaced rather than appended. And the Makefile tracked
no header dependencies, so editing src/authz.h rebuilt nothing and make test
passed against a binary that was not the code on disk.

Each fix went in as a failing test first, so the suite goes from 162 cases to
176 and no existing test was changed. Clean under -Werror and clean under
ASan/UBSan.
</pre>
</div>
</content>
</entry>
<entry>
<title>Comments: cut to what the code cannot say</title>
<updated>2026-11-14T01:05:08+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-14T01:05:08+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=312ddd4936f09ae27a180ca495cacf2c06faf33e'/>
<id>312ddd4936f09ae27a180ca495cacf2c06faf33e</id>
<content type='text'>
The comments had grown into essays.  A file header explaining why the file
exists, then a paragraph above each function restating what the next eight
lines do, then a paragraph above that one explaining why that matters.  The
reader gets no further than the first paragraph, and the second is the one that
goes stale: it describes code that has since changed, and nothing fails when it
does.

Cut by about half.  What is left is the three things a comment can do that code
cannot: say why the constraint exists (no regex because a hook must not depend
on what might be missing at 3am), say what is not obvious from the shape (a
bare ref name is a branch, never a tag; the seventh field of /etc/passwd is the
shell), and say where it hurts (the NULL in an execvp array, the mode and owner
that have to survive an atomic rewrite, the child that must not keep the hook's
stdin).

Block comments became // lines, which is also what the other C trees here use,
and the file headers went to two or three lines.  Section banners stayed: they
are navigation, not prose.

Behaviour is unchanged and the suites prove it: 171 direct checks, 162
behavioural, clean under -Werror and under ASan/UBSan.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The comments had grown into essays.  A file header explaining why the file
exists, then a paragraph above each function restating what the next eight
lines do, then a paragraph above that one explaining why that matters.  The
reader gets no further than the first paragraph, and the second is the one that
goes stale: it describes code that has since changed, and nothing fails when it
does.

Cut by about half.  What is left is the three things a comment can do that code
cannot: say why the constraint exists (no regex because a hook must not depend
on what might be missing at 3am), say what is not obvious from the shape (a
bare ref name is a branch, never a tag; the seventh field of /etc/passwd is the
shell), and say where it hurts (the NULL in an execvp array, the mode and owner
that have to survive an atomic rewrite, the child that must not keep the hook's
stdin).

Block comments became // lines, which is also what the other C trees here use,
and the file headers went to two or three lines.  Section banners stayed: they
are navigation, not prose.

Behaviour is unchanged and the suites prove it: 171 direct checks, 162
behavioural, clean under -Werror and under ASan/UBSan.
</pre>
</div>
</content>
</entry>
<entry>
<title>The two git calls were missing their NULL, so every push cost one level too much</title>
<updated>2026-11-14T00:21:48+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-14T00:21:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=4dfb9a5787b1554280807aaa28687f6c1a0d2db6'/>
<id>4dfb9a5787b1554280807aaa28687f6c1a0d2db6</id>
<content type='text'>
execvp walks argv until it finds a NULL.  head_ref built a four-element array
and fast_forward a five-element one, filled every slot, and never wrote the
terminator - so the fifth and sixth entries were whatever the stack happened to
be holding, and the exec either failed or ran something that was not the
argument list anybody meant.

Both answers were load-bearing, and both failures were silent:

  symbolic-ref fails   the hook cannot tell which branch HEAD is, so it charges
                       every deletion the most: admin
  merge-base fails     the update cannot be shown to be a fast-forward, so it
                       costs force

Together that meant a user with write could create a branch and then never
update it, and nobody but an admin could delete anything - with the refusal
pointing at the policy, which was fine, and at a level the user did not hold,
which looked deliberate.  It was not.  It was the shape of a C array.

Fixed by writing the arrays out with their NULL visible, and commented, because
the compiler will not catch this one: the array is big enough, the types are
right, and the bug is in the element that is not there.

The core suite could not see this, and that was the real problem - it passes
--ff and --head precisely so that it needs no git, which leaves the asking
itself untested.  So there is now a stand-in named git in the suite, and the
real one kept out of PATH: it answers symbolic-ref to order and exits merge-base
either way, which covers fast-forward and non-fast-forward, HEAD's branch and
not, and the case with no git at all, where the hook must fail toward denying
rather than toward guessing.  Eight checks, all of which failed before the fix.

The container suite caught this by being the only suite that runs the real
thing, which is worth noting for the next time someone suggests the integration
suite is the slow one that can be skipped.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
execvp walks argv until it finds a NULL.  head_ref built a four-element array
and fast_forward a five-element one, filled every slot, and never wrote the
terminator - so the fifth and sixth entries were whatever the stack happened to
be holding, and the exec either failed or ran something that was not the
argument list anybody meant.

Both answers were load-bearing, and both failures were silent:

  symbolic-ref fails   the hook cannot tell which branch HEAD is, so it charges
                       every deletion the most: admin
  merge-base fails     the update cannot be shown to be a fast-forward, so it
                       costs force

Together that meant a user with write could create a branch and then never
update it, and nobody but an admin could delete anything - with the refusal
pointing at the policy, which was fine, and at a level the user did not hold,
which looked deliberate.  It was not.  It was the shape of a C array.

Fixed by writing the arrays out with their NULL visible, and commented, because
the compiler will not catch this one: the array is big enough, the types are
right, and the bug is in the element that is not there.

The core suite could not see this, and that was the real problem - it passes
--ff and --head precisely so that it needs no git, which leaves the asking
itself untested.  So there is now a stand-in named git in the suite, and the
real one kept out of PATH: it answers symbolic-ref to order and exits merge-base
either way, which covers fast-forward and non-fast-forward, HEAD's branch and
not, and the case with no git at all, where the hook must fail toward denying
rather than toward guessing.  Eight checks, all of which failed before the fix.

The container suite caught this by being the only suite that runs the real
thing, which is worth noting for the next time someone suggests the integration
suite is the slow one that can be skipped.
</pre>
</div>
</content>
</entry>
<entry>
<title>Layout: cmd/, src/, test/, everything built into obj/</title>
<updated>2026-11-14T00:06:35+00:00</updated>
<author>
<name>dev</name>
<email>dev@example</email>
</author>
<published>2026-11-14T00:06:35+00:00</published>
<link rel='alternate' type='text/html' href='http://git.jnsn.dev/cgit/access-control/commit/?id=bc7f4da406fbd802b08985ba583e52f040bdba85'/>
<id>bc7f4da406fbd802b08985ba583e52f040bdba85</id>
<content type='text'>
The tree had grown sideways: main.c living among the sources it dispatches to,
one test binary covering everything, object files left in the source directory
because the Makefile put them there and, worse, tracked them.

Now the command line is cmd/main.c, the engine is src/ and nothing in it knows
about the command line, and each area of the engine has its own program under
test/ - glob, norm, parse, need, check - each linking the library and reporting
its own count.  A failure says which area broke instead of taking the whole run
down with a single "unit: 171" line, which is the only thing a per-file split
buys and it is worth the small duplication the shared test.h absorbs.

Objects go to obj/, test runners to obj/test_runner/, so a build leaves the
tree as it found it.  The stale src/*.o and tests/unit that were committed
earlier are gone; they were build output in a source tree and the .gitignore
that should have stopped them arrived after they did.

The Makefile follows the same shape as the other C trees here: directories in
variables, wildcards for the sources, one pattern rule that makes its own
directory, test runners built from the same objects as the binary so they
cannot test a different build than ships, and `test` running every runner with
a foreach so the first failure stops the line.  `strict` is `all` with -Werror,
which is what CI now calls instead of passing CFLAGS in from outside; the
sanitizer and install targets are unchanged in what they do.

Behaviour is unchanged: 171 direct checks and 154 behavioural ones, same as
before the move, and make install still stages a working hook symlink.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The tree had grown sideways: main.c living among the sources it dispatches to,
one test binary covering everything, object files left in the source directory
because the Makefile put them there and, worse, tracked them.

Now the command line is cmd/main.c, the engine is src/ and nothing in it knows
about the command line, and each area of the engine has its own program under
test/ - glob, norm, parse, need, check - each linking the library and reporting
its own count.  A failure says which area broke instead of taking the whole run
down with a single "unit: 171" line, which is the only thing a per-file split
buys and it is worth the small duplication the shared test.h absorbs.

Objects go to obj/, test runners to obj/test_runner/, so a build leaves the
tree as it found it.  The stale src/*.o and tests/unit that were committed
earlier are gone; they were build output in a source tree and the .gitignore
that should have stopped them arrived after they did.

The Makefile follows the same shape as the other C trees here: directories in
variables, wildcards for the sources, one pattern rule that makes its own
directory, test runners built from the same objects as the binary so they
cannot test a different build than ships, and `test` running every runner with
a foreach so the first failure stops the line.  `strict` is `all` with -Werror,
which is what CI now calls instead of passing CFLAGS in from outside; the
sanitizer and install targets are unchanged in what they do.

Behaviour is unchanged: 171 direct checks and 154 behavioural ones, same as
before the move, and make install still stages a working hook symlink.
</pre>
</div>
</content>
</entry>
</feed>
