cipolicy

package
v0.70.4 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package cipolicy owns the versioned CI north-star P1 policy manifest.

Index

Constants

View Source
const (
	ArtifactTypeNativeLibghostty = "native-libghostty"
	ArtifactTypeRelease          = "release"

	ArtifactFormatTar     = "tar"
	ArtifactFormatTarGzip = "tar.gz"

	ArtifactFileRegular = "file"
	ArtifactFileSymlink = "symlink"
)
View Source
const (
	FixtureSchemaVersion     = 1
	FixtureCanonicalPath     = "/usr/bin:/bin"
	FixtureCanonicalLocale   = "C"
	FixtureCanonicalTimezone = "UTC"
)
View Source
const (
	SchemaVersion = 1
	PolicyVersion = "ci-policy-v1"

	DefaultManifestPath  = "internal/cipolicy/manifest.json"
	DefaultInventoryPath = "internal/cibaseline/inventory.json"
	DefaultRepository    = "d0ugal/graith"
	DefaultDefaultBranch = "main"
)
View Source
const (
	P11JSSurfaceDirectory = ".github/workflows/scripts"
	P11NextTrancheHelper  = ".github/workflows/scripts/regen-auth.test.js"
)
View Source
const (
	PlanSchemaVersion = 1
	DetectorVersion   = "cipolicy-detector-v1"
)
View Source
const ArtifactSchemaVersion = 1
View Source
const CacheSchemaVersion = 1
View Source
const ResultSchemaVersion = 1

Variables

This section is empty.

Functions

func CacheKeyDigest

func CacheKeyDigest(material CacheKeyMaterial) (string, error)

func ComparePortableArchives

func ComparePortableArchives(left ArchiveSnapshot, right ArchiveSnapshot) error

func DetectorDigest

func DetectorDigest() string

func ExtractVerifiedArtifact

func ExtractVerifiedArtifact(
	policy Manifest,
	plan RunPlan,
	result ResultRecord,
	artifact ArtifactContractManifest,
	archive []byte,
	destination string,
	options ArtifactVerificationOptions,
	now time.Time,
) error

func ReadInventory

func ReadInventory(path string) (cibaseline.Inventory, error)

func RejectUnsupportedPlatformPasses

func RejectUnsupportedPlatformPasses(plan RunPlan, observations []GeneratedUnsupported) error

func ValidateArtifactManifest

func ValidateArtifactManifest(policy Manifest, plan RunPlan, result ResultRecord, artifact ArtifactContractManifest, now time.Time) error

func ValidateCacheRead

func ValidateCacheRead(
	policy Manifest,
	producerPlan RunPlan,
	producerResult ResultRecord,
	consumerPlan RunPlan,
	consumerJob PlanJob,
	cache CacheManifest,
	payload []byte,
	options CacheReadOptions,
	now time.Time,
) error

func ValidateCacheWrite

func ValidateCacheWrite(policy Manifest, plan RunPlan, result ResultRecord, cache CacheManifest, payload []byte, now time.Time) error

func ValidateCredentialOperation

func ValidateCredentialOperation(operation CredentialOperation) error

func ValidateCurrent

func ValidateCurrent(manifest Manifest, inventoryPath string) error

func ValidateFixtureChangedFiles

func ValidateFixtureChangedFiles(knownFiles []FixtureFile, changedFiles []string, exact bool) error

func ValidateHermeticEnvironment

func ValidateHermeticEnvironment(env map[string]string) error

func ValidateManifestWorkflowBindings

func ValidateManifestWorkflowBindings(manifest Manifest, knownFiles []FixtureFile) error

func ValidateP11JSSurfaceInventory

func ValidateP11JSSurfaceInventory(repoRoot string, inventory cibaseline.Inventory, contracts []P11JSHelperContract) error

func ValidateResultRecord

func ValidateResultRecord(manifest Manifest, plan RunPlan, result ResultRecord, now time.Time) error

func VerifyArtifact

func VerifyArtifact(expect ArtifactExpectation, artifact ArtifactManifest) error

func VerifyArtifactArchive

func VerifyArtifactArchive(artifact ArtifactContractManifest, archive []byte) error

func VerifyArtifactConsumer

func VerifyArtifactConsumer(
	policy Manifest,
	plan RunPlan,
	result ResultRecord,
	artifact ArtifactContractManifest,
	archive []byte,
	options ArtifactVerificationOptions,
	now time.Time,
) error

func VerifyCachePayload

func VerifyCachePayload(cache CacheManifest, payload []byte) error

func VerifyCacheRestore

