Documentation
¶
Overview ¶
Package scan builds a Flightbay bundle from a code repository instead of a live cluster: plain manifests, Helm charts, Kustomize overlays and the Argo CD and Flux objects that point at them. The bundle is a normal one (header, discovery, resources, coverage, manifest with SHA-256s) marked source "repo", so the desk, the Scorecard, reach, search, SQL and Compare all work on it unchanged. It is declared state: there is no status, no pods and no logs, and the checks that need them say so.
Index ¶
- Constants
- func FileName(r *Result, now time.Time) string
- func Load(b []byte) (*store.Workspace, error)
- func NormalizeRepoURL(u string) string
- func Plural(n int, one, many string) string
- func RuntimeOnly(group, resource string) bool
- func SARIFLevel(sev string) string
- func ValidSeverity(s string) bool
- type Failure
- type FixPackResult
- type Gate
- func (g Gate) CodeQuality() []map[string]any
- func (g Gate) ExitCode(threshold string) int
- func (g Gate) Gating(threshold string) []Failure
- func (g *Gate) MarkNew(base Gate, label string) int
- func (g Gate) Reported() []Failure
- func (g Gate) SARIF(version string) any
- func (g Gate) Write(w io.Writer, format, threshold, version string) error
- type Options
- type Result
Constants ¶
const ( SourceAnnotation = "flightbay.dev/source" // repo-relative file (the template, for Helm) LineAnnotation = "flightbay.dev/source-line" // line of the document, when known RenderedByAnnotation = "flightbay.dev/rendered-by" // yaml, helm <chart>, kustomize <dir>, argocd ..., flux ... )
Annotations every rendered object carries, so the desk and the CI report can say where it came from.
const NamespaceAnnotation = "flightbay.dev/namespace"
NamespaceAnnotation on a Chart.yaml sets the namespace a scan renders the chart into when --namespace is not given.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
Load imports a bundle held in memory into a new in-memory workspace, the same way the desk opens one.
func NormalizeRepoURL ¶
NormalizeRepoURL reduces the forms a Git remote is written in (https://host/org/repo.git, git@host:org/repo, ssh://git@host/org/repo) to host/org/repo for comparison.
func RuntimeOnly ¶
RuntimeOnly reports whether a type exists only at runtime (pods, nodes, events, endpoints), so a repo scan cannot judge its absence.
func SARIFLevel ¶
SARIFLevel maps a check severity to a SARIF level.
func ValidSeverity ¶
ValidSeverity reports whether s is a --fail-on value.
Types ¶
type Failure ¶
type Failure struct {
Check string `json:"check"`
Area string `json:"area"`
Category string `json:"category"`
Severity string `json:"severity"`
Title string `json:"title"`
Detail string `json:"detail"`
Guide string `json:"guide"` // a related public field guide
Docs string `json:"docs,omitempty"` // a related product documentation page
Item posture.Item `json:"item"`
File string `json:"file"`
Line int `json:"line,omitempty"`
Renderer string `json:"renderedBy,omitempty"`
New bool `json:"new"`
}
Failure is one failing object of one Scorecard check, with the file it was declared in.
type FixPackResult ¶
FixPackResult lists what a fix pack wrote.
func WriteFixPack ¶
WriteFixPack writes one YAML file per failing check into dir, with the affected objects' names filled in (Agent reach fixes come fully written), proposals for new objects next to plain-YAML sources under proposals/, and a README.md listing each check, the objects and their source files. The repository's own files are never changed.
type Gate ¶
type Gate struct {
Repo *bundle.RepoInfo `json:"repo,omitempty"`
Areas []posture.AreaScore `json:"areas"`
Failures []Failure `json:"failures"`
Baseline string `json:"baseline,omitempty"` // what --new-only compared with
Checks []posture.Check `json:"-"`
}
Gate is the result of scoring a scan.
func Evaluate ¶
Evaluate scores a scanned workspace with the Scorecard (and Agent reach when that feature is on) and lists every failing object with its source.
func (Gate) CodeQuality ¶
CodeQuality renders the reported failures as a GitLab Code Quality report (the Code Climate issue subset GitLab reads): one issue per failing object.
func (Gate) Gating ¶
Gating returns the failures that count: new ones (all, without a baseline) at or above the threshold. An empty threshold gates nothing.
func (*Gate) MarkNew ¶
MarkNew compares with a baseline gate: failures the baseline already had are not new. It returns how many are new.
func (Gate) Reported ¶
Reported is what the report shows: only new failures when compared with a baseline, otherwise all.
type Options ¶
type Options struct {
Paths []string // files or directories inside one repository; default "."
Root string // the repository root that source paths are relative to; default the Git top level, else the scanned directory
Values []string // FILE (every chart) or CHARTDIR=FILE
Set []string // key=value, as helm --set, for every chart
Overlays []string // kustomize directories to build; default every overlay that is not only a base
Env string // pick overlays/<env>, values-<env>.yaml, envs/<env>
Release string // Helm release name; default the chart name
Namespace string // namespace for namespaced objects without one; default "default"
ContextName string // the synthetic cluster name; default repo:<name>
RepoURL string // treat GitOps sources with this URL as this repository
HelmFetch bool // allow helm dependency update (network)
Version string // collector version for the header
Log io.Writer
}
Options control a scan.