v0.34.0 7c1886f

verifier.go RawHistoryFolder

1// SPDX-License-Identifier: AGPL-3.0-or-later
2
3// Package sigverify checks commit signatures against the trusted keys
4// (ADR 0030). It is pure Go: no gpg or ssh-keygen binary is run. SSH
5// signatures (SSHSIG, gpg.format=ssh) and OpenPGP detached signatures are
6// verified; X.509 signatures are recognized and reported as unsupported.
7//
8// Every verifier is a stateless value, safe for concurrent use, and never
9// panics on hostile input: a malformed signature is a bad_signature status.
10package sigverify
11
12import (
13	"bytes"
14
15	"bnema.dev/ermite/internal/domain"
16	"bnema.dev/ermite/internal/ports"
17)
18
19// maxSignatureBytes bounds the signature a verifier parses; a larger one is
20// reported as bad_signature without being read.
21const maxSignatureBytes = 64 << 10
22
23// Verifier dispatches a signature to the verifier of its format.
24type Verifier struct{}
25
26var _ ports.SignatureVerifier = Verifier{}
27
28// Verify implements ports.SignatureVerifier. An x509 signature is
29// unsupported; an unrecognized armor is a bad signature without format.
30func (Verifier) Verify(payload, signature []byte, committerEmail string, signedAt int64, keys []domain.TrustedKey) domain.CommitVerification {
31	switch domain.SignatureFormatOf(bytes.TrimLeft(signature, " \t\r\n")) {
32	case domain.FormatSSH:
33		return SSH{}.Verify(payload, signature, committerEmail, signedAt, keys)
34	case domain.FormatGPG:
35		return GPG{}.Verify(payload, signature, committerEmail, signedAt, keys)
36	case domain.FormatX509:
37		return domain.CommitVerification{Format: domain.FormatX509, Status: domain.StatusUnsupported}
38	}
39	return domain.CommitVerification{Format: domain.FormatNone, Status: domain.StatusBadSignature}
40}
41
42// trusted completes the verification of a signature whose cryptography is
43// valid and whose key is trusted: verified when the key may sign for the
44// committer email, email_mismatch otherwise.
45func trusted(v domain.CommitVerification, key domain.TrustedKey, committerEmail string) domain.CommitVerification {
46	v.KeyID, v.KeyTitle = key.ID, key.Title
47	if key.TrustsEmail(committerEmail) {
48		v.Status = domain.StatusVerified
49	} else {
50		v.Status = domain.StatusEmailMismatch
51	}
52	return v
53}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 45

↑↓ moveenter openesc close