func VerifyCacheRestore(request CacheRequest, entry CacheEntry) error

Types

type ArchiveComparison

type ArchiveComparison struct {
	Left  ArchiveSnapshot
	Right ArchiveSnapshot
}

type ArchiveEntry

type ArchiveEntry struct {
	Name       string
	Type       string
	Mode       int
	SHA256     string
	LineEnding string
	LinkTarget string
}

type ArchiveSnapshot

type ArchiveSnapshot struct {
	Platform string
	Entries  []ArchiveEntry
}

type ArtifactCheck

type ArtifactCheck struct {
	Expectation ArtifactExpectation
	Artifact    ArtifactManifest
}

type ArtifactContractManifest

type ArtifactContractManifest struct {
	SchemaVersion  int    `json:"schema_version"`
	ManifestDigest string `json:"manifest_digest"`
	ArtifactType   string `json:"artifact_type"`
	ArtifactID     string `json:"artifact_id"`
	ArtifactFormat string `json:"artifact_format"`
	ArtifactDigest string `json:"artifact_digest"`

	PolicyVersion   string         `json:"policy_version"`
	PolicyDigest    string         `json:"policy_digest"`
	PlanDigest      string         `json:"plan_digest"`
	ResultDigest    string         `json:"result_digest"`
	DetectorVersion string         `json:"detector_version"`
	DetectorDigest  string         `json:"detector_digest"`
	Source          SourceRevision `json:"source"`
	Event           EventSelection `json:"event"`
	TrustTier       string         `json:"trust_tier"`

	Mode         string            `json:"mode"`
	Coordinate   string            `json:"coordinate"`
	Capability   string            `json:"capability"`
	Platform     string            `json:"platform"`
	OS           string            `json:"os"`
	Architecture string            `json:"architecture"`
	CostClass    string            `json:"cost_class"`
	Requiredness string            `json:"requiredness"`
	Matrix       map[string]string `json:"matrix"`

	Dependencies []IdentityDigest   `json:"dependencies"`
	Toolchains   []IdentityDigest   `json:"toolchains"`
	BuildFlags   []BuildFlag        `json:"build_flags"`
	Files        []ArtifactFile     `json:"files"`
	Provenance   ArtifactProvenance `json:"provenance"`
}

func DecodeArtifactManifest

func DecodeArtifactManifest(name string, data []byte) (ArtifactContractManifest, error)

func NewArtifactManifest

func NewArtifactManifest(policy Manifest, plan RunPlan, result ResultRecord, input ArtifactManifestInput) (ArtifactContractManifest, error)

func ReadArtifactManifest

func ReadArtifactManifest(path string) (ArtifactContractManifest, error)

func (ArtifactContractManifest) Canonical

func (ArtifactContractManifest) Digest

func (artifact ArtifactContractManifest) Digest() (string, error)

func (ArtifactContractManifest) MarshalCanonical

func (artifact ArtifactContractManifest) MarshalCanonical() ([]byte, error)

type ArtifactExpectation

type ArtifactExpectation struct {
	Plan          RunPlan
	Job           PlanJob
	Digest        string
	ProducerRunID string
	RunAttempt    int
	Now           time.Time
	MaxAge        time.Duration
}

type ArtifactFile

type ArtifactFile struct {
	Path       string `json:"path"`
	Kind       string `json:"kind"`
	Mode       int64  `json:"mode"`
	Size       int64  `json:"size"`
	SHA256     string `json:"sha256"`
	LinkTarget string `json:"link_target,omitempty"`
}

type ArtifactManifest

type ArtifactManifest struct {
	Name           string
	Digest         string
	ContentDigest  string
	PlanDigest     string
	PolicyDigest   string
	SourceCommit   string
	SourceTree     string
	Mode           string
	Coordinate     string
	ProducerRunID  string
	RunAttempt     int
	CreatedAt      time.Time
	UploadComplete bool
}

type ArtifactManifestInput

type ArtifactManifestInput struct {
	ArtifactType   string
	ArtifactID     string
	ArtifactFormat string
	ArtifactDigest string
	Dependencies   []IdentityDigest
	Toolchains     []IdentityDigest
	BuildFlags     []BuildFlag
	Files          []ArtifactFile
	Provenance     ArtifactProvenance
}

type ArtifactProvenance

