diff options
| author | dev <dev@example> | 2026-11-13 22:28:22 +0000 |
|---|---|---|
| committer | dev <dev@example> | 2026-11-13 22:28:22 +0000 |
| commit | 50f296cf7609ce77d41b9fb3df51d6aeec8330d6 (patch) | |
| tree | a84e367145fa7f86f285b844144c55b3b3452cf3 /src/main.c | |
| parent | e12fc6e1c14afaab8711c6c9ac695ce911d83df5 (diff) | |
| download | access-control-50f296cf7609ce77d41b9fb3df51d6aeec8330d6.tar.gz access-control-50f296cf7609ce77d41b9fb3df51d6aeec8330d6.zip | |
Remove protected-refs: a rule covers what it names, and nothing else
`set protected-refs` raised the price of a listed ref by one level: write
needed force on main, force needed admin. It was a second, invisible list, and
it was the one part of the model that could not be read off the rules. The
question it was supposed to answer - "who can move main?" - stopped having an
answer in the file: you had to hold both the rules and the protection list in
your head and combine them, and the combination was where surprises lived.
Giving someone force so they could rewrite their own branches quietly let them
fast-forward main, because a fast-forward costs write, protection raised it to
force, and there it was.
Now a rule says what it says. An unscoped rule covers main; a rule that means
to leave main alone names what it covers instead, and the refusal says "bob
holds write on team, but not on refs/heads/main" rather than blaming a list
nobody remembered. Excluding one person from one branch is a matter of what
their lines name, which is the same mechanism as everything else here.
The setting is refused by name rather than ignored. A policy that still carries
one would otherwise mean "everyone with write can fast-forward main" while
looking like it said the opposite, and the operator would learn that from a push
rather than from the parser; so `set protected-refs` is now an error that says
what to write instead, and the suite asserts both halves - that it is refused,
and that cleaning it out makes the file valid again.
What stays: refs outside refs/heads and refs/tags still need admin whatever a
rule appears to grant about them. That one the policy genuinely cannot name in
advance, because it is the part of the namespace no policy was written with in
mind.
`protect` goes with it, so the editing commands are grant and revoke. The
example policy now names frank, whose two refs are main and the release tags,
because that is the shape the file is now meant to be written in.
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -3,7 +3,7 @@ * check an operator asking, or a script * authorize git asking, once per push (also reached as 'pre-receive') * validate the entrypoint and CI asking before anything is served - * edit changing the file (grant, revoke, protect) + * edit changing the file (grant, revoke) * * They are one program because they must agree, exactly, about what a rule * means: a check that answers differently from the hook is worse than two @@ -58,14 +58,14 @@ static void usage(FILE *f) "\n" " grant <user> <repo> <level> [ref ...] add one rule, or replace that pair's\n" " revoke <user> <repo> take it away again\n" -" protect [--repo R] <ref pattern> ... set which refs need an extra level\n" " --out FILE | --stdout write elsewhere instead of in place\n" " The deployed policy is a read-only mount on purpose; these are for the\n" " source copy, and they say so when they are pointed at a read-only file.\n" "\n" "Levels are monotone: admin implies force implies write. '@all' means everyone\n" "the policy already names. \"main\", \"heads/main\" and \"refs/heads/main\" are the\n" -"same branch; a bare name is always a branch and never a tag.\n" +"same branch; a bare name is always a branch and never a tag. A rule says what\n" +"it says: nothing else in the file can raise the price of a ref.\n" "\n" "Exit status: 0 allowed, 1 denied, 3 the policy could not be read or does not\n" "parse - nothing is allowed on a policy that cannot be read - and 64 for usage.\n", @@ -274,8 +274,7 @@ int main(int argc, char **argv) /* The three commands that change the file. They read it themselves, and * they must not disagree with the checker about what a rule means, which is * why they are in the same binary. */ - if (strcmp(cmd, "grant") == 0 || strcmp(cmd, "revoke") == 0 || - strcmp(cmd, "protect") == 0) { + if (strcmp(cmd, "grant") == 0 || strcmp(cmd, "revoke") == 0) { int consumed = 0; if (authz_parse_out(argc, argv, &eo, &consumed) != 0) @@ -283,9 +282,7 @@ int main(int argc, char **argv) argc -= consumed; /* what is left was compacted to the front */ if (strcmp(cmd, "grant") == 0) return cmd_grant(path, eo, argc, argv); - if (strcmp(cmd, "revoke") == 0) - return cmd_revoke(path, eo, argc, argv); - return cmd_protect(path, eo, argc, argv); + return cmd_revoke(path, eo, argc, argv); } policy_init(&p, path); |
