attestation

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttestationConfig

type AttestationConfig struct {
	// Key-based signing configuration
	KeyBased KeyBasedConfig
}

AttestationConfig contains configuration for the attestation service

type AttestationResult

type AttestationResult struct {
	ImageRef        string
	AttestationType string // "sbom" or "vulnerability"
	Success         bool
	Error           error
	Timestamp       time.Time
	DigestSigned    string // The digest that was attested/signed
}

AttestationResult represents the result of an attestation operation

type Attestor

type Attestor interface {
	// AttestSBOM creates and pushes SBOM attestation using sigstore-go
	AttestSBOM(ctx context.Context, imageRef string, sbom *scanner.SBOM) error

	// AttestVulnerabilities creates and pushes vulnerability attestation using sigstore-go
	AttestVulnerabilities(ctx context.Context, imageRef string, result *scanner.ScanResult) error

	// AttestSCAI creates and pushes SCAI attestation using sigstore-go
	AttestSCAI(ctx context.Context, imageRef string, scai *SCAIAttestation) error

	// SignImage signs the image using sigstore-go if policy passes
	SignImage(ctx context.Context, imageRef string) error
}

Attestor defines the interface for creating attestations and signing images

type KeyBasedConfig

type KeyBasedConfig struct {
	Key         string // Base64-encoded private key content
	KeyPassword string // Password for the private key (optional)
	CertPath    string // Path to the certificate file (optional)
}

KeyBasedConfig contains configuration for key-based signing

type SBOMAttestation

type SBOMAttestation struct {
	ImageRef  string
	SBOM      *scanner.SBOM
	Timestamp time.Time
	Predicate SBOMPredicate
}

SBOMAttestation represents SBOM attestation data

type SBOMPredicate

type SBOMPredicate struct {
	Format      string    `json:"format"`  // "cyclonedx"
	Version     string    `json:"version"` // CycloneDX version
	Content     []byte    `json:"content"` // SBOM data
	GeneratedAt time.Time `json:"generatedAt"`
}

SBOMPredicate contains the SBOM attestation predicate

type SCAIAttestation

type SCAIAttestation struct {
	Attribute  string              `json:"attribute"`
	Target     SCAITarget          `json:"target"`
	Evidence   SCAIEvidence        `json:"evidence"`
	Attributes []SCAIAttributeItem `json:"attributes"`
}

SCAIAttestation represents the complete SCAI attestation structure following the in-toto SCAI v0.3 specification

type SCAIAttributeItem

type SCAIAttributeItem struct {
	Attribute string                    `json:"attribute"` // "tolerated-vulnerability"
	Evidence  SCAIToleratedVulnEvidence `json:"evidence"`
}

SCAIAttributeItem represents a single tolerated vulnerability

type SCAIEvidence

type SCAIEvidence struct {
	LastScanned time.Time `json:"lastScanned"` // RFC 3339 format
	ValidUntil  time.Time `json:"validUntil"`  // RFC 3339 format
	ScanStatus  string    `json:"scanStatus"`  // "passed-with-exceptions" or "passed"
}

SCAIEvidence contains the primary security assessment metadata

type SCAIGenerator

type SCAIGenerator struct {
	// contains filtered or unexported fields
}

SCAIGenerator creates SCAI attestation predicates

func NewSCAIGenerator

func NewSCAIGenerator(config *config.RegsyncConfig, logger *slog.Logger) *SCAIGenerator

NewSCAIGenerator creates a new SCAI generator

func (*SCAIGenerator) GenerateSCAI

func (g *SCAIGenerator) GenerateSCAI(
	ctx context.Context,
	imageRef string,
	scanResult *scanner.ScanResult,
	target string,
) (*SCAIAttestation, error)

GenerateSCAI creates an SCAI attestation predicate from scan results Parameters:

  • ctx: context for cancellation
  • imageRef: full image reference with digest
  • scanResult: vulnerability scan results
  • target: target repository from regsync config (for toleration lookup)

Returns: SCAI attestation structure ready for JSON serialization

type SCAITarget

type SCAITarget struct {
	URI string `json:"uri"` // PURL format: pkg:docker/repo@sha256:digest
}

SCAITarget identifies the container image being assessed

type SCAIToleratedVulnEvidence