type ArtifactProvenance struct {
	Workflow       string `json:"workflow"`
	WorkflowSHA256 string `json:"workflow_sha256"`
	RunID          int64  `json:"run_id"`
	RunAttempt     int    `json:"run_attempt"`
	JobID          string `json:"job_id"`
	JobName        string `json:"job_name"`
	ProducerStatus string `json:"producer_status"`
	UploadComplete bool   `json:"upload_complete"`
	ArtifactID     string `json:"artifact_id"`
	ArtifactDigest string `json:"artifact_digest"`
}

type ArtifactVerificationOptions

type ArtifactVerificationOptions struct {
	ArtifactType       string
	ArtifactID         string
	ArtifactDigest     string
	ProducerMode       string
	ProducerCoordinate string
	ConsumerPlan       RunPlan
	ConsumerJob        PlanJob
	Workflow           string
	RunID              int64
	RunAttempt         int
}

type BaselineInventory

type BaselineInventory struct {
	Path             string `json:"path"`
	SchemaVersion    int    `json:"schema_version"`
	Digest           string `json:"digest"`
	ObservationState string `json:"observation_state"`
}

type BuildFlag

type BuildFlag struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type CacheEntry

type CacheEntry struct {
	Key             string
	ToolchainDigest string
	Checksum        string
	TrustTier       string
	WrittenBy       string
	WriterDigest    string
	PlanDigest      string
	PolicyDigest    string
	SourceCommit    string
	SourceTree      string
	Mode            string
	Coordinate      string
	CreatedAt       time.Time
	ExpiresAt       time.Time
}

type CacheKeyMaterial

type CacheKeyMaterial struct {
	SchemaVersion int              `json:"schema_version"`
	PolicyVersion string           `json:"policy_version"`
	PolicyDigest  string           `json:"policy_digest"`
	Source        SourceRevision   `json:"source"`
	Mode          string           `json:"mode"`
	Coordinate    string           `json:"coordinate"`
	Capability    string           `json:"capability"`
	Platform      string           `json:"platform"`
	OS            string           `json:"os"`
	Architecture  string           `json:"architecture"`
	Dependencies  []IdentityDigest `json:"dependencies"`
	Toolchains    []IdentityDigest `json:"toolchains"`
	BuildFlags    []BuildFlag      `json:"build_flags"`
}

type CacheManifest

type CacheManifest struct {
	SchemaVersion  int    `json:"schema_version"`
	ManifestDigest string `json:"manifest_digest"`
	CacheKey       string `json:"cache_key"`
	CacheKeyDigest string `json:"cache_key_digest"`
	CacheFormat    string `json:"cache_format"`
	CacheDigest    string `json:"cache_digest"`

	PolicyVersion   string         `json:"policy_version"`
	PolicyDigest    string         `json:"policy_digest"`
	PlanDigest      string         `json:"plan_digest"`
	ResultDigest    string         `json:"result_digest"`
	DetectorVersion string         `json:"detector_version"`
	DetectorDigest  string         `json:"detector_digest"`
	Source          SourceRevision `json:"source"`
	Event           EventSelection `json:"event"`
	TrustTier       string         `json:"trust_tier"`

	Mode         string            `json:"mode"`
	Coordinate   string            `json:"coordinate"`
	Capability   string            `json:"capability"`
	Platform     string            `json:"platform"`
	OS           string            `json:"os"`
	Architecture string            `json:"architecture"`
	CostClass    string            `json:"cost_class"`
	Requiredness string            `json:"requiredness"`
	Matrix       map[string]string `json:"matrix"`

	Dependencies []IdentityDigest `json:"dependencies"`
	Toolchains   []IdentityDigest `json:"toolchains"`
	BuildFlags   []BuildFlag      `json:"build_flags"`
	Files        []ArtifactFile   `json:"files"`
	Provenance   CacheProvenance  `json:"provenance"`
}

func DecodeCacheManifest

func DecodeCacheManifest(name string, data []byte) (CacheManifest, error)

func NewCacheManifest

func NewCacheManifest(policy Manifest, plan RunPlan, result ResultRecord, input CacheManifestInput) (CacheManifest, error)

func ReadCacheManifest

func ReadCacheManifest(path string) (CacheManifest, error)

func (CacheManifest) Canonical

func (cache CacheManifest) Canonical() CacheManifest

func (CacheManifest) Digest

func (cache CacheManifest) Digest() (string, error)

func (CacheManifest) ExpectedKeyDigest

func (cache CacheManifest) ExpectedKeyDigest() (string, error)

func (CacheManifest) MarshalCanonical

func (cache CacheManifest) MarshalCanonical() ([]byte, error)

type CacheManifestInput

