ghainit

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 13 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 ghainit writes a repository's managed Vulnetix workflow from what the repository is made of and a small policy file. The workflow uses the granular actions: one or two languages or package managers get parallel jobs plus a rest step, three or more get the high-level scanner.

Index

Constants

View Source
const (
	// TriggerPR scans pull requests and pushes to main.
	TriggerPR = "pr"
	// TriggerPush scans pushes to main.
	TriggerPush = "push"
	// TriggerBelai scans pushes to main and pull requests from belai/ branches.
	TriggerBelai = "belai"
)

Trigger models. Each maps to the `on:` and job conditions of one kind of repo.

View Source
const PolicyPath = ".vulnetix/workflow.yaml"

PolicyPath is the policy file, relative to the repository root.

View Source
const WorkflowPath = ".github/workflows/vulnetix.yml"

WorkflowPath is the file `gha init` manages.

Variables

This section is empty.

Functions

func IsManaged

func IsManaged(content string) bool

IsManaged reports whether a workflow is this command's.

func Normalize

func Normalize(content string) string

Normalize drops action refs, which a lock tool narrows to exact tags, so a locked workflow still compares equal to what this command renders.

func Render

func Render(p *Policy, sig *Signals, opt Options) string

Render writes the workflow.

Types

type Extra

type Extra struct {
	Action string            `yaml:"action"`
	ID     string            `yaml:"id,omitempty"`
	With   map[string]string `yaml:"with,omitempty"`
	// Prior are catalogue actions run first in the same job, for an action that
	// reads what they write (report after sca, bom-validate after sbom).
	Prior []string `yaml:"prior,omitempty"`
	// Run are shell lines run before the action.
	Run []string `yaml:"run,omitempty"`
	// Then are shell lines run after the action, to check what it left behind.
	Then []string `yaml:"then,omitempty"`
	// Needs names a job whose SBOM or results this one reads.
	Needs string `yaml:"needs,omitempty"`
	// Permissions are added to the job's contents: read.
	Permissions map[string]string `yaml:"permissions,omitempty"`
}

Extra is one catalogue action run as its own job.

type Options

type Options struct {
	// Ref is the action ref, v0 by default.
	Ref string
	// CheckoutRef is the actions/checkout ref.
	CheckoutRef string
}

Options are the values a render needs beyond the policy.

type Policy

type Policy struct {
	Version  int    `yaml:"version"`
	Triggers string `yaml:"triggers"`
	// Runner is the self-hosted pool's label. Empty uses ubuntu-latest everywhere.
	Runner string `yaml:"runner,omitempty"`
	// Publish uploads SARIF to code scanning. Code scanning returns 403 on a
	// private repository without Code Security, so private repositories leave it off.
	Publish bool `yaml:"publish,omitempty"`

	SAST Selection `yaml:"sast"`
	SCA  Selection `yaml:"sca"`
	// NoRest leaves out the rest step, for a fixture whose legs are every
	// language it has. Without the step a finding outside the legs goes unseen.
	NoRest bool `yaml:"no_rest,omitempty"`

	Secrets    *bool  `yaml:"secrets,omitempty"`
	SBOM       *bool  `yaml:"sbom,omitempty"`
	IaC        string `yaml:"iac,omitempty"`        // auto, on, off
	Containers string `yaml:"containers,omitempty"` // auto, on, off
	License    bool   `yaml:"license,omitempty"`
	Malscan    bool   `yaml:"malscan,omitempty"`
	CBOM       bool   `yaml:"cbom,omitempty"`
	AIBOM      bool   `yaml:"aibom,omitempty"`
	Analyze    bool   `yaml:"analyze,omitempty"`

	// Gates maps a scanner to its --fail-on. A scanner with no gate reports and
	// never fails the job. There is no baseline, so a gate goes on once a run is
	// clean at that level.
	Gates map[string]string `yaml:"gates,omitempty"`
	// Rules are external rule packs per scanner: sast, secrets, iac, sast/go.
	Rules map[string][]string `yaml:"rules,omitempty"`

	// TEA publishes each run's BOMs to the Transparency Exchange API. Nil is on.
	TEA *TEA `yaml:"tea,omitempty"`

	Extras []Extra `yaml:"extras,omitempty"`
}

Policy is .vulnetix/workflow.yaml.

func DefaultPolicy

func DefaultPolicy() *Policy

DefaultPolicy is a policy with nothing decided.

func LoadPolicy

func LoadPolicy(root string) (*Policy, error)

LoadPolicy reads root's policy, or nil when it has none.

func (*Policy) Validate

func (p *Policy) Validate() error

Validate refuses what would render a broken or unsafe workflow: a value that ends up in an expression, a runner label or a uses: line.

type Selection

type Selection struct {
	Mode  string
	Names []string
}

Selection picks scoped legs: "auto", "high", "none", or the names to run.

func (*Selection) UnmarshalYAML

func (s *Selection) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML reads a word or a list.

type Signals

type Signals struct {
	Languages  []string // largest first
	Managers   []string // largest first
	Terraform  bool
	Containers bool
}

Signals is what a repository is made of.

func Detect

func Detect(root string) (*Signals, error)

Detect walks root.

type TEA

type TEA struct {
	Off        bool     `yaml:"off,omitempty"`
	Visibility string   `yaml:"visibility,omitempty"`
	Channels   []string `yaml:"channels,omitempty"`
}

TEA configures the publish job.

Jump to

Keyboard shortcuts

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