Documentation
¶
Overview ¶
Package enhancers holds the built-in pkg/enhance implementations: noop (the explicit "nothing configured" placeholder) and staticfile (a YAML-backed repo→ownership map that doubles as the fake CMDB for development and e2e). The real CMDB integration implements the same pkg/enhance.Enhancer seam later.
Index ¶
Constants ¶
const ( DefaultOrgLabel = "scm-repository-org" DefaultNameLabel = "scm-repository-name" DefaultProviderLabel = "scm-repository-provider" DefaultURLLabel = "scm-repository-url" )
Default label keys. A cloud resource says who owns it by carrying these; they are the bridge between an infrastructure finding and the repository whose code provisions the thing that is wrong.
Google Cloud label values are lowercase alphanumerics, hyphens and underscores, capped at 63 characters — which a URL cannot survive. Hence the triple: an org and a name both fit comfortably, and the URL form is there for security marks, whose values are far less constrained.
const GoogleCloudLabelsID = "google-cloud-labels"
GoogleCloudLabelsID is the enhancer's id.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssetLabels ¶ added in v0.8.0
type AssetLabels interface {
LabelsFor(ctx context.Context, resourceName string) (*gcpasset.Labels, error)
}
AssetLabels reads a cloud resource's labels. Declared here, next to its only consumer, so the enhancer's tests need no Google Cloud client.
type GoogleCloudLabels ¶ added in v0.8.0
type GoogleCloudLabels struct {
// contains filtered or unexported fields
}
GoogleCloudLabels resolves a finding's repository from the ownership labels on the Google Cloud resource it was raised against.
It answers only for Google Cloud findings, and it answers only about the repository: ownership by person is a different question, and the CMDB enhancer is the one that knows it.
func NewGoogleCloudLabels ¶ added in v0.8.0
func NewGoogleCloudLabels(o GoogleCloudOptions) (*GoogleCloudLabels, error)
NewGoogleCloudLabels builds the enhancer.
func (*GoogleCloudLabels) Enhance ¶ added in v0.8.0
func (g *GoogleCloudLabels) Enhance(ctx context.Context, issue enhance.Issue) (*enhance.Enrichment, error)
Enhance implements enhance.Enhancer.
A resource that exists but carries no ownership labels returns an enrichment with no repository rather than an error: that is a final answer, and reporting it as a failure would hold the finding out of sight instead of handing it to a human. Only a lookup that might succeed next time errors.
func (*GoogleCloudLabels) ID ¶ added in v0.8.0
func (*GoogleCloudLabels) ID() string
ID implements enhance.Enhancer.
type GoogleCloudOptions ¶ added in v0.8.0
type GoogleCloudOptions struct {
// Assets looks resources up. Required.
Assets AssetLabels
// Keys names the labels to read.
Keys LabelKeys
// DefaultHost is the forge host used when a resource names an org and a
// repository but no host. Empty means github.com, matching the default
// the Forge resolver already assumes.
DefaultHost string
// DefaultProvider is the forge family assumed when a resource names no
// provider. Empty means github.
DefaultProvider string
}
GoogleCloudOptions configure the enhancer.
type LabelKeys ¶ added in v0.8.0
LabelKeys names the labels the enhancer reads. Zero values fall back to the defaults, so an operator overrides only what differs from the convention.
type Noop ¶
type Noop struct{}
Noop is the placeholder enhancer used when no context source is configured: it records that enhancement ran with nothing to add, so the issue still advances through the pipeline.
type StaticFile ¶
type StaticFile struct {
// contains filtered or unexported fields
}
StaticFile enhances issues from a YAML map of repositories to ownership, attributes, and optional free-form markdown — the stand-in for a CMDB:
repos:
acme/shop:
owners: [octocat, hubot]
attributes:
system: storefront
tier: "1"
markdown: |
Storefront is PCI-scoped; page #payments-oncall first.
func NewStaticFile ¶
func NewStaticFile(path string) (*StaticFile, error)
NewStaticFile loads the map from path.
func (*StaticFile) Enhance ¶
func (s *StaticFile) Enhance(_ context.Context, issue enhance.Issue) (*enhance.Enrichment, error)
Enhance implements enhance.Enhancer; a repository absent from the map contributes nothing.