type CacheManifestInput struct {
	CacheFormat  string
	CacheDigest  string
	Dependencies []IdentityDigest
	Toolchains   []IdentityDigest
	BuildFlags   []BuildFlag
	Files        []ArtifactFile
	Provenance   CacheProvenance
}

type CacheProvenance

type CacheProvenance struct {
	Workflow       string `json:"workflow"`
	WorkflowSHA256 string `json:"workflow_sha256"`
	RunID          int64  `json:"run_id"`
	RunAttempt     int    `json:"run_attempt"`
	JobID          string `json:"job_id"`
	JobName        string `json:"job_name"`
	ProducerStatus string `json:"producer_status"`
	UploadComplete bool   `json:"upload_complete"`
	CacheKey       string `json:"cache_key"`
	CacheDigest    string `json:"cache_digest"`
}

type CacheReadOptions

type CacheReadOptions struct {
	Dependencies []IdentityDigest
	Toolchains   []IdentityDigest
	BuildFlags   []BuildFlag
}

type CacheRequest

type CacheRequest struct {
	Plan            RunPlan
	Job             PlanJob
	Key             string
	ToolchainDigest string
	Checksum        string
	TrustTier       string
	Now             time.Time
}

type CacheRestoreCheck

type CacheRestoreCheck struct {
	Job     PlanJob
	Request CacheRequest
	Entry   CacheEntry
}

type Capability

type Capability struct {
	ID          string   `json:"id"`
	Owner       string   `json:"owner"`
	Description string   `json:"description"`
	Modes       []string `json:"modes"`
}

type Coordinate

type Coordinate struct {
	ID           string            `json:"id"`
	Platform     string            `json:"platform"`
	Matrix       map[string]string `json:"matrix"`
	Requiredness string            `json:"requiredness"`
	GitHubName   string            `json:"github_name"`
	EvidenceRefs []string          `json:"evidence_refs"`
	Trace        LegacyTrace       `json:"trace"`
}

type CostClass

type CostClass struct {
	ID          string `json:"id"`
	Owner       string `json:"owner"`
	Description string `json:"description"`
}

type CredentialOperation

type CredentialOperation struct {
	Operation  string
	TrustTier  string
	Capability string
	Token      SyntheticToken
	Target     string
}

type Detection

type Detection struct {
	DetectorVersion    string   `json:"detector_version"`
	DetectorDigest     string   `json:"detector_digest"`
	ExactFileList      bool     `json:"exact_file_list"`
	ChangedFilesDigest string   `json:"changed_files_digest"`
	Capabilities       []string `json:"capabilities"`
	Superset           bool     `json:"superset"`
	SupersetReasons    []string `json:"superset_reasons"`
	Errors             []string `json:"errors"`
}

func DetectCapabilities

func DetectCapabilities(changedFiles []string, exactFileList bool, detectorErrors []string) Detection

type EventIdentity

type EventIdentity struct {
	ID          string   `json:"id"`
	Source      string   `json:"source"`
	GitHubEvent string   `json:"github_event"`
	Refs        []string `json:"refs"`
	TrustTiers  []string `json:"trust_tiers"`
	Description string   `json:"description"`
}

type EventInput

type EventInput struct {
	Source              string `json:"source"`
	GitHubEvent         string `json:"github_event"`
	Ref                 string `json:"ref"`
	BaseRef             string `json:"base_ref"`
	HeadRef             string `json:"head_ref"`
	BaseRepository      string `json:"base_repository"`
	HeadRepository      string `json:"head_repository"`
	Commit              string `json:"commit"`
	Tree                string `json:"tree"`
	PullRequestFork     bool   `json:"pull_request_fork"`
	SameRepositoryAgent bool   `json:"same_repository_agent"`
	TrustedBase         bool   `json:"trusted_base"`
	Publication         bool   `json:"publication"`
}

type EventSelection

type EventSelection struct {
	Source              string `json:"source"`
	Event               string `json:"event"`
	GitHubEvent         string `json:"github_event"`
	Ref                 string `json:"ref"`
	BaseRef             string `json:"base_ref"`
	HeadRef             string `json:"head_ref"`
	BaseRepository      string `json:"base_repository"`
	HeadRepository      string `json:"head_repository"`
	PullRequestFork     bool   `json:"pull_request_fork"`
	SameRepositoryAgent bool   `json:"same_repository_agent"`
	TrustedBase         bool   `json:"trusted_base"`
	Publication         bool   `json:"publication"`
}

func SelectEvent

func SelectEvent(manifest Manifest, input EventInput) (EventSelection, string, error)

type FanInDecision

