programfeed

package
v0.0.0-...-27e7fae Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: GPL-3.0 Imports: 18 Imported by: 1 module, 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 programfeed reads the signed bundles of the public program feed (RFC-065 §16, collector openctemio/programfeed, record schema openctem.programfeed/v1): a key set signed by the offline root, a signed pointer, a signed snapshot manifest and an optional signed delta manifest, each naming gzip JSON-lines files of programs and of changes.

Verification follows the feed contract: pinned root, key-set version never lower than one accepted before, sequence newer than the applied one, a delta only when its base is the applied sequence (otherwise the snapshot), not expired and at most 7 days valid, every file's size and SHA-256 as the manifest says, every record re-validated (a bundle with one bad record is refused whole). Records are read through a RecordParser so the importer follows the collector's published schema.

Index

Constants

View Source
const (
	KeySetPayloadType   = "application/vnd.openctem.programfeed.keyset+json"
	KeySetKind          = "openctem.programfeed.keyset/v1"
	LatestPayloadType   = "application/vnd.openctem.programfeed.latest+json"
	LatestSchema        = "openctem.programfeed.latest/v1"
	ManifestPayloadType = "application/vnd.openctem.programfeed.manifest+json"
	ManifestSchema      = "openctem.programfeed/v1"
	KindSnapshot        = "snapshot"
	KindDelta           = "delta"
	LatestFile          = "latest.dsse.json"
	KeySetFile          = "keyset.dsse.json"
)

Format constants (must match the collector).

View Source
const (
	MaxBundleValidity    = 7 * 24 * time.Hour
	MaxManifestBytes     = 1 << 20
	MaxFileBytes         = 64 << 20
	MaxDecompressedBytes = 512 << 20
	MaxRecordBytes       = 1 << 20
	MaxPrograms          = 100000
	MaxChanges           = 500000
)

Bounds.

View Source
const (
	LocalLatestFile = "latest.json"
)

Unsigned file names of a local bundle.

View Source
const MaxKeySetValidity = 180 * 24 * time.Hour

MaxKeySetValidity caps not_after - issued_at of the program feed key set.

Variables

View Source
var ErrNotNewer = errors.New("bundle is not newer than the applied sequence")

ErrNotNewer: the bundle is not newer than what was applied.

View Source
var KeySetType = feedsign.KeySetType{PayloadType: KeySetPayloadType, Kind: KeySetKind, MaxValidity: MaxKeySetValidity}

KeySetType is the program feed's key set.

Functions

func FileName

func FileName(kind, records string) string

FileName is a record file of a kind: programs or changes.

func ManifestName

func ManifestName(kind string) string

ManifestName is the manifest file of a kind.

Types

type Collector

type Collector struct {
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	LocalOnly bool   `json:"local_only,omitempty"`
}

Collector names the build. LocalOnly marks an unsigned bundle a self-hoster built without the publish policy: never accepted on the signed-feed path.

type File

type File struct {
	Name    string `json:"name"`
	SHA256  string `json:"sha256"`
	Size    int64  `json:"size"`
	Records int    `json:"records"`
}

File is one record file of a manifest.

type Latest

type Latest struct {
	Schema       string    `json:"schema"`
	Sequence     uint64    `json:"sequence"`
	Tag          string    `json:"tag"`
	Snapshot     string    `json:"snapshot"`
	Delta        string    `json:"delta,omitempty"`
	BaseSequence uint64    `json:"base_sequence,omitempty"`
	CreatedAt    time.Time `json:"created_at"`
	ExpiresAt    time.Time `json:"expires_at"`
}

Latest points at the newest bundle.

type Manifest

type Manifest struct {
	Schema       string    `json:"schema"`
	Sequence     uint64    `json:"sequence"`
	Kind         string    `json:"kind"`
	BaseSequence uint64    `json:"base_sequence,omitempty"`
	CreatedAt    time.Time `json:"created_at"`
	ExpiresAt    time.Time `json:"expires_at"`
	Sources      []Source  `json:"sources"`
	Files        []File    `json:"files"`
	Stats        Stats     `json:"stats"`
	Collector    Collector `json:"collector"`
}

Manifest describes a snapshot or a delta.

type Options

type Options struct {
	PinnedRoot       string
	MinKeySetVersion uint64
	AppliedSequence  uint64
	Now              time.Time
}

Options are the platform's state at verification.

type RecordParser

type RecordParser interface {
	Parse(line []byte) (bp.PublicProgram, error)
	ParseChange(line []byte) (bp.FeedChange, error)
}

RecordParser reads the record lines of the programs and changes files.

type Source

type Source struct {
	Name        string    `json:"name"`
	URL         string    `json:"url"`
	AsOf        time.Time `json:"as_of"`
	Terms       string    `json:"terms"`
	Licence     string    `json:"licence"` //nolint:misspell // the collector wire name
	Attribution string    `json:"attribution"`
	Programs    int       `json:"programs"`
}

Source is one upstream source, with its license and attribution.

type Stats

type Stats struct {
	Programs int `json:"programs"`
	Open     int `json:"open"`
	Bounty   int `json:"bounty"`
	Targets  int `json:"targets"`
	Rejected int `json:"rejected"`
	Changes  int `json:"changes"`
	Added    int `json:"added"`
	Closed   int `json:"closed"`
	Dropped  int `json:"dropped"`
}

Stats summarizes a manifest.

type V1

type V1 struct{}

V1 reads records of schema openctem.programfeed/v1 (the collector's schema/program.schema.json and schema/change.schema.json). Fields the schema adds later are ignored (the collector extends records within v1); every field read is validated, and every target is classified again by the platform's own parser: the feed's canonical form is not trusted to be scannable. Pointer and manifests stay strict (feedsign.DecodeStrict).

func (V1) Parse

func (V1) Parse(line []byte) (bp.PublicProgram, error)

Parse reads one program record.

func (V1) ParseChange

func (V1) ParseChange(line []byte) (bp.FeedChange, error)

ParseChange reads one change record.

type Verified

type Verified struct {
	Dir    string
	KeySet *feedsign.KeySet
	Latest Latest
	// Use is the manifest to apply: the delta when its base is the applied
	// sequence, otherwise the snapshot.
	Use Manifest
}

Verified is a bundle whose envelopes and the files to apply checked out.

func VerifyDir

func VerifyDir(dir string, opt Options) (*Verified, error)

VerifyDir verifies the bundle in dir.

func VerifyLocalDir

func VerifyLocalDir(dir string, opt Options) (*Verified, error)

VerifyLocalDir verifies an unsigned local bundle in dir.

func (*Verified) IsDelta

func (v *Verified) IsDelta() bool

IsDelta reports whether the delta is applied.

func (*Verified) Read

Read reads and validates the programs and changes of the manifest to apply.

Directories

Path Synopsis
Package programfeedtest builds signed program-feed bundles for tests: a fresh offline root and online key per Builder, so no key is ever committed and no test reaches the network.
Package programfeedtest builds signed program-feed bundles for tests: a fresh offline root and online key per Builder, so no key is ever committed and no test reaches the network.

Jump to

Keyboard shortcuts

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