Standing approvals: always allow for this repository (v0.16.0) #19

Merged
mnovak merged 1 commits from feature/standing-approval into main 2026-11-11 16:13:06 +01:00
Owner

Standing approvals for signing keys: "always allow this, for this repository" (asked for by Mark on 2026-11-11; the app side is Custos docs/15_standing_approvals.md).

What

  • signing.standing: rules of repository + key (id and created) + kind + pipeline + origin (local / remote), and for an approval the targets it was granted for. Compared exactly, no wildcards.
  • standing_can_grant, standing_grant, standing_rule_for, standing_rules, standing_revoke.
  • signing_sign(req, Approval::Standing, now): signs only when a rule fits, records the new outcome standing, counts the use (uses, lastUsed).
  • Security audit actions standing-granted, standing-revoked (written only by grant and revoke; security_note refuses them).
  • Docs first: docs/SIGNING.md ("Standing approvals", the audit table, compatibility, the API), docs/FORMAT.md (values older cores refuse). Version 0.16.0.

Never covered by a rule: another repository, key, kind, pipeline or origin; a request out of the key's scope (and a scope narrowed later stops the rule); a request without a run; a key's first signature; an approval target the rule was not granted for; a release signature asked through the mailbox; anything while card-signing is ticked.

Tests

Workspace: 240 passed, 0 failed (cargo test --workspace --release). New: tests/standing.rs 12, unit 3 (a_key_made_again_under_the_same_id_does_not_inherit_the_rule, an_older_reader_refuses_a_vault_in_which_a_standing_approval_was_granted, a_broken_standing_approval_makes_the_vault_refuse_to_open), and mandatory test 2 (no_api_path_returns_a_private_key) now also drives grant, Approval::Standing and the rule list.

First red: 10 of the 12 integration tests failed against stubs (standing_can_grant refusing, standing_rule_for returning none). The other two (a_test_key_and_a_server_runners_release_signature_cannot_start_a_rule, signing_with_standing_and_no_rule_is_refused_and_recorded) assert refusals and cannot fail against a refusing stub. The three unit tests were written after the code and were not seen red.

Self-review

  1. Major, fixed before the first push of this state: standing_grant stored the rule and then validated it, and on failure removed the rule with that id, so a grant that pushed an approval rule past 64 targets would have deleted the existing rule. Now the candidate is validated first and the stored rule is untouched on failure. No test covers the 64-target limit.
  2. Minor, accepted: Approval and Outcome gained a variant: a downstream exhaustive match stops compiling (the desktop compares with ==, the web vault does not read signing).
  3. Minor, accepted: "has signed before" is read from the audit (approved or standing, at or after the key's created). The signing audit is never trimmed, so this holds; if it ever gets a limit, this rule needs its own flag on the key.
  4. Minor, accepted: the id is 64 bits of SHA-256. A collision cannot make a wrong rule fit, because every field is compared as well; it could only stop a second rule from being stored.
  5. Nit: standing_rule_for runs the full check again inside signing_sign (two checks per signature). Cheap; kept for one code path.

Not verified

  • The wasm build (custos-wasm) was not rebuilt; it does not read signing.
  • No test for 256 rules or 64 targets.
  • Nothing here was run against a real vault.
Standing approvals for signing keys: "always allow this, for this repository" (asked for by Mark on 2026-11-11; the app side is Custos `docs/15_standing_approvals.md`). ## What - `signing.standing`: rules of repository + key (id and `created`) + kind + pipeline + origin (`local` / `remote`), and for an approval the targets it was granted for. Compared exactly, no wildcards. - `standing_can_grant`, `standing_grant`, `standing_rule_for`, `standing_rules`, `standing_revoke`. - `signing_sign(req, Approval::Standing, now)`: signs only when a rule fits, records the new outcome `standing`, counts the use (`uses`, `lastUsed`). - Security audit actions `standing-granted`, `standing-revoked` (written only by grant and revoke; `security_note` refuses them). - Docs first: `docs/SIGNING.md` ("Standing approvals", the audit table, compatibility, the API), `docs/FORMAT.md` (values older cores refuse). Version 0.16.0. Never covered by a rule: another repository, key, kind, pipeline or origin; a request out of the key's scope (and a scope narrowed later stops the rule); a request without a run; a key's first signature; an approval target the rule was not granted for; a release signature asked through the mailbox; anything while `card-signing` is ticked. ## Tests Workspace: 240 passed, 0 failed (`cargo test --workspace --release`). New: `tests/standing.rs` 12, unit 3 (`a_key_made_again_under_the_same_id_does_not_inherit_the_rule`, `an_older_reader_refuses_a_vault_in_which_a_standing_approval_was_granted`, `a_broken_standing_approval_makes_the_vault_refuse_to_open`), and mandatory test 2 (`no_api_path_returns_a_private_key`) now also drives grant, `Approval::Standing` and the rule list. First red: 10 of the 12 integration tests failed against stubs (`standing_can_grant` refusing, `standing_rule_for` returning none). The other two (`a_test_key_and_a_server_runners_release_signature_cannot_start_a_rule`, `signing_with_standing_and_no_rule_is_refused_and_recorded`) assert refusals and cannot fail against a refusing stub. The three unit tests were written after the code and were not seen red. ## Self-review 1. **Major, fixed before the first push of this state:** `standing_grant` stored the rule and then validated it, and on failure removed the rule with that id, so a grant that pushed an approval rule past 64 targets would have deleted the existing rule. Now the candidate is validated first and the stored rule is untouched on failure. No test covers the 64-target limit. 2. **Minor, accepted:** `Approval` and `Outcome` gained a variant: a downstream exhaustive `match` stops compiling (the desktop compares with `==`, the web vault does not read `signing`). 3. **Minor, accepted:** "has signed before" is read from the audit (`approved` or `standing`, at or after the key's `created`). The signing audit is never trimmed, so this holds; if it ever gets a limit, this rule needs its own flag on the key. 4. **Minor, accepted:** the id is 64 bits of SHA-256. A collision cannot make a wrong rule fit, because every field is compared as well; it could only stop a second rule from being stored. 5. **Nit:** `standing_rule_for` runs the full `check` again inside `signing_sign` (two checks per signature). Cheap; kept for one code path. ## Not verified - The wasm build (`custos-wasm`) was not rebuilt; it does not read `signing`. - No test for 256 rules or 64 targets. - Nothing here was run against a real vault.
mnovak added 1 commit 2026-11-11 16:02:46 +01:00
mnovak merged commit 95613f4ed0 into main 2026-11-11 16:13:06 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/CustosPublic#19