type FanInDecision struct {
	Mode       string `json:"mode"`
	Coordinate string `json:"coordinate"`
	Status     string `json:"status"`
	Reason     string `json:"reason"`
}

type FanInReport

type FanInReport struct {
	SchemaVersion int             `json:"schema_version"`
	PlanDigest    string          `json:"plan_digest"`
	PolicyDigest  string          `json:"policy_digest"`
	Source        SourceRevision  `json:"source"`
	Event         EventSelection  `json:"event"`
	TrustTier     string          `json:"trust_tier"`
	Status        string          `json:"status"`
	Accepted      []FanInDecision `json:"accepted"`
	Rejected      []FanInDecision `json:"rejected"`
}

func FanIn

func FanIn(manifest Manifest, plan RunPlan, results []ResultRecord, now time.Time) (FanInReport, error)

func FanInFixture

func FanInFixture(manifest Manifest, plan RunPlan, workflowData GeneratedWorkflowData, observations []JobObservation, now time.Time) (FanInReport, error)

func RunHermeticFixture

func RunHermeticFixture(run FixtureRun) (FanInReport, error)

type FaultInjection

type FaultInjection struct {
	ID    string
	Apply func(*FixtureRun)
}

type FixtureFile

type FixtureFile struct {
	Path    string `json:"path"`
	SHA256  string `json:"sha256"`
	Content []byte `json:"-"`
}

func P11KnownFilesFromRepository

func P11KnownFilesFromRepository(repoRoot string, manifest Manifest, extraPaths []string) ([]FixtureFile, error)

type FixtureRun

type FixtureRun struct {
	Manifest             Manifest
	KnownFiles           []FixtureFile
	Environment          map[string]string
	PlanOptions          PlanOptions
	WorkflowData         GeneratedWorkflowData
	Observations         []JobObservation
	CacheRestores        []CacheRestoreCheck
	Artifacts            []ArtifactCheck
	ArchiveComparisons   []ArchiveComparison
	CredentialOperations []CredentialOperation
	Now                  time.Time
}

func ApplyFault

func ApplyFault(run FixtureRun, fault FaultInjection) (FixtureRun, error)

type GeneratedUnsupported

type GeneratedUnsupported struct {
	Mode         string `json:"mode"`
	Coordinate   string `json:"coordinate"`
	Platform     string `json:"platform"`
	TrustTier    string `json:"trust_tier"`
	Requiredness string `json:"requiredness"`
	Status       string `json:"status,omitempty"`
}

type GeneratedWorkflowData

type GeneratedWorkflowData struct {
	SchemaVersion int                    `json:"schema_version"`
	PolicyVersion string                 `json:"policy_version"`
	PolicyDigest  string                 `json:"policy_digest"`
	PlanDigest    string                 `json:"plan_digest"`
	Jobs          []GeneratedWorkflowJob `json:"jobs"`
	Unsupported   []GeneratedUnsupported `json:"unsupported"`
}

func GenerateWorkflowData

func GenerateWorkflowData(plan RunPlan) GeneratedWorkflowData

func (GeneratedWorkflowData) ValidateAgainstPlan

func (data GeneratedWorkflowData) ValidateAgainstPlan(plan RunPlan) error

type GeneratedWorkflowJob

type GeneratedWorkflowJob struct {
	Mode       string            `json:"mode"`
	Coordinate string            `json:"coordinate"`
	GitHubName string            `json:"github_name"`
	Display    string            `json:"display"`
	Platform   string            `json:"platform"`
	TrustTier  string            `json:"trust_tier"`
	Matrix     map[string]string `json:"matrix"`
}

type IdentityDigest

type IdentityDigest struct {
	ID      string `json:"id"`
	Version string `json:"version"`
	Digest  string `json:"digest"`
}

type JobObservation

type JobObservation struct {
	Mode           string
	Coordinate     string
	Display        string
	Status         string
	FailureClass   string
	StartedAt      time.Time
	CompletedAt    time.Time
	EvidenceDigest string
	ArtifactDigest string
	CacheDigest    string
	SupersededBy   string
	UploadComplete bool
}

type LegacyTrace

type LegacyTrace struct {
	InventoryMapping string `json:"inventory_mapping"`
	LegacyWorkflow   string `json:"legacy_workflow"`
	LegacyJob        string `json:"legacy_job"`
	WorkflowPath     string `json:"workflow_path"`
	WorkflowSHA256   string `json:"workflow_sha256"`
	LegacyCondition  string `json:"legacy_condition"`
	SkipSemantics    string `json:"skip_semantics"`
}

type Manifest

