Documentation
¶
Overview ¶
Package buildrecord signs and verifies the record the control plane keeps for an image a remote builder produced, so a runner can trust what it deploys.
Index ¶
- Constants
- Variables
- func Verify(pub ed25519.PublicKey, r Signed) error
- type Claims
- type DBStore
- func (s DBStore) GetRecord(ctx context.Context, id string) (Signed, error)
- func (s DBStore) LinkAttempt(ctx context.Context, id, attemptID string) error
- func (s DBStore) RecordByDigest(ctx context.Context, digest string) (string, Signed, error)
- func (s DBStore) RecordByRepo(ctx context.Context, repo string) (string, Signed, error)
- func (s DBStore) SaveRecord(ctx context.Context, id, app string, r Signed) error
- type Gate
- type ImageStore
- type KeyStore
- type Policy
- type Signed
- type Signer
- type Store
Constants ¶
const ( TierServer = "server" TierManaged = "managed" TierPersonal = "personal" )
Builder tiers, mirroring the node trust tiers.
Variables ¶
var ErrBadSignature = errors.New("buildrecord: signature does not verify")
ErrBadSignature means the record was altered or signed by another key.
var ErrNoRecord = errors.New("build record: none for this image")
ErrNoRecord means no signed record exists for the image.
Functions ¶
Types ¶
type Claims ¶
type Claims struct {
App string `json:"app"`
Environment string `json:"environment"`
Repo string `json:"repo"`
Digest string `json:"digest"`
BuilderNodeID string `json:"builder_node_id"`
BuilderTrust string `json:"builder_trust"`
SourceRef string `json:"source_ref"`
IssuedAt time.Time `json:"issued_at"`
Nonce string `json:"nonce"`
}
Claims is the signed content. Field order is part of the format.
type DBStore ¶
DBStore adapts the store rows to Store and ImageStore.
func (DBStore) LinkAttempt ¶
LinkAttempt ties a record to a deploy attempt.
func (DBStore) RecordByDigest ¶
RecordByDigest finds the newest record of a digest.
func (DBStore) RecordByRepo ¶
RecordByRepo finds the newest record of an exact image reference.
type Gate ¶
type Gate struct {
Signer *Signer
Store Store
Policy func(ctx context.Context, app string) (Policy, error)
}
Gate refuses to deploy an image whose builder the environment does not allow or whose personal-tier record does not verify.
type ImageStore ¶
type ImageStore interface {
RecordByDigest(ctx context.Context, digest string) (string, Signed, error)
RecordByRepo(ctx context.Context, repo string) (string, Signed, error)
}
ImageStore finds the record of an image about to be deployed.
type KeyStore ¶
type KeyStore interface {
Resolve(ctx context.Context, serviceName, envKey string) (string, error)
SetValue(ctx context.Context, serviceName, envKey, plaintext string) error
}
KeyStore is the slice of the secrets manager the signing key needs.
type Policy ¶
type Policy struct {
EnvKind string
// EnvName is the environment the claim's environment is compared with, when known.
EnvName string
// Allowed is the explicit allow-list of tiers or node IDs; it decides alone when set.
Allowed []string
PersonalInProd bool
}
Policy is what an environment says about who may build for it.
func (Policy) TierAllowed ¶
TierAllowed reports whether a builder of this tier or node may produce images for the environment.
type Signed ¶
type Signed struct {
Claims Claims `json:"claims"`
Signature string `json:"signature"`
KeyID string `json:"key_id"`
}
Signed is Claims plus the control plane signature and the id of the key used.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer signs build records with the control plane ed25519 key.
func LoadOrCreateSigner ¶
LoadOrCreateSigner reads the key from the secrets store, generating it on first use. The seed is stored encrypted and never logged.
func NewSigner ¶
func NewSigner(priv ed25519.PrivateKey) *Signer
NewSigner wraps an ed25519 private key.