Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/git/vole.git

Write over SSH with a registered key:

git clone ssh://git@0.0.0.0:2222/vole.git

A free and open-source forge that lives in your Git repo.

One trust model: attribution at the boundary, and a log of what it decided

f50f6fabc7de2f2d33d22a4f2a8e5518ddb5becb · Keenan Nemetz · 16d ago · parent 671f2aa7

One trust model: attribution at the boundary, and a log of what it decided

The system had two answers to "who did this". Runner results were attributed
by a commit signature; issues, comments, approvals and every push were
attributed by the account the SSH handshake resolved. One was cryptographic
and lived in the object, three were boundary-based and lived in the
instance's word.

Keeping both meant keeping allowed_signers generation, ssh-keygen
-Y find-principals semantics, a --key contract in the runner, a pre-flight key
check before every build, a key column in the queue, and the standing
obligation to keep all of it agreeing with the mechanism used everywhere
else. The signature lost on three counts: it restated the handshake (a runner
signs with the key it already pushes with, so the only thing it added was
portability nobody consumes), it proved attribution rather than truth (a
runner can sign a lie), and an assurance mechanism nobody verifies is a
liability, because it looks like security.

So the signature is gone, and what replaced it is the thing a trust-the-box
model actually requires: a record. post-receive now writes one line per
accepted ref update — ref, old, new, account, repo — into the same
append-only log as the privileged acts. In post-receive rather than
pre-receive because pre-receive returning 0 is a permission and this is the
event, and it can never fail a push: the update has already landed, and
reporting it as rejected would make a client re-send something that worked.

Attribution is unchanged in substance — a record must still name the account
that pushed it, which is the rule an issue's author and an approval's owner
already follow — and the gate's three checks simplify to two, since "the
commit must be signed by that account's key" and "the signature's principal
must be that account" both went with the signature. What was a signed record
is now a plain commit on the metadata branch; the run page says "reported by"
and links the commit that carries it.

Deletions, net 467 lines: CommitFilesSigned and CommitTreeAsSigned collapse
into the unsigned forms, VerifyCommitSignature and signedByRE go,
allowedSigners/rosterKeys go with them, the runner loses loadSigningKey,
loadPrivateKey, publicKeyFile, keyFromSSHCommand and checkSigningKey along
with the --key flag and the ping round-trip that validated a key before work,
and Record.Key, Attestation.Fingerprint and their usage go from the record
format and the queue.

The docs now state the model once, in one place — README "The trust model"
and roadmap "The trust model" — including the cost, which is real: a clone
can no longer show who pushed what, and that is the wrong trade for an
instance mirrored outside its operator's control. If that arrives, the answer
is per-repository mandatory signing implemented once, not a second mechanism
kept warm in the meantime. Slices 4 and 6 of Phase 4 are marked removed with
their reasoning kept, because the proposal will come back.

Measured: TestPostReceiveRecordsThePush (both ref updates logged with actor
and account, a deletion logged as "-> none", the CI spool still written) and
TestPostReceiveSurvivesAnUnwritableLog (a full disk cannot fail a push);
TestARecordCannotBeAttributedToAnotherAccount and TestARecordNeedsNoSignature
replace the three signature tests; TestARecordMustDescribeTheLeasedJob stays,
because "the record must describe the job you were given" is a boundary check
and not a crypto one.

internal/hook/hook_test.go +79

@@ -2,6 +2,8 @@ package hook
2 2
3 3 import (
4 4 "bytes"
5 "io"
6 "os"
5 7 "path/filepath"
6 8 "strings"
7 9 "testing"
@@ -10,6 +12,7 @@ import (
10 12 "github.com/rodent-software/vole/internal/acl"
11 13 "github.com/rodent-software/vole/internal/gitx"
12 14 "github.com/rodent-software/vole/internal/repo"
15 "github.com/rodent-software/vole/internal/runs"
13 16 )
14 17
15 18 type fixture struct {
@@ -194,3 +197,79 @@ func TestArbitraryRefsRejected(t *testing.T) {
194 197 }
195 198 }
196 199 }
200
201 // The push log is the audit trail for an ordinary push: attribution is the boundary's, so
202 // what the instance owes a reader is a record of what it decided. One line per accepted
203 // ref update, in the same log as the privileged acts.
204 func TestPostReceiveRecordsThePush(t *testing.T) {
205 t.Parallel()
206 dir := t.TempDir()
207 repoDir := filepath.Join(dir, "demo.git")
208 if err := gitx.InitBare(repoDir, "main"); err != nil {
209 t.Fatal(err)
210 }
211 audit := filepath.Join(dir, "audit.log")
212 var out bytes.Buffer
213 code := PostReceive(Config{
214 Actor: "keenan",
215 ActorID: "01ACCOUNT",
216 AuditPath: audit,
217 SpoolDir: filepath.Join(dir, "spool"),
218 RepoDir: repoDir,
219 In: strings.NewReader(
220 "0000000000000000000000000000000000000000 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa refs/heads/main\n" +
221 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0000000000000000000000000000000000000000 refs/heads/gone\n"),
222 Out: &out,
223 })
224 if code != 0 {
225 t.Fatalf("post-receive exited %d: %s", code, out.String())
226 }
227 line, err := os.ReadFile(audit)
228 if err != nil {
229 t.Fatal(err)
230 }
231 got := string(line)
232 for _, want := range []string{
233 "push refs/heads/main none -> ", "by keenan (01ACCOUNT) in demo",
234 "push refs/heads/gone ", "-> none",
235 } {
236 if !strings.Contains(got, want) {
237 t.Fatalf("the push log is missing %q:\n%s", want, got)
238 }
239 }
240 if n := strings.Count(got, "push "); n != 2 {
241 t.Fatalf("%d push lines for two ref updates:\n%s", n, got)
242 }
243 // The CI spool is still written, and a push with no spool is still recorded.
244 if entries, err := runs.Next(filepath.Join(dir, "spool")); err != nil || len(entries) != 2 {
245 t.Fatalf("spool = %d entries, err %v", len(entries), err)
246 }
247 code = PostReceive(Config{
248 Actor: "keenan", AuditPath: audit, RepoDir: repoDir,
249 In: strings.NewReader("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb refs/heads/main\n"),
250 Out: &out,
251 })
252 if code != 0 {
253 t.Fatalf("a push with no spool dir exited %d", code)
254 }
255 }
256
257 // A push log that cannot be written must not fail the push: the update already landed, and
258 // reporting it as rejected would make the client re-send something that worked.
259 func TestPostReceiveSurvivesAnUnwritableLog(t *testing.T) {
260 t.Parallel()
261 dir := t.TempDir()
262 repoDir := filepath.Join(dir, "demo.git")
263 if err := gitx.InitBare(repoDir, "main"); err != nil {
264 t.Fatal(err)
265 }
266 code := PostReceive(Config{
267 Actor: "keenan", AuditPath: filepath.Join(dir, "no", "such", "dir", "audit.log"),
268 RepoDir: repoDir,
269 In: strings.NewReader("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb refs/heads/main\n"),
270 Out: io.Discard,
271 })
272 if code != 0 {
273 t.Fatalf("an unwritable audit log failed the push (exit %d)", code)
274 }
275 }