type Manifest struct {
	SchemaVersion int                   `json:"schema_version"`
	PolicyVersion string                `json:"policy_version"`
	PolicyDigest  string                `json:"policy_digest"`
	Source        SourceIdentity        `json:"source"`
	TrustTiers    []TrustTier           `json:"trust_tiers"`
	Events        []EventIdentity       `json:"events"`
	Platforms     []Platform            `json:"platforms"`
	CostClasses   []CostClass           `json:"cost_classes"`
	Capabilities  []Capability          `json:"capabilities"`
	Modes         []Mode                `json:"modes"`
	Unsupported   []UnsupportedDecision `json:"unsupported"`
}

func DecodeManifest

func DecodeManifest(name string, data []byte) (Manifest, error)

func FromInventory

func FromInventory(inventory cibaseline.Inventory) (Manifest, error)

func GenerateFromInventoryPath

func GenerateFromInventoryPath(path string) (Manifest, error)

func ReadManifest

func ReadManifest(path string) (Manifest, error)

func (Manifest) Canonical

func (manifest Manifest) Canonical() Manifest

func (Manifest) Digest

func (manifest Manifest) Digest() (string, error)

func (Manifest) MarshalCanonical

func (manifest Manifest) MarshalCanonical() ([]byte, error)

func (Manifest) Validate

func (manifest Manifest) Validate() error

func (Manifest) ValidateAt

func (manifest Manifest) ValidateAt(now time.Time) error

type Mode

type Mode struct {
	ID           string        `json:"id"`
	Capability   string        `json:"capability"`
	Owner        string        `json:"owner"`
	Requiredness string        `json:"requiredness"`
	CostClass    string        `json:"cost_class"`
	ProofType    string        `json:"proof_type"`
	SourceEvents []SourceEvent `json:"source_events"`
	TrustTiers   []string      `json:"trust_tiers"`
	Coordinates  []Coordinate  `json:"coordinates"`
	EvidenceRefs []string      `json:"evidence_refs"`
	Trace        LegacyTrace   `json:"trace"`
}

type P11CompatibilityComparison

type P11CompatibilityComparison struct {
	ID              string
	HelperPath      string
	PlanDigest      string
	TrustTier       string
	Capabilities    []string
	RequiredModes   []string
	Coordinates     []string
	Superset        bool
	SupersetReasons []string
	FanInStatus     string
	AcceptedCount   int
}

func CompareP11CompatibilitySamples

func CompareP11CompatibilitySamples(manifest Manifest, knownFiles []FixtureFile, samples []P11CompatibilitySample, now time.Time) ([]P11CompatibilityComparison, error)

type P11CompatibilitySample

type P11CompatibilitySample struct {
	ID                         string
	HelperPath                 string
	Description                string
	PlanOptions                PlanOptions
	ExpectedTrustTier          string
	ExpectedCapabilities       []string
	ExpectedSupersetReasons    []string
	ExpectedManifestModes      []P11ManifestModeExpectation
	ExpectedPresentCoordinates []string
	ExpectedAbsentCoordinates  []string
	CredentialExpectations     []P11CredentialExpectation
}

type P11CompatibilitySampleRequirement

type P11CompatibilitySampleRequirement struct {
	ID          string
	Description string
}

func P11RegenAuthCompatibilityRequirements

func P11RegenAuthCompatibilityRequirements() []P11CompatibilitySampleRequirement

type P11CredentialExpectation

type P11CredentialExpectation struct {
	Operation           CredentialOperation
	Allowed             bool
	BindToPlan          bool
	PlanTrustTier       string
	CredentialTrustTier string
	WantErrorSubstr     string
}

type P11JSHelperContract

type P11JSHelperContract struct {
	Path                 string
	Owner                string
	Kind                 string
	Callers              []string
	PolicyInputs         []string
	PolicyOutputs        []string
	Disposition          string
	ExecutableContract   string
	DeletionCriterion    string
	CompatibilitySamples []P11CompatibilitySampleRequirement
	Tranche              string
}

func P11JSSurfaceContracts

func P11JSSurfaceContracts() []P11JSHelperContract

type P11ManifestCoordinateExpectation

type P11ManifestCoordinateExpectation struct {
	ID           string
	Requiredness string
}

type P11ManifestModeExpectation

type P11ManifestModeExpectation struct {
	ID           string
	Capability   string
	Requiredness string
	TrustTiers   []string
	Coordinates  []P11ManifestCoordinateExpectation
}

type P11WorkflowJob

