buildrecord

package
v1.5.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	TierServer   = "server"
	TierManaged  = "managed"
	TierPersonal = "personal"
)

Builder tiers, mirroring the node trust tiers.

Variables

View Source
var ErrBadSignature = errors.New("buildrecord: signature does not verify")

ErrBadSignature means the record was altered or signed by another key.

View Source
var ErrNoRecord = errors.New("build record: none for this image")

ErrNoRecord means no signed record exists for the image.

Functions

func Verify

func Verify(pub ed25519.PublicKey, r Signed) error

Verify checks r against pub, failing closed on any decode problem.

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

type DBStore struct{ DB *store.DB }

DBStore adapts the store rows to Store and ImageStore.

func (DBStore) GetRecord

func (s DBStore) GetRecord(ctx context.Context, id string) (Signed, error)

GetRecord loads a record by id.

func (DBStore) LinkAttempt

func (s DBStore) LinkAttempt(ctx context.Context, id, attemptID string) error

LinkAttempt ties a record to a deploy attempt.

func (DBStore) RecordByDigest

func (s DBStore) RecordByDigest(ctx context.Context, digest string) (string, Signed, error)

RecordByDigest finds the newest record of a digest.

func (DBStore) RecordByRepo

func (s DBStore) RecordByRepo(ctx context.Context, repo string) (string, Signed, error)

RecordByRepo finds the newest record of an exact image reference.

func (DBStore) SaveRecord

func (s DBStore) SaveRecord(ctx context.Context, id, app string, r Signed) error

SaveRecord stores a signed record.

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.

func (*Gate) CheckBuild

func (g *Gate) CheckBuild(ctx context.Context, app, attemptID, recordID, digest, tier, nodeID string) error

CheckBuild fails closed. Server tier images and the tar path carry no record and pass.

func (*Gate) CheckImage

func (g *Gate) CheckImage(ctx context.Context, app, image string) error

CheckImage vets an image about to become app's desired image, whatever path brought it there. An image with no record was not built remotely and passes; a lookup or policy failure refuses.

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

func (p Policy) TierAllowed(tier, nodeID string) bool

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

func LoadOrCreateSigner(ctx context.Context, ks KeyStore) (*Signer, error)

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.

func (*Signer) KeyID

func (s *Signer) KeyID() string

KeyID is a short stable fingerprint of the public key.

func (*Signer) PublicKey

func (s *Signer) PublicKey() ed25519.PublicKey

PublicKey is the verification key.

func (*Signer) Sign

func (s *Signer) Sign(c Claims) (Signed, error)

Sign stamps the claims with a fresh nonce (when empty) and signs them.

func (*Signer) Verify

func (s *Signer) Verify(r Signed) error

Verify checks the signature against the signer's own public key.

type Store

type Store interface {
	SaveRecord(ctx context.Context, id, app string, s Signed) error
	GetRecord(ctx context.Context, id string) (Signed, error)
	LinkAttempt(ctx context.Context, id, attemptID string) error
}

Store is where signed records live.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL