Documentation
¶
Overview ¶
Package bundle implements the deterministic .agentpaas tar.gz format: hardened reader, writer, and offline verification (Block 22 T01).
Index ¶
- Constants
- func AppendChainDeltasSection(b *strings.Builder, report *pack.ProvenanceReport, ...)
- func AppendD3Disclaimer(b *strings.Builder)
- func AppendPolicyLintsSection(b *strings.Builder, lints []PolicyLint)
- func AppendPolicySummarySection(b *strings.Builder, lines []PolicySummaryLine)
- func AppendProvenanceSection(b *strings.Builder, provenanceText string)
- func AppendPublisherSection(b *strings.Builder, pub *InspectPublisher)
- func AppendRequirementsSection(b *strings.Builder, req *InspectRequirements)
- func AppendSBOMSection(b *strings.Builder, sbom *SBOMSummary)
- func AppendTailAnchorSection(b *strings.Builder, report *pack.ProvenanceReport)
- func FileBundleDigest(path string) (string, error)
- func FormatConsentCard(r *InspectReport, opts ConsentCardOpts) string
- func FormatInspectText(r *InspectReport) string
- func MustMarshalInspectGoldenJSON(r *InspectReport) []byte
- func NormalizeInspectText(s string) string
- func TamperManifestCreatedAt(src, dst string) error
- type Bundle
- type BundleConfig
- type BundleResult
- type ConsentCardMode
- type ConsentCardOpts
- type CredentialRequirement
- type ErrCapExceeded
- type ErrPathRejected
- type ErrUnsupported
- type InspectHeader
- type InspectPublisher
- type InspectReport
- type InspectRequirements
- type Manifest
- type ManifestContents
- type ManifestDigestEntry
- type ManifestExtraFile
- type ManifestImageEntry
- type ManifestPublisherInfo
- type PolicyLint
- type PolicySummaryLine
- type SBOMSummary
- type VerifyCheck
- type VerifyReport
Constants ¶
const ( LintWildcardDomain = "wildcard_domain" LintRawIPEgress = "raw_ip_egress" LintNonTLSPort = "non_tls_port" LintManyEgressDomains = "many_egress_domains" LintCredWildcardDest = "credential_wildcard_destination" )
const ( // MaxEntries is the maximum number of entries allowed in a bundle tar. MaxEntries = 10_000 // MaxSingleFileSize is the maximum size of a single file entry (256 MB). MaxSingleFileSize = 256 * 1024 * 1024 // MaxTotalUncompressed is the maximum total uncompressed size of all entries (2 GB). MaxTotalUncompressed = 2 * 1024 * 1024 * 1024 // MaxMetadataFileSize is the maximum size for manifest/lock/policy/sbom (10 MB each). MaxMetadataFileSize = 10 * 1024 * 1024 )
const ( ManifestPath = "manifest.json" AgentLockPath = "agent.lock" PolicyPath = "policy.yaml" SBOMPath = "sbom.spdx.json" SourcePrefix = "source/" ImagePrefix = "image/" ExtraPrefix = "extra/" )
const ( CheckManifestParse = "manifest_parse" CheckManifestSignature = "manifest_signature" CheckPublisherMatch = "publisher_match" CheckLockProvenance = "lock_provenance" CheckContentSHA256 = "content_sha256" CheckPolicyDigest = "policy_digest" CheckSBOMDigest = "sbom_digest" CheckSourceDigest = "source_digest" CheckImageDigest = "image_digest" )
const BundleSchemaVersion = 1
BundleSchemaVersion is the current .agentpaas bundle schema version.
const D3TrustDisclaimer = "A valid signature proves who signed this and that it is unmodified.\n" +
"It does not mean the agent is safe. Review the policy below."
D3TrustDisclaimer is fixed copy for bundle inspect and consent surfaces (PRD D3).
const LintChainAddsEgress = "chain_adds_egress"
Variables ¶
This section is empty.
Functions ¶
func AppendChainDeltasSection ¶
func AppendChainDeltasSection(b *strings.Builder, report *pack.ProvenanceReport, locallyVerified map[int]bool)
AppendChainDeltasSection renders per-hop policy deltas for forked bundles.
func AppendD3Disclaimer ¶
AppendD3Disclaimer writes the fixed D3 disclaimer line block.
func AppendPolicyLintsSection ¶
func AppendPolicyLintsSection(b *strings.Builder, lints []PolicyLint)
AppendPolicyLintsSection writes policy lint warnings to b.
func AppendPolicySummarySection ¶
func AppendPolicySummarySection(b *strings.Builder, lines []PolicySummaryLine)
AppendPolicySummarySection writes policy summary lines to b.
func AppendProvenanceSection ¶
AppendProvenanceSection writes provenance text to b.
func AppendPublisherSection ¶
func AppendPublisherSection(b *strings.Builder, pub *InspectPublisher)
AppendPublisherSection writes the publisher block to b (shared by inspect and consent).
func AppendRequirementsSection ¶
func AppendRequirementsSection(b *strings.Builder, req *InspectRequirements)
AppendRequirementsSection writes install requirements to b.
func AppendSBOMSection ¶
func AppendSBOMSection(b *strings.Builder, sbom *SBOMSummary)
AppendSBOMSection writes SBOM summary to b.
func AppendTailAnchorSection ¶
func AppendTailAnchorSection(b *strings.Builder, report *pack.ProvenanceReport)
AppendTailAnchorSection writes the multi-hop trust anchor sentence (PRD A4).
func FileBundleDigest ¶
FileBundleDigest returns SHA-256 hex of the bundle file bytes.
func FormatConsentCard ¶
func FormatConsentCard(r *InspectReport, opts ConsentCardOpts) string
FormatConsentCard renders the install policy approval card from verified bundle contents only (post-trust-resolution). Deterministic for a given report and opts.
func FormatInspectText ¶
func FormatInspectText(r *InspectReport) string
FormatInspectText renders the inspect report for terminal output.
func MustMarshalInspectGoldenJSON ¶
func MustMarshalInspectGoldenJSON(r *InspectReport) []byte
MustMarshalInspectGoldenJSON marshals a normalized inspect report for golden comparison.
func NormalizeInspectText ¶
NormalizeInspectText replaces volatile paths, digests, and fingerprints for golden tests.
func TamperManifestCreatedAt ¶
TamperManifestCreatedAt copies src to dst after advancing manifest created_at by one second, invalidating the manifest signature. For integration tests only.
Types ¶
type Bundle ¶
type Bundle struct {
Manifest *Manifest
Lock *pack.AgentLock
LockJSON []byte
PolicyYAML []byte
SBOM []byte
// contains filtered or unexported fields
}
Bundle represents a fully opened and validated .agentpaas file.
func Open ¶
Open opens a .agentpaas bundle file and validates its structure. Phase 1: stream-scan all tar headers, validate paths, extract the four metadata files (manifest, lock, policy, sbom) to memory. Phase 2: source/ and image/ entries are indexed for on-demand extraction via ExtractSource and ExtractImage. They are never extracted implicitly.
func (*Bundle) ExtractImage ¶
ExtractImage extracts the image/ tree to destDir.
func (*Bundle) ExtractSource ¶
ExtractSource extracts the source/ tree to destDir. destDir must be an existing directory. Files are written with their original modes. Extraction is safe: paths are validated against escape.
type BundleConfig ¶
type BundleConfig struct {
// ProjectDir is the source directory to include as source/ entries.
ProjectDir string
// Manifest is the manifest to write (manifest_signature is added by Write).
Manifest *Manifest
// Lock is the signed agent lockfile.
Lock *pack.AgentLock
// PolicyYAML is the raw policy.yaml bytes (exact sidecar, never re-marshaled).
PolicyYAML []byte
// SBOM is the raw SPDX JSON bytes.
SBOM []byte
// ImageDir is an optional OCI image layout directory to include as image/.
ImageDir string
// Ignore filters source/ collection (export uses export-specific matcher).
Ignore *pack.IgnoreMatcher
// ExtraFiles are written under extra/ and listed in manifest.extra_files.
ExtraFiles []pack.BuildFile
// PublisherKey is the ECDSA private key used to sign the manifest.
PublisherKey interface{} // *ecdsa.PrivateKey — use interface to avoid import
// SourceDateEpoch is the fixed timestamp for deterministic tar entries.
SourceDateEpoch time.Time
}
BundleConfig controls bundle creation.
type BundleResult ¶
type BundleResult struct {
// BundleDigest is the SHA-256 of the final .agentpaas file bytes (hex).
BundleDigest string
// Path is the path to the written file (empty when writing to io.Writer).
Path string
// FileCount is the total number of entries in the bundle.
FileCount int
// TotalBytes is the final size in bytes.
TotalBytes int64
}
BundleResult is returned by Write after successful bundle creation.
func Write ¶
func Write(cfg BundleConfig, out io.Writer) (*BundleResult, error)
Write creates a deterministic .agentpaas bundle and writes it to out. The bundle is a gzipped tar with lexicographically sorted entries. All tar headers use mtime=SourceDateEpoch, uid/gid=0, uname/gname="" . The manifest is signed with PublisherKey and written first in tar order.
func WriteToFile ¶
func WriteToFile(cfg BundleConfig, path string) (*BundleResult, error)
WriteToFile is like Write but writes to a file path and sets BundleResult.Path.
type ConsentCardMode ¶
type ConsentCardMode int
ConsentCardMode describes which install consent presentation to use.
const ( ConsentCardFull ConsentCardMode = iota ConsentCardAbbreviated )
type ConsentCardOpts ¶
type ConsentCardOpts struct {
Mode ConsentCardMode
AgentName string
AgentVersion string
// PolicyDiffLines are locally computed structural diff lines (changed-policy updates).
PolicyDiffLines []string
// LocallyVerifiedHops maps hop index → true for hops verified against local state.
LocallyVerifiedHops map[int]bool
}
ConsentCardOpts controls consent card rendering from a verified inspect report.
type CredentialRequirement ¶
type CredentialRequirement struct {
ID string `json:"id"`
Type string `json:"type"`
Header string `json:"header,omitempty"`
Destination string `json:"destination,omitempty"`
}
CredentialRequirement is a credential the receiver must map at install.
type ErrCapExceeded ¶
ErrCapExceeded is returned when a bundle exceeds a size/entry cap.
func (*ErrCapExceeded) Error ¶
func (e *ErrCapExceeded) Error() string
type ErrPathRejected ¶
ErrPathRejected is returned when a tar entry path fails validation.
func (*ErrPathRejected) Error ¶
func (e *ErrPathRejected) Error() string
type ErrUnsupported ¶
type ErrUnsupported struct {
What string
}
ErrUnsupported is returned when a bundle feature is unsupported.
func (*ErrUnsupported) Error ¶
func (e *ErrUnsupported) Error() string
type InspectHeader ¶
type InspectHeader struct {
File string `json:"file"`
SizeBytes int64 `json:"size_bytes"`
BundleDigest string `json:"bundle_digest"`
BundleSchemaVersion int `json:"bundle_schema_version"`
LockSchemaVersion int `json:"lock_schema_version"`
AgentName string `json:"agent_name"`
AgentVersion string `json:"agent_version"`
}
InspectHeader is section 1 of the inspect report.
type InspectPublisher ¶
type InspectPublisher struct {
Name string `json:"name"`
Fingerprint string `json:"fingerprint"`
FingerprintDisplay string `json:"fingerprint_display"`
TrustDisclaimer string `json:"trust_disclaimer"`
}
InspectPublisher is section 3 (only when verified).
type InspectReport ¶
type InspectReport struct {
Header InspectHeader `json:"header"`
Integrity *VerifyReport `json:"integrity"`
Verified bool `json:"verified"`
Publisher *InspectPublisher `json:"publisher,omitempty"`
Provenance *pack.ProvenanceReport `json:"provenance,omitempty"`
ProvenanceText string `json:"provenance_text,omitempty"`
PolicySummary []PolicySummaryLine `json:"policy_summary,omitempty"`
PolicyLints []PolicyLint `json:"policy_lints,omitempty"`
Requirements *InspectRequirements `json:"requirements,omitempty"`
SBOM *SBOMSummary `json:"sbom,omitempty"`
ExtraFiles []ManifestExtraFile `json:"extra_files,omitempty"`
}
InspectReport is the full structured bundle inspect report (B25 consumes --json).
func Inspect ¶
func Inspect(path string, b *Bundle, verifyReport *VerifyReport) (*InspectReport, error)
Inspect builds an offline inspect report for an opened bundle file.
func NormalizeInspectReport ¶
func NormalizeInspectReport(r *InspectReport) *InspectReport
NormalizeInspectReport returns a copy with volatile fields cleared for golden JSON tests.
type InspectRequirements ¶
type InspectRequirements struct {
Credentials []CredentialRequirement `json:"credentials"`
LLMProvider string `json:"llm_provider"`
Image string `json:"image"`
Platform string `json:"platform"`
}
InspectRequirements is section 7.
type Manifest ¶
type Manifest struct {
BundleSchemaVersion int `json:"bundle_schema_version"`
Publisher ManifestPublisherInfo `json:"publisher"`
Contents ManifestContents `json:"contents"`
CreatedAt time.Time `json:"created_at"`
// ManifestSignature is the ECDSA signature over the canonical JSON,
// excluding this field. Base64-encoded.
ManifestSignature string `json:"manifest_signature,omitempty"`
// ExtraFiles lists --include paths digest-pinned but excluded from source digest.
ExtraFiles []ManifestExtraFile `json:"extra_files,omitempty"`
}
Manifest describes the bundle contents and is signed by the publisher.
type ManifestContents ¶
type ManifestContents struct {
Lock ManifestDigestEntry `json:"lock"`
Policy ManifestDigestEntry `json:"policy"`
SBOM ManifestDigestEntry `json:"sbom"`
Source ManifestDigestEntry `json:"source"`
Image *ManifestImageEntry `json:"image,omitempty"`
}
ManifestContents describes what's in the bundle, with per-file content digests.
type ManifestDigestEntry ¶
type ManifestDigestEntry struct {
Digest string `json:"digest"`
}
ManifestDigestEntry is a single content entry with its SHA-256 digest.
type ManifestExtraFile ¶
type ManifestExtraFile struct {
Path string `json:"path"`
Digest string `json:"digest"`
Bytes int64 `json:"bytes"`
}
ManifestExtraFile is an explicitly included file outside the locked source digest.
type ManifestImageEntry ¶
ManifestImageEntry describes the OCI image included in the bundle.
type ManifestPublisherInfo ¶
type ManifestPublisherInfo struct {
Name string `json:"name"`
Fingerprint string `json:"fingerprint"`
PublicKeyPEM string `json:"public_key_pem"`
}
ManifestPublisherInfo identifies the publisher of the bundle.
type PolicyLint ¶
PolicyLint is a non-fatal policy warning (PRD A3).
func ComputeChainLints ¶
func ComputeChainLints(report *pack.ProvenanceReport) []PolicyLint
ComputeChainLints returns warnings when any provenance hop adds egress vs the original.
func ComputePolicyLints ¶
func ComputePolicyLints(pol *policy.Policy) []PolicyLint
ComputePolicyLints returns PRD A3 warnings for a parsed policy.
type PolicySummaryLine ¶
PolicySummaryLine is one rendered policy row for inspect output.
type SBOMSummary ¶
type SBOMSummary struct {
PackageCount int `json:"package_count"`
TopLevelDeps []string `json:"top_level_deps"`
ParseWarning string `json:"parse_warning,omitempty"`
}
SBOMSummary is section 8.
type VerifyCheck ¶
type VerifyCheck struct {
Name string `json:"name"`
Passed bool `json:"passed"`
Detail string `json:"detail"`
}
VerifyCheck is a single verification check result.
type VerifyReport ¶
type VerifyReport struct {
Verified bool `json:"verified"`
Checks []VerifyCheck `json:"checks"`
}
VerifyReport is the result of Verify().
func Verify ¶
func Verify(b *Bundle) (*VerifyReport, error)
Verify performs offline verification of an opened bundle. All nine checks from the Block 22 T01 spec are evaluated; Verified is true only when every check passes.