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/gitx/gitx.go +4−51

@@ -10,7 +10,6 @@ import (
10 10 "io"
11 11 "os"
12 12 "os/exec"
13 "regexp"
14 13 "sort"
15 14 "strconv"
16 15 "strings"
@@ -18,12 +17,6 @@ import (
18 17
19 18 const ZeroSHA = "0000000000000000000000000000000000000000"
20 19
21 // signedByRE reads `git verify-commit`'s success line, which is the only place it
22 // says which principal and key answered for a signature:
23 //
24 // Good "git" signature for keenan with ED25519 key SHA256:abc…
25 var signedByRE = regexp.MustCompile(`Good ".*" signature for (\S+) with \S+ key (\S+)`)
26
27 20 // Entry is one record from `git ls-tree` or one line of `git mktree` input.
28 21 type Entry struct {
29 22 Mode string
@@ -269,30 +262,11 @@ func (r *Repo) HashObject(payload []byte) (string, error) {
269 262 // CommitTreeAs commits with a specific author, which is the audit record for a
270 263 // metadata change.
271 264 func (r *Repo) CommitTreeAs(tree, parent, msg, author string) (string, error) {
272 return r.commitTree(tree, parent, msg, author, "")
265 return r.commitTree(tree, parent, msg, author)
273 266 }
274 267
275 // CommitTreeAsSigned is CommitTreeAs with an SSH signature: git writes it into the
276 // commit object's gpgsig header, made with signingKey (an OpenSSH *public* key file;
277 // the private half has to be where ssh-keygen finds it).
278 //
279 // The commit then *is* the attestation. Its signature covers the tree — every file of
280 // the record — the parents and the message, so one signature carries a run's result
281 // and the artifacts it published, with no second claim to keep in step. `pre-receive`
282 // verifies it against the roster, so nothing else has to know what a claim was.
283 func (r *Repo) CommitTreeAsSigned(tree, parent, msg, author, signingKey string) (string, error) {
284 return r.commitTree(tree, parent, msg, author, signingKey)
285 }
286
287 func (r *Repo) commitTree(tree, parent, msg, author, signingKey string) (string, error) {
288 args := []string{}
289 if signingKey != "" {
290 // -c options must precede the subcommand.
291 args = append(args, "-c", "gpg.format=ssh", "-c", "user.signingkey="+signingKey,
292 "commit-tree", "-S", tree)
293 } else {
294 args = append(args, "commit-tree", tree)
295 }
268 func (r *Repo) commitTree(tree, parent, msg, author string) (string, error) {
269 args := []string{"commit-tree", tree}
296 270 if parent != "" {
297 271 args = append(args, "-p", parent)
298 272 }
@@ -311,28 +285,7 @@ func (r *Repo) commitTree(tree, parent, msg, author, signingKey string) (string,
311 285 }
312 286
313 287 func (r *Repo) CommitTree(tree, parent, msg string) (string, error) {
314 return r.commitTree(tree, parent, msg, "", "")
315 }
316
317 // VerifyCommitSignature checks an SSH-signed commit against an allowed-signers file
318 // and returns the principal the file matched and the fingerprint of the signing key.
319 // An unsigned commit, or one signed by a key the file does not list, is an error
320 // carrying git's own explanation.
321 func (r *Repo) VerifyCommitSignature(commit, allowedSigners string) (principal, fingerprint string, err error) {
322 out, errs, runErr := r.run(nil, "-c", "gpg.format=ssh",
323 "-c", "gpg.ssh.allowedSignersFile="+allowedSigners, "verify-commit", commit)
324 text := strings.TrimSpace(string(out) + string(errs))
325 if runErr != nil {
326 if text == "" {
327 text = "not signed (git verify-commit said nothing, which is what an unsigned commit looks like)"
328 }
329 return "", "", fmt.Errorf("%s", text)
330 }
331 // Good "git" signature for <principal> with ED25519 key SHA256:<fp>
332 if m := signedByRE.FindStringSubmatch(text); m != nil {
333 return m[1], m[2], nil
334 }
335 return "", "", fmt.Errorf("%s", text)
288 return r.commitTree(tree, parent, msg, "")
336 289 }
337 290
338 291 // LastTouchedByPath reports, for every path under dir reachable from rev, the newest