Documentation
¶
Overview ¶
Package pbom provides Pipeline Bill of Materials (PBOM) generation.
A PBOM is an inventory of all dependencies used in a CI/CD pipeline, including container images and includes (components, templates, remote files). Unlike an SBOM (Software Bill of Materials) which tracks application dependencies, a PBOM tracks pipeline infrastructure dependencies.
Index ¶
- Constants
- type ContainerImage
- type CycloneDX
- type CycloneDXComponent
- type CycloneDXMetadata
- type CycloneDXProperty
- type CycloneDXTool
- type Generator
- func (g *Generator) Generate(imageData *gitlab.GitlabPipelineImageData, ...) *PBOM
- func (g *Generator) GenerateFromGitHubIR(pipeline *ir.NormalizedPipeline) *PBOM
- func (g *Generator) WithCommit(sha, ref string) *Generator
- func (g *Generator) WithComplianceData(data *ImageComplianceData) *Generator
- func (g *Generator) WithGitHubComplianceData(data *GitHubComplianceData) *Generator
- func (g *Generator) WithIncludeOverrideData(data *IncludeOverrideData) *Generator
- func (g *Generator) WithoutComplianceVerdicts() *Generator
- type GitHubComplianceData
- type ImageComplianceData
- type Include
- type IncludeOverrideData
- type PBOM
- type PlatformGlobalScore
- type PlatformSummary
- type PlumberScoreCounts
- type PlumberScoreSummary
- type PolicyScore
- type ProjectInfo
- type Summary
Constants ¶
const CycloneDXSpecVersion = "1.5"
CycloneDX spec version we're generating
const Version = "1.0.0"
Version is the current PBOM specification version
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerImage ¶
type ContainerImage struct {
// Full image reference (e.g., "docker.io/library/golang:1.22-alpine")
Image string `json:"image"`
// Parsed components
Registry string `json:"registry"`
Name string `json:"name"`
Tag string `json:"tag,omitempty"`
// Usage context
Jobs []string `json:"jobs"`
// Compliance status (from analysis, if available)
Authorized *bool `json:"authorized,omitempty"`
ForbiddenTag *bool `json:"forbiddenTag,omitempty"`
}
ContainerImage represents a container image used in the pipeline
type CycloneDX ¶
type CycloneDX struct {
BOMFormat string `json:"bomFormat"`
SpecVersion string `json:"specVersion"`
Version int `json:"version"`
SerialNumber string `json:"serialNumber"`
Metadata CycloneDXMetadata `json:"metadata"`
Components []CycloneDXComponent `json:"components"`
}
CycloneDX represents a CycloneDX SBOM Spec: https://cyclonedx.org/docs/1.5/json/ Struct field order matches a natural read path: BOM header, identifiers, metadata (project/tool), dependency components last.
type CycloneDXComponent ¶
type CycloneDXComponent struct {
Type string `json:"type"`
BOMRef string `json:"bom-ref,omitempty"`
Name string `json:"name"`
Version string `json:"version,omitempty"`
Description string `json:"description,omitempty"`
Purl string `json:"purl,omitempty"`
Properties []CycloneDXProperty `json:"properties,omitempty"`
}
CycloneDXComponent represents a component in the BOM
type CycloneDXMetadata ¶
type CycloneDXMetadata struct {
Timestamp string `json:"timestamp"`
Tools []CycloneDXTool `json:"tools,omitempty"`
Component *CycloneDXComponent `json:"component,omitempty"`
Properties []CycloneDXProperty `json:"properties,omitempty"`
}
CycloneDXMetadata contains metadata about the BOM
type CycloneDXProperty ¶
CycloneDXProperty represents a name-value property
type CycloneDXTool ¶
type CycloneDXTool struct {
Vendor string `json:"vendor"`
Name string `json:"name"`
Version string `json:"version"`
}
CycloneDXTool describes a tool used to create the BOM
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator creates PBOMs from pipeline analysis data
func NewGenerator ¶
NewGenerator creates a new PBOM generator
func NewGitHubGenerator ¶ added in v0.3.0
NewGitHubGenerator creates a PBOM generator pre-configured for the GitHub provider. URL is the GitHub host (`github.com` or a GHES host); branch is informational, used to stamp the project section.
func (*Generator) Generate ¶
func (g *Generator) Generate( imageData *gitlab.GitlabPipelineImageData, originData *gitlab.GitlabPipelineOriginData, ) *PBOM
Generate creates a PBOM from pipeline data collections
func (*Generator) GenerateFromGitHubIR ¶ added in v0.3.0
func (g *Generator) GenerateFromGitHubIR(pipeline *ir.NormalizedPipeline) *PBOM
GenerateFromGitHubIR builds a PBOM from the normalized GitHub pipeline IR. Container images are extracted from each job's `image:` and `services:` blocks; the GitHub analogue of GitLab's "include" list is the merged set of third-party action references (`uses: owner/repo@ref`) and reusable-workflow calls (`jobs.<name>.uses: …/.github/workflows/x.yml@ref`).
func (*Generator) WithCommit ¶ added in v0.4.52
WithCommit attaches the resolved analyzed commit and its branch/tag so the PBOM names the exact code it describes (#443).
func (*Generator) WithComplianceData ¶
func (g *Generator) WithComplianceData(data *ImageComplianceData) *Generator
func (*Generator) WithGitHubComplianceData ¶ added in v0.3.0
func (g *Generator) WithGitHubComplianceData(data *GitHubComplianceData) *Generator
WithGitHubComplianceData attaches per-image and per-action compliance lookups so the resulting PBOM marks each image with its authorized/forbiddenTag flags and each action with a custom property for unpinned status.
func (*Generator) WithIncludeOverrideData ¶ added in v0.1.47
func (g *Generator) WithIncludeOverrideData(data *IncludeOverrideData) *Generator
WithIncludeOverrideData attaches override detection results so the PBOM marks overridden includes
func (*Generator) WithoutComplianceVerdicts ¶ added in v0.4.48
WithComplianceData attaches compliance results so the PBOM includes authorized/forbiddenTag fields WithoutComplianceVerdicts suppresses the include fields that state a CONTROL'S CONCLUSION rather than what was collected. It backs --no-controls.
`UpToDate` is the one that matters: unlike the image flags it is computed during data collection (the origin collector probes the upstream ref), so it survives even when no policy is evaluated, and it is exactly what includesMustBeUpToDate reports. `LatestVersion` is kept: the upstream version is a collected fact and asserts nothing on its own.
type GitHubComplianceData ¶ added in v0.3.0
type GitHubComplianceData struct {
// ForbiddenTagImages keys on the full image reference
// (`docker.io/golang:1.22`).
ForbiddenTagImages map[string]bool
// ImagesPinnedByDigest keys on the full image reference; true
// when the image carries an `@sha256:…` suffix.
ImagesPinnedByDigest map[string]bool
// UnpinnedActions keys on the full action ref (`actions/checkout@v4`);
// true when the ref is not a 40-char SHA.
UnpinnedActions map[string]bool
// ArchivedActions keys on the full action ref; true when the
// upstream repository is archived (ISSUE-702). Sourced from the
// per-action GitHub API metadata enrichment.
ArchivedActions map[string]bool
// VulnerableActions keys on the full action ref; true when the
// upstream repository has at least one published GitHub Advisory
// (ISSUE-703). Same metadata enrichment path as ArchivedActions.
VulnerableActions map[string]bool
// ActionAdvisories keys on the full action ref, value is the
// list of GHSA IDs published against the action's repository.
// Populated alongside VulnerableActions and surfaced into the
// Include / CDX layer so consumers see which advisories triggered
// the finding.
ActionAdvisories map[string][]string
}
GitHubComplianceData carries the GitHub-side compliance lookups the PBOM enriches container images and actions with. Mirrors ImageComplianceData on the GitLab side; kept separate because the keys (action ref vs include path) and providers differ.
func BuildGitHubPBOMCompliance ¶ added in v0.3.65
func BuildGitHubPBOMCompliance(result *control.AnalysisResult) *GitHubComplianceData
BuildGitHubPBOMCompliance walks Findings and the IR to assemble the per-image / per-action compliance lookup the PBOM generator uses to enrich entries.
type ImageComplianceData ¶
type ImageComplianceData struct {
// ForbiddenTagImages maps image links to true if they use a forbidden tag
ForbiddenTagImages map[string]bool
UnauthorizedImages map[string]bool
}
ImageComplianceData holds compliance results for images to enrich PBOM output
func BuildImageComplianceData ¶ added in v0.3.65
func BuildImageComplianceData(result *control.AnalysisResult) *ImageComplianceData
BuildImageComplianceData extracts per-image compliance flags from an AnalysisResult into the lookup map consumed by the PBOM generator.
type Include ¶
type Include struct {
// Type of include: "component", "project", "local", "remote",
// "template" (GitLab) or "action", "reusableWorkflow" (GitHub).
Type string `json:"type"`
// Location/path of the include
Location string `json:"location"`
// For project includes
Project string `json:"project,omitempty"`
// Version information
Version string `json:"version,omitempty"`
LatestVersion string `json:"latestVersion,omitempty"`
UpToDate *bool `json:"upToDate,omitempty"`
// For components from GitLab CI/CD Catalog
ComponentName string `json:"componentName,omitempty"`
FromCatalog bool `json:"fromCatalog,omitempty"`
// Whether this is a nested include (included by another include)
Nested bool `json:"nested,omitempty"`
// Override information (populated from control results)
Overridden bool `json:"overridden,omitempty"`
OverriddenJobs []utils.OverriddenJobDetail `json:"overriddenJobs,omitempty"`
// GitHub-only compliance enrichments populated from GitHubComplianceData.
// Archived is true when the action's upstream repository is archived
// (ISSUE-702). HasCVE is true when the action's upstream carries at
// least one published GitHub Advisory (ISSUE-703). Advisories is the
// list of GHSA IDs that triggered HasCVE.
Archived *bool `json:"archived,omitempty"`
HasCVE *bool `json:"hasCve,omitempty"`
Advisories []string `json:"advisories,omitempty"`
}
Include represents an include/component/template used in the pipeline. On GitHub, the analogue of GitLab's "include" types are:
- "action" — third-party `uses: owner/repo@ref` step
- "reusableWorkflow" — `uses:` at the job level pointing at a reusable-workflow file
type IncludeOverrideData ¶ added in v0.1.47
type IncludeOverrideData struct {
// Overrides maps a clean include path to its overridden job details
Overrides map[string][]utils.OverriddenJobDetail
}
IncludeOverrideData holds override detection results for includes. Key is the clean include location path (without version/instance prefix).
func BuildIncludeOverrideData ¶ added in v0.3.65
func BuildIncludeOverrideData(result *control.AnalysisResult) *IncludeOverrideData
BuildIncludeOverrideData extracts include-override detection results from an AnalysisResult into the lookup map consumed by the PBOM generator.
type PBOM ¶
type PBOM struct {
PBOMVersion string `json:"pbomVersion"`
GeneratedAt time.Time `json:"generatedAt"`
Project ProjectInfo `json:"project"`
Summary Summary `json:"summary"`
PlumberScore *PlumberScoreSummary `json:"plumberScore,omitempty"`
// Policies and PlatformGlobalScore are the platform-mode score block
// (spec 2026-09-10-cli-platform-mode-policies-only s5). In that mode
// there is no run-level score to put in PlumberScore: every verdict
// belongs to one of the platform's policies, and the single global
// figure is the platform's own, present only when the push returned one.
// Both are absent from a standalone PBOM.
Policies []PolicyScore `json:"policies,omitempty"`
PlatformGlobalScore *PlatformGlobalScore `json:"platformGlobalScore,omitempty"`
ContainerImages []ContainerImage `json:"containerImages"`
Includes []Include `json:"includes"`
}
PBOM represents a Pipeline Bill of Materials - an inventory of all dependencies used in a CI/CD pipeline. JSON field order follows encode/json struct order: version stamp, project context, aggregate summary, score, then inventories (read top-to-bottom).
func (*PBOM) ApplyPlatformSummary ¶ added in v0.4.60
func (p *PBOM) ApplyPlatformSummary(s *PlatformSummary)
ApplyPlatformSummary stamps the platform-mode score block onto a document: the per-policy verdicts and the platform's own global score. A no-op for a standalone run (nil summary), which is what keeps those documents byte-identical.
It is the counterpart of BuildPlumberScoreSummary and deliberately does not touch PlumberScore: in platform mode there is no run-level score to write there, and the caller has already passed a nil one.
func (*PBOM) ToCycloneDX ¶
ToCycloneDX converts a PBOM to CycloneDX format
type PlatformGlobalScore ¶ added in v0.4.60
type PlatformGlobalScore struct {
Letter string `json:"letter,omitempty"`
Points int `json:"points"`
}
PlatformGlobalScore is the platform's own displayed score for the run, as the push response returned it. It is never computed CLI-side.
type PlatformSummary ¶ added in v0.4.60
type PlatformSummary struct {
Policies []PolicyScore
GlobalScore *PlatformGlobalScore
ForbiddenTagEvaluated bool
AuthorizedSourceEvaluated bool
}
PlatformSummary is what a platform-mode run hands the PBOM writers: the per-policy verdicts and the platform's global score (nil when the push returned none). nil itself outside platform mode.
ForbiddenTagEvaluated and AuthorizedSourceEvaluated are false when no resolved policy enables the control behind that per-image boolean. The booleans are a POSITIVE claim - an image no finding names is published as authorized, with no forbidden tag - so with no policy asking for a control the writers drop ITS boolean and the image is reported as inventory alone on that axis. Both fields are already *bool, so dropping one is the existing tri-state, not a schema change.
They are two flags rather than one because the two controls are independent: a policy commonly pins tags without also restricting registries. Answering for both at once published the other control's positive verdict, which is exactly the claim-nobody-evaluated failure these flags exist to prevent.
type PlumberScoreCounts ¶ added in v0.1.83
type PlumberScoreCounts struct {
Critical int `json:"critical"`
High int `json:"high"`
Medium int `json:"medium"`
Low int `json:"low"`
}
PlumberScoreCounts is the number of issues per severity bucket.
type PlumberScoreSummary ¶ added in v0.1.83
type PlumberScoreSummary struct {
ProfileID string `json:"profileId"`
RawPoints float64 `json:"rawPoints"`
FinalPoints float64 `json:"finalPoints"`
Score string `json:"score,omitempty"`
CriticalMalusApplied bool `json:"criticalMalusApplied,omitempty"`
CriticalMalusMax float64 `json:"criticalMalusMax,omitempty"`
Counts PlumberScoreCounts `json:"counts"`
}
PlumberScoreSummary mirrors control.PlumberScoreResult for JSON consumers (PBOM / SBOM).
func BuildPlumberScoreSummary ¶ added in v0.3.65
func BuildPlumberScoreSummary(score *control.PlumberScoreResult, scoreMode bool) *PlumberScoreSummary
BuildPlumberScoreSummary converts a PlumberScoreResult into the PBOM PlumberScoreSummary shape. Returns nil when scoreMode is false or score is nil (no score in output).
type PolicyScore ¶ added in v0.4.60
type PolicyScore struct {
Name string `json:"name"`
Enforcement string `json:"enforcement"`
Score string `json:"score,omitempty"`
FinalPoints *int `json:"finalPoints,omitempty"`
Applied bool `json:"applied"`
Reason string `json:"reason,omitempty"`
}
PolicyScore is one resolved platform policy's own verdict over its own control set. Score and FinalPoints are omitted for a policy the CLI could not evaluate (Applied false, Reason says why): a letter-less zero would read as a policy that scored badly rather than one that ran nothing.
type ProjectInfo ¶
type ProjectInfo struct {
Path string `json:"path"`
ID int `json:"id,omitempty"`
Provider string `json:"provider,omitempty"`
URL string `json:"url,omitempty"`
GitLabURL string `json:"gitlabUrl,omitempty"`
Branch string `json:"branch,omitempty"`
// CommitSHA and Ref are the analyzed commit and its branch/tag (#443).
// Empty when the commit could not be resolved.
CommitSHA string `json:"commitSHA,omitempty"`
Ref string `json:"ref,omitempty"`
}
ProjectInfo contains information about the analyzed project. Provider names which CI platform produced this PBOM ("gitlab" or "github"). URL is the platform host used by the analysis (full URL on GitLab, host or host/api/v3 on GitHub). GitLabURL is kept for backward compatibility with v0.2.x consumers that key on it; new readers should prefer Provider + URL.
type Summary ¶
type Summary struct {
// Image counts
TotalImages int `json:"totalImages"`
UniqueRegistries int `json:"uniqueRegistries"`
// Include counts
TotalIncludes int `json:"totalIncludes"`
Components int `json:"components"`
ProjectIncludes int `json:"projectIncludes"`
LocalIncludes int `json:"localIncludes"`
RemoteIncludes int `json:"remoteIncludes"`
Templates int `json:"templates"`
// GitHub-specific include counts. Always emitted (matches the
// pattern the GitLab-side counters above use — zero is meaningful
// and gets serialised as `0`, not dropped).
Actions int `json:"actions"`
ReusableWorkflows int `json:"reusableWorkflows"`
}
Summary provides aggregate statistics about the pipeline dependencies