Documentation
¶
Overview ¶
Package agentpkg defines the signed Agent Package manifest (ADR-010) and its admission verification. A package pins, by digest: the AgentVersion spec, runtime lock, tool lock, permissions, memory schema and SBOM, plus build provenance. v0.3 signs the canonical manifest with ed25519 under a registered key identity; production admission fails closed on any missing or invalid signature, provenance or unknown key. Cosign interop for OCI image signatures is a future projection; the manifest itself is the kernel's trust anchor.
Index ¶
- Constants
- Variables
- func DecodePrivateKey(encoded string) (ed25519.PrivateKey, error)
- func DecodePublicKey(encoded string) (ed25519.PublicKey, error)
- func EncodePublicKey(key ed25519.PublicKey) string
- func GenerateSBOM(manifest Manifest) ([]byte, error)
- func GenerateSigningKey(id string) (*SigningKey, *Key, error)
- func ManifestDigest(manifest Manifest) ([sha256.Size]byte, error)
- func Verify(pkg *Package, keys map[string]ed25519.PublicKey) error
- func VerifyImageSignature(manifest Manifest, keys map[string]ed25519.PublicKey) error
- func VerifySBOM(document []byte, expected Digest) error
- type CompatibilityRule
- type Digest
- type Key
- type Manifest
- type MetadataIndex
- type Package
- type Provenance
- type PublisherInfo
- type Registry
- type RuntimeRequirements
- type SecurityInstallRequest
- type SecurityInstallResult
- type Signature
- type SigningKey
Constants ¶
const ManifestSchema = "fenced.agentpkg/v1"
ManifestSchema is the canonical manifest version.
const SBOMSpecVersion = "1.5"
SBOMSpecVersion is the CycloneDX version the generator emits (ADR-010: CI produces an SPDX or CycloneDX SBOM for every package).
Variables ¶
var ( ErrSignatureVerificationFailed = errors.New("security pipeline: package signature verification failed") ErrDigestMismatch = errors.New("security pipeline: SBOM or OCI layer digest mismatch") ErrABIIncompatible = errors.New("security pipeline: syscall ABI version incompatible with kernel") ErrCapabilityDenied = errors.New("security pipeline: admission policy denied requested capabilities") )
var ErrPackageBindingMismatch = errors.New("agent package does not bind to this publication")
ErrPackageBindingMismatch reports a package whose signed manifest does not bind to the publication it is attached to (reference or spec mismatch).
var ErrPackageManifestInvalid = errors.New("agent package manifest is invalid")
ErrPackageManifestInvalid reports a malformed manifest.
var ErrPackageSignatureInvalid = errors.New("agent package signature is invalid")
ErrPackageSignatureInvalid reports a broken signature, an unknown key, or a manifest that does not match the signature.
var ErrPackageUnsigned = errors.New("agent package is not signed")
ErrPackageUnsigned reports a package missing its signature.
Functions ¶
func DecodePrivateKey ¶
func DecodePrivateKey(encoded string) (ed25519.PrivateKey, error)
DecodePrivateKey parses a base64 raw std or standard private key for the signing CLI.
func DecodePublicKey ¶
DecodePublicKey parses a base64 raw std or standard public key.
func EncodePublicKey ¶
EncodePublicKey renders a public key for transport (CLI flags, env vars).
func GenerateSBOM ¶
GenerateSBOM emits a minimal CycloneDX document describing the locked runtime and tool digests of the manifest. The caller pins its digest into the manifest's sbom field.
func GenerateSigningKey ¶
func GenerateSigningKey(id string) (*SigningKey, *Key, error)
GenerateSigningKey creates a fresh package-signing key pair.
func ManifestDigest ¶
ManifestDigest returns the SHA-256 of the canonical manifest encoding (the exact bytes Sign signed and Verify re-checks).
func Verify ¶
Verify checks the signature against the manifest using the trusted key registry. Verification is fail-closed: an unknown key, a malformed signature or a manifest mismatch rejects the package.
func VerifyImageSignature ¶
VerifyImageSignature checks the manifest's image signature fail-closed: when the manifest declares a signed image, the signature must verify over exactly that digest under a trusted key.
func VerifySBOM ¶
VerifySBOM checks that the document is a CycloneDX SBOM and that its SHA-256 digest matches the manifest pin.
Types ¶
type CompatibilityRule ¶
type CompatibilityRule struct {
MinKernelVersion string `json:"minKernelVersion"`
MaxKernelVersion string `json:"maxKernelVersion,omitempty"`
SupportedABIs []string `json:"supportedAbis"`
}
CompatibilityRule defines compatibility with Fenced versions.
type Digest ¶
Digest is a content digest reference (algorithm + hex).
func ComputeContentDigest ¶
ComputeContentDigest calculates standard sha256:hex digest.
func SBOMDigest ¶
SBOMDigest returns the sha256 digest of the generated document for pinning into the manifest.
func SpecSHA256 ¶
SpecSHA256 is a convenience for building a manifest from raw spec bytes.
type Manifest ¶
type Manifest struct {
Schema string `json:"schema"`
AgentVersionRef string `json:"agentVersionRef"`
SpecDigest Digest `json:"specDigest"`
Spec json.RawMessage `json:"spec"`
RuntimeLock []Digest `json:"runtimeLock"`
ToolLock []Digest `json:"toolLock"`
Permissions Digest `json:"permissions"`
MemorySchema Digest `json:"memorySchema"`
SBOM Digest `json:"sbom"`
Provenance Provenance `json:"provenance"`
// SignedImageDigest is the digest-pinned OCI image this package ships
// (ADR-010 cosign-style binding); ImageSignature is its signature. When
// either is set both must be set and the signature must verify.
SignedImageDigest Digest `json:"signedImageDigest,omitempty"`
ImageSignature *Signature `json:"imageSignature,omitempty"`
}
Manifest is the canonical, signed package document.
func FromAgentManifest ¶
func FromAgentManifest(manifest agentversion.Manifest, provenance Provenance) (Manifest, error)
FromAgentManifest builds the unsigned supply-chain manifest from a strict portable Agent Manifest. The returned spec bytes are exactly those accepted by AgentVersion publication, so signing and admission bind the same object.
type MetadataIndex ¶
type MetadataIndex struct {
Manifest Manifest `json:"manifest"`
Version string `json:"version"`
OCIDigest Digest `json:"ociDigest"`
Signature Signature `json:"signature"`
SBOM Digest `json:"sbom"`
SyscallABIVersion string `json:"syscallAbiVersion"`
Capabilities []string `json:"capabilities"`
RuntimeRequirements RuntimeRequirements `json:"runtimeRequirements"`
Publisher PublisherInfo `json:"publisher"`
Compatibility CompatibilityRule `json:"compatibility"`
PublishedAt time.Time `json:"publishedAt"`
}
MetadataIndex defines the complete catalog record for an Agent Package in the registry.
func BuildMetadataIndex ¶
func BuildMetadataIndex(pkg *Package, publisher PublisherInfo, ociDigest Digest) (*MetadataIndex, error)
BuildMetadataIndex creates the complete registry catalog record from a signed package.
type Provenance ¶
type Provenance struct {
Builder string `json:"builder"`
BuildWorkflow string `json:"buildWorkflow"`
GitCommit string `json:"gitCommit"`
BuiltAt time.Time `json:"builtAt"`
}
Provenance records who built the package and from what (in-toto/SLSA shape, v0.3 subset): the build workflow identity, the git commit, and the builder. Production admission checks workflow allow-listing on this field.
type PublisherInfo ¶
type PublisherInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Email string `json:"email,omitempty"`
Organization string `json:"organization,omitempty"`
Verified bool `json:"verified"`
}
PublisherInfo identifies the signing organization or author.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the trusted package-signing key set used by publish admission (ADR-010). Lookup is fail-closed: a package signed by a key that is not in the registry is rejected before any other check.
func (*Registry) Add ¶
Add trusts the given key identity. Re-adding an identity with a different key is an error: key IDs must be unique within the trust root.
type RuntimeRequirements ¶
type RuntimeRequirements struct {
CPU string `json:"cpu,omitempty"`
Memory string `json:"memory,omitempty"`
Isolation string `json:"isolation,omitempty"` // wasm, oci, gvisor
Features []string `json:"features,omitempty"`
}
RuntimeRequirements defines hardware and isolation constraints.
type SecurityInstallRequest ¶
type SecurityInstallRequest struct {
Package *Package
ExpectedKeyID string
AllowedCapabilities map[string]bool
TenantID string
DryRun bool
}
SecurityInstallRequest carries inputs for the 6-stage security gate.
type SecurityInstallResult ¶
type SecurityInstallResult struct {
VerifiedSignature bool `json:"verifiedSignature"`
VerifiedSBOM bool `json:"verifiedSbom"`
VerifiedDigest bool `json:"verifiedDigest"`
VerifiedABI bool `json:"verifiedAbi"`
VerifiedPolicy bool `json:"verifiedPolicy"`
AgentVersionRef string `json:"agentVersionRef"`
RegisteredAt time.Time `json:"registeredAt"`
}
SecurityInstallResult details the outcome of every security verification stage.
func ExecuteSecurityPipeline ¶
func ExecuteSecurityPipeline( ctx context.Context, req SecurityInstallRequest, keyRegistry *Registry, ) (*SecurityInstallResult, error)
ExecuteSecurityPipeline enforces the mandatory 6-stage security gate: Registry Fetch -> Verify Signature -> Verify SBOM/Digest -> Check ABI Compatibility -> Check Capability -> Create AgentVersion. It is physically impossible to bypass Admission, Capability grants, or Policy rules.
type Signature ¶
type Signature struct {
KeyID string `json:"keyId"`
Ed25519 string `json:"ed25519"` // base64 raw std encoding
CreatedAt time.Time `json:"createdAt"`
}
Signature binds the manifest hash to a registered key identity.
func SignImage ¶
func SignImage(digest Digest, key *SigningKey) (*Signature, error)
SignImage signs the digest-pinned OCI image the package ships. The signature is embedded in the manifest (SignedImageDigest + ImageSignature) before the manifest itself is signed, so the manifest signature covers it.
type SigningKey ¶
type SigningKey struct {
ID string
PrivateKey ed25519.PrivateKey
}
SigningKey is the private half; only the signer holds it.