type P11WorkflowJob struct {
	Name                  string
	If                    string
	Needs                 []string
	RunsOn                string
	Permissions           map[string]string
	PermissionsExpression string
	Env                   map[string]string
	Steps                 []P11WorkflowStep
}

type P11WorkflowStep

type P11WorkflowStep struct {
	Name string
	Uses string
	If   string
	Env  map[string]string
	With map[string]string
	Run  string
}

type P11WorkflowSummary

type P11WorkflowSummary struct {
	Name                  string
	Events                []string
	Permissions           map[string]string
	PermissionsExpression string
	Env                   map[string]string
	Jobs                  map[string]P11WorkflowJob
}

func ReadP11WorkflowSummary

func ReadP11WorkflowSummary(path string) (P11WorkflowSummary, error)

type PlanJob

type PlanJob struct {
	Source       string            `json:"source"`
	Event        string            `json:"event"`
	TrustTier    string            `json:"trust_tier"`
	Mode         string            `json:"mode"`
	Coordinate   string            `json:"coordinate"`
	Capability   string            `json:"capability"`
	Platform     string            `json:"platform"`
	CostClass    string            `json:"cost_class"`
	Requiredness string            `json:"requiredness"`
	Owner        string            `json:"owner"`
	GitHubName   string            `json:"github_name"`
	Matrix       map[string]string `json:"matrix"`
	EvidenceRefs []string          `json:"evidence_refs"`
}

type PlanOptions

type PlanOptions struct {
	Event           EventInput
	ChangedFiles    []string
	ExactFileList   bool
	DetectorVersion string
	DetectorErrors  []string
	CreatedAt       time.Time
	ExpiresAt       time.Time
	Now             time.Time
	PlanTTL         time.Duration
}

type PlanUnsupportedDecision

type PlanUnsupportedDecision struct {
	Mode              string   `json:"mode"`
	Coordinate        string   `json:"coordinate"`
	Source            string   `json:"source"`
	Event             string   `json:"event"`
	Platform          string   `json:"platform"`
	TrustTier         string   `json:"trust_tier"`
	Requiredness      string   `json:"requiredness"`
	Owner             string   `json:"owner"`
	Rationale         string   `json:"rationale"`
	Expires           string   `json:"expires"`
	SilentPassAllowed bool     `json:"silent_pass_allowed"`
	EvidenceRefs      []string `json:"evidence_refs"`
}

type Platform

type Platform struct {
	ID           string `json:"id"`
	Owner        string `json:"owner"`
	RunnerLabel  string `json:"runner_label"`
	OS           string `json:"os"`
	Architecture string `json:"architecture"`
	Description  string `json:"description"`
}

type ResultAttempt

type ResultAttempt struct {
	Attempt        int       `json:"attempt"`
	Status         string    `json:"status"`
	FailureClass   string    `json:"failure_class"`
	StartedAt      time.Time `json:"started_at"`
	CompletedAt    time.Time `json:"completed_at"`
	EvidenceDigest string    `json:"evidence_digest"`
	ArtifactDigest string    `json:"artifact_digest"`
	CacheDigest    string    `json:"cache_digest"`
}

type ResultRecord

type ResultRecord struct {
	SchemaVersion     int               `json:"schema_version"`
	ResultDigest      string            `json:"result_digest"`
	PlanDigest        string            `json:"plan_digest"`
	PolicyVersion     string            `json:"policy_version"`
	PolicyDigest      string            `json:"policy_digest"`
	DetectorVersion   string            `json:"detector_version"`
	DetectorDigest    string            `json:"detector_digest"`
	Source            SourceRevision    `json:"source"`
	Event             EventSelection    `json:"event"`
	TrustTier         string            `json:"trust_tier"`
	Mode              string            `json:"mode"`
	Coordinate        string            `json:"coordinate"`
	Capability        string            `json:"capability"`
	Platform          string            `json:"platform"`
	CostClass         string            `json:"cost_class"`
	Requiredness      string            `json:"requiredness"`
	Owner             string            `json:"owner"`
	Matrix            map[string]string `json:"matrix"`
	Attempts          []ResultAttempt   `json:"attempts"`
	FirstStatus       string            `json:"first_status"`
	FirstFailureClass string            `json:"first_failure_class"`
	Status            string            `json:"status"`
	FailureClass      string            `json:"failure_class"`
	StartedAt         time.Time         `json:"started_at"`
	CompletedAt       time.Time         `json:"completed_at"`
	EvidenceDigest    string            `json:"evidence_digest"`
	ArtifactDigest    string            `json:"artifact_digest"`
	CacheDigest       string            `json:"cache_digest"`
	SupersededBy      string            `json:"superseded_by"`
}

