enhancers

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

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

type LabelKeys struct {
	Org      string
	Name     string
	Provider string
	URL      string
}

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.

func (Noop) Enhance

Enhance implements enhance.Enhancer.

func (Noop) ID

func (Noop) ID() string

ID implements enhance.Enhancer.

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.

func (*StaticFile) ID

func (*StaticFile) ID() string

ID implements enhance.Enhancer.

Jump to

Keyboard shortcuts

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