type SCAIToleratedVulnEvidence struct {
	CVEID          string     `json:"cveId"`
	Severity       string     `json:"severity"`
	PackageName    string     `json:"packageName"`
	Version        string     `json:"version"`
	FixedVersion   string     `json:"fixedVersion,omitempty"` // Version with fix (empty if no fix available)
	Description    string     `json:"description,omitempty"`  // Short description of the vulnerability
	Statement      string     `json:"statement"`
	ToleratedUntil *time.Time `json:"toleratedUntil,omitempty"` // RFC 3339 format, nil if no expiry
}

SCAIToleratedVulnEvidence contains details about a tolerated vulnerability

type ScannerInfo

type ScannerInfo struct {
	Name    string `json:"name"`    // "trivy"
	Version string `json:"version"` // Scanner version
}

ScannerInfo contains information about the scanner used

type SignatureResult

type SignatureResult struct {
	ImageRef     string
	Success      bool
	Error        error
	Timestamp    time.Time
	DigestSigned string // The digest that was signed
	SignatureRef string // Reference to the signature in the registry
}

SignatureResult represents the result of a signing operation

type SigstoreAttestor

type SigstoreAttestor struct {
	// contains filtered or unexported fields
}

SigstoreAttestor implements the Attestor interface using cosign CLI

func NewSigstoreAttestor

func NewSigstoreAttestor(config AttestationConfig, logger *slog.Logger) (*SigstoreAttestor, error)

NewSigstoreAttestor creates a new Sigstore attestor Note: Registry authentication should be handled separately during initialization

func (*SigstoreAttestor) AttestSBOM

func (a *SigstoreAttestor) AttestSBOM(ctx context.Context, imageRef string, sbom *scanner.SBOM) error

AttestSBOM creates and pushes SBOM attestation using cosign CLI

func (*SigstoreAttestor) AttestSCAI

func (a *SigstoreAttestor) AttestSCAI(ctx context.Context, imageRef string, scai *SCAIAttestation) error

AttestSCAI creates and pushes SCAI attestation using cosign CLI

func (*SigstoreAttestor) AttestVulnerabilities

func (a *SigstoreAttestor) AttestVulnerabilities(ctx context.Context, imageRef string, result *scanner.ScanResult) error

AttestVulnerabilities creates and pushes vulnerability attestation using cosign CLI

func (*SigstoreAttestor) Close

func (a *SigstoreAttestor) Close() error

Close cleans up temporary resources

func (*SigstoreAttestor) SignImage

func (a *SigstoreAttestor) SignImage(ctx context.Context, imageRef string) error

SignImage signs the image using cosign CLI

type VulnerabilityAttestation

type VulnerabilityAttestation struct {
	ImageRef   string
	ScanResult *scanner.ScanResult
	Timestamp  time.Time
	Predicate  VulnerabilityPredicate
}

VulnerabilityAttestation represents vulnerability scan attestation data

type VulnerabilityInfo

type VulnerabilityInfo struct {
	ID           string `json:"id"`       // CVE ID
	Severity     string `json:"severity"` // CRITICAL, HIGH, MEDIUM, LOW
	PackageName  string `json:"packageName"`
	Version      string `json:"version"`      // Installed version
	FixedVersion string `json:"fixedVersion"` // Version with fix
	Title        string `json:"title"`
	Description  string `json:"description"`
	PrimaryURL   string `json:"primaryUrl"`
}

VulnerabilityInfo represents a vulnerability in the attestation

type VulnerabilityPredicate

type VulnerabilityPredicate struct {
	Scanner         ScannerInfo          `json:"scanner"`
	Vulnerabilities []VulnerabilityInfo  `json:"vulnerabilities"`
	Summary         VulnerabilitySummary `json:"summary"`
	ScannedAt       time.Time            `json:"scannedAt"`
}

VulnerabilityPredicate contains the vulnerability attestation predicate

type VulnerabilitySummary

type VulnerabilitySummary struct {
	Critical int `json:"critical"`
	High     int `json:"high"`
	Medium   int `json:"medium"`
	Low      int `json:"low"`
	Total    int `json:"total"`
}

VulnerabilitySummary provides a summary of vulnerabilities by severity

Jump to

Keyboard shortcuts

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