func NewResultRecord

func NewResultRecord(plan RunPlan, job PlanJob, attempts []ResultAttempt) (ResultRecord, error)

func NewSupersededResultRecord

func NewSupersededResultRecord(plan RunPlan, job PlanJob, attempts []ResultAttempt, supersededBy string) (ResultRecord, error)

func (ResultRecord) Canonical

func (result ResultRecord) Canonical() ResultRecord

func (ResultRecord) Digest

func (result ResultRecord) Digest() (string, error)

func (ResultRecord) MarshalCanonical

func (result ResultRecord) MarshalCanonical() ([]byte, error)

type RunPlan

type RunPlan struct {
	SchemaVersion        int                       `json:"schema_version"`
	PlanDigest           string                    `json:"plan_digest"`
	PolicyVersion        string                    `json:"policy_version"`
	PolicyDigest         string                    `json:"policy_digest"`
	DetectorVersion      string                    `json:"detector_version"`
	DetectorDigest       string                    `json:"detector_digest"`
	Source               SourceRevision            `json:"source"`
	Event                EventSelection            `json:"event"`
	TrustTier            string                    `json:"trust_tier"`
	DetectedCapabilities []string                  `json:"detected_capabilities"`
	Capabilities         []string                  `json:"capabilities"`
	RequiredModes        []string                  `json:"required_modes"`
	Jobs                 []PlanJob                 `json:"jobs"`
	Unsupported          []PlanUnsupportedDecision `json:"unsupported"`
	ExactFileList        bool                      `json:"exact_file_list"`
	ChangedFilesDigest   string                    `json:"changed_files_digest"`
	Superset             bool                      `json:"superset"`
	SupersetReasons      []string                  `json:"superset_reasons"`
	DetectorErrors       []string                  `json:"detector_errors"`
	CreatedAt            time.Time                 `json:"created_at"`
	ExpiresAt            time.Time                 `json:"expires_at"`
}

func BuildHermeticPlan

func BuildHermeticPlan(manifest Manifest, knownFiles []FixtureFile, options PlanOptions) (RunPlan, error)

func BuildPlan

func BuildPlan(manifest Manifest, options PlanOptions) (RunPlan, error)

func (RunPlan) Canonical

func (plan RunPlan) Canonical() RunPlan

func (RunPlan) Digest

func (plan RunPlan) Digest() (string, error)

func (RunPlan) MarshalCanonical

func (plan RunPlan) MarshalCanonical() ([]byte, error)

func (RunPlan) Validate

func (plan RunPlan) Validate(manifest Manifest) error

func (RunPlan) ValidateAt

func (plan RunPlan) ValidateAt(manifest Manifest, now time.Time) error

type SourceEvent

type SourceEvent struct {
	Source string `json:"source"`
	Event  string `json:"event"`
}

type SourceIdentity

type SourceIdentity struct {
	ID                string            `json:"id"`
	Repository        string            `json:"repository"`
	DefaultBranch     string            `json:"default_branch"`
	PolicyPath        string            `json:"policy_path"`
	BaselineInventory BaselineInventory `json:"baseline_inventory"`
}

type SourceRevision

type SourceRevision struct {
	Repository     string `json:"repository"`
	Ref            string `json:"ref"`
	Commit         string `json:"commit"`
	Tree           string `json:"tree"`
	BaseRef        string `json:"base_ref"`
	HeadRef        string `json:"head_ref"`
	HeadRepository string `json:"head_repository"`
}

type SyntheticToken

type SyntheticToken struct {
	Name         string
	TrustTier    string
	Class        string
	Scopes       []string
	AllowedRoots []string
}

type TrustTier

type TrustTier struct {
	ID                     string `json:"id"`
	Owner                  string `json:"owner"`
	Description            string `json:"description"`
	PublicationCredentials bool   `json:"publication_credentials"`
}

type UnsupportedDecision

type UnsupportedDecision struct {
	Mode              string   `json:"mode"`
	Coordinate        string   `json:"coordinate"`
	Source            string   `json:"source"`
	Event             string   `json:"event"`
	Platform          string   `json:"platform"`
	TrustTier         string   `json:"trust_tier"`
	Requiredness      string   `json:"requiredness"`
	Owner             string   `json:"owner"`
	Rationale         string   `json:"rationale"`
	Expires           string   `json:"expires"`
	SilentPassAllowed bool     `json:"silent_pass_allowed"`
	EvidenceRefs      []string `json:"evidence_refs"`
}

Jump to

Keyboard shortcuts

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