Documentation
¶
Overview ¶
Package policy evaluates deploy guardrail rules against what an app is about to run. It is pure: callers resolve the layers and the subject.
Index ¶
Constants ¶
const ( ScopeOrg = "org" ScopeProject = "project" ScopeEnvironment = "environment" // OrgScopeID is the single organization-wide scope id. OrgScopeID = "org" )
Scopes a rule set can be attached to, least to most specific.
const ( RuleAllowedRegistries = "allowed_registries" RuleRequireReadiness = "require_readiness_probe" RuleMaxMemoryMB = "max_memory_mb" RuleMaxCPU = "max_cpu" RuleForbidPrivileged = "forbid_privileged" RuleForbidHostMounts = "forbid_host_mounts" RuleRequiredLabels = "required_labels" RuleMaxReplicas = "max_replicas" RuleForbidLatestTag = "forbid_latest_tag" RuleRequireDigest = "require_image_digest" RuleRequireLimits = "require_resource_limits" RuleRequireSignature = "require_image_signature" )
Rule ids, the keys of a Set.
const ( CodeRegistryNotAllowed = "policy_registry_not_allowed" CodeReadinessRequired = "policy_readiness_probe_required" CodeMemoryCeiling = "policy_memory_ceiling_exceeded" CodeCPUCeiling = "policy_cpu_ceiling_exceeded" CodePrivilegedForbidden = "policy_privileged_forbidden" CodeHostMountForbidden = "policy_host_mount_forbidden" CodeLabelRequired = "policy_label_required" CodeReplicasExceeded = "policy_replicas_exceeded" CodeLatestTag = "policy_latest_tag_forbidden" CodeDigestRequired = "policy_image_digest_required" CodeLimitsRequired = "policy_resource_limits_required" CodeSignatureRequired = "policy_image_signature_required" CodeSignatureUnverified = "policy_image_signature_unverifiable" // CodeViolation is the response code of a blocked deploy. CodeViolation = "policy_violation" )
Stable machine readable violation codes.
const ( SigVerified = "verified" SigUnsigned = "unsigned" SigInvalid = "invalid" SigUntrusted = "untrusted" SigUnverifiable = "unverifiable" )
Signature verdict statuses.
const ( ReasonNotChecked = "not_checked" ReasonNoTrustedSigners = "no_trusted_signers" ReasonNotPinned = "image_not_pinned_by_digest" ReasonRegistryUnreachable = "registry_unreachable" ReasonTrustRootMissing = "trust_root_unavailable" ReasonTimeout = "verification_timed_out" ReasonNoSignature = "no_signature" ReasonBadSignature = "signature_invalid" ReasonSignerNotTrusted = "signer_not_trusted" )
Typed reasons a signature could not be verified or was refused.
Variables ¶
This section is empty.
Functions ¶
func CheckSignerItem ¶
CheckSignerItem validates one trusted signer list entry on write.
func RegistryOf ¶
RegistryOf returns the registry host an image reference pulls from.
Types ¶
type Mode ¶
type Mode string
Mode is how a rule reacts: off ignores it, warn reports it, enforce blocks.
type Rule ¶
type Rule struct {
Mode Mode `json:"mode"`
Values []string `json:"values,omitempty"`
Limit float64 `json:"limit,omitempty"`
}
Rule is one guardrail. Values carries list rules (registries, labels, allowed host path prefixes); Limit carries numeric ceilings.
type SignatureVerdict ¶
type SignatureVerdict struct {
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
Signer string `json:"signer,omitempty"`
Digest string `json:"digest,omitempty"`
}
SignatureVerdict is what verifying an image against the trusted signer list found. Signer names who signed when Status is verified.
type Signer ¶
Signer is one entry of the trusted signer list: a public key, or a keyless identity pinned to its OIDC issuer. Both parts of a keyless signer are matched exactly, never by pattern.
func ParseSigner ¶
ParseSigner reads "key:<base64 PKIX DER ECDSA key>" or "keyless:<issuer url>|<identity>".
func ParseSigners ¶
ParseSigners parses a list, skipping nothing: one bad entry fails the whole list so a typo cannot silently shrink what is trusted.
type Subject ¶
type Subject struct {
Image string
MemoryBytes int64
NanoCPUs int64
HasReadiness bool
Privileged bool
HostMounts []string
Labels map[string]string
Replicas int
// Signature is the image signature verdict. Nil means no check ran, which
// the signature rule treats as unverifiable rather than as a pass.
Signature *SignatureVerdict
}
Subject is the deploy being judged. Zero MemoryBytes or NanoCPUs mean no limit is set, which a ceiling treats as exceeding it.
type Violation ¶
type Violation struct {
Rule string `json:"rule"`
Code string `json:"code"`
Mode Mode `json:"mode"`
Message string `json:"message"`
NextAction string `json:"next_action"`
}
Violation is one rule a subject breaks, with a stable code and the next action for a human.