recipelint

package
v1.0.0-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 21 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 recipelint holds the shipped CI recipes to their security rules: no privileged trigger, every action pinned by SHA, and an agent's job that holds nothing but read access to the code.

Index

Constants

View Source
const (
	RuleCommentTrigger    = "comment-trigger"
	RuleAgentOpen         = "agent-open"
	RuleAgentContentWrite = "agent-contents-write"
	RuleSubscriptionToken = "subscription-token"
	RuleAgentBudget       = "agent-budget"
)

The rules only the customer profile names. It also names RulePullRequestTarget, RuleAgentIDToken, RuleExpressionInScript, RuleUnpinned, RuleAgentPromptInput, RuleEgressAudit, RuleTwoCaps, RuleJoinAttributes and RuleUnreadable.

View Source
const (
	// RuleAgentAdminKey is a gateway's admin key or sealing key within the
	// agent's reach.
	RuleAgentAdminKey = "agent-admin-key"
	// RuleGatewayEnvironment is a job that holds a gateway's admin key or
	// sealing key and names no environment.
	RuleGatewayEnvironment = "gateway-environment"
)
View Source
const (
	RuleEgressAudit    = "egress-audit"
	RuleEgressEndpoint = "egress-endpoint"
)

RuleEgressAudit names harden-runner that leaves a job's egress open or broken: audit mode, block mode with no allowed-endpoints, or a list that harden-runner cannot read. RuleEgressEndpoint names a host a recipe allows that is not one of egressHosts, and telemetry left on, which allows step-security's own hosts. Both are notes and reject nothing.

View Source
const (
	RuleReportLabel     = "report-label"
	RuleCosignCommit    = "cosign-commit"
	RuleReportExitCodes = "report-exit-codes"
)

The rules only a GitLab template can break.

View Source
const (
	RuleUnreadable         = "unreadable"
	RulePullRequestTarget  = "pull-request-target"
	RuleUnpinned           = "unpinned-action"
	RuleUnrecordedPin      = "unrecorded-pin"
	RuleAgentIDToken       = "agent-id-token"
	RuleIDTokenScope       = "id-token-scope"
	RulePermissions        = "explicit-permissions"
	RuleAgentPermissions   = "agent-permissions"
	RuleAgentGuard         = "agent-guard"
	RuleAgentVersion       = "agent-version"
	RuleUnknownAgent       = "unknown-agent"
	RuleAgentContentFlags  = "agent-content-flags"
	RuleAgentProvider      = "agent-provider"
	RuleAgentTools         = "agent-tools"
	RuleAgentPromptInput   = "agent-prompt-input"
	RuleAgentNoteToken     = "agent-note-token"
	RuleReportJob          = "report-job"
	RuleExpressionInScript = "expression-in-script"
	RuleFollowUpCode       = "follow-up-code"
	RuleFollowUpArtifact   = "follow-up-artifact"
)

The rules a finding can name.

View Source
const (
	RuleIngestPlatform = "ingest-platform"
	RuleConnectJob     = "connect-job"
)

RuleIngestPlatform names an ingest step with platform-url that cannot send its rows to Costroid Platform: an input missing, an integration token written into the file, or a job condition that skips the job when only the platform is named. RuleConnectJob names a job that runs costroid connect and holds more than the permission its proof needs.

View Source
const (
	RulePluginUnpinned = "plugin-unpinned"
	RulePluginWrites   = "plugin-writes"
)

RulePluginUnpinned names a plugin part that a later push could change unseen: a marketplace entry from outside the repository, a version that is not exact, or an MCP server fetched from a package registry at no exact version. RulePluginWrites names a part that can do more than read: a hook, or a command, skill or agent that allows a tool not known to only read.

View Source
const MarketplaceFile = ".claude-plugin/marketplace.json"

MarketplaceFile is where Claude Code reads a repository's plugin marketplace, by path from the repository's root.

View Source
const RuleAgentCheckoutCredentials = "agent-checkout-credentials"

RuleAgentCheckoutCredentials is a checkout in an agent's job that leaves the job's token in the clone's git config, where the agent can read it.

View Source
const (
	// RuleApprovalCode holds an approval workflow to its event, its token and
	// no code.
	RuleApprovalCode = "approval-code"
)

An approval workflow runs costroid approve on a pull request review. It runs with this repository's token on an event any reviewer starts, so it holds no code and starts no agent.

View Source
const RuleArtifactPath = "artifact-path"

RuleArtifactPath is a download that unpacks an artifact into the runner's temporary directory itself. Costroid's binary and the event file sit there, and the job that uploaded the artifact chose every name in it.

View Source
const (
	// RuleFollowUpPermissions holds a follow-up's token to what it needs.
	RuleFollowUpPermissions = "follow-up-permissions"
)

A follow-up is a workflow_run workflow. It runs in the base repository with that repository's token, after a workflow a fork's pull request could edit, so it holds no code and runs nothing that workflow left behind.

View Source
const RuleJoinAttributes = "join-attributes"

RuleJoinAttributes names an agent that costroid run does not start, such as claude-code-action's, whose environment does not give its telemetry the pull request's join keys. costroid run sets them for every agent it starts.

View Source
const RuleTwoCaps = "two-caps"

RuleTwoCaps names steps that state different caps for one run. The run is held to one, the read step grades it against the one it is told, and the report states the one the run recorded, so a second figure makes one of them read another cap than the run had.

Variables

This section is empty.

Functions

func EventNames

func EventNames(root *yaml.Node) []string

EventNames lists the events of a workflow's on: key, read through aliases and merge keys as lint reads them. root is the workflow's top mapping.

func Field

func Field(node *yaml.Node, key string) *yaml.Node

Field returns the value of key in the mapping node, with aliases followed and merge keys expanded, or nil when node holds no such key.

func Uses

func Uses(node *yaml.Node, visit func(key, value *yaml.Node))

Uses calls visit once for every uses: key under node whose value is a scalar, read through aliases and merge keys. A step that an alias repeats is visited once, at the node the anchor marks.

Types

type Finding

type Finding struct {
	Path     string
	Line     int
	Severity Severity
	Rule     string
	Message  string
}

Finding is one line of a file and the rule it breaks. A note uses the same shape and rejects nothing. Severity is set by the customer profile alone.

func (Finding) String

func (f Finding) String() string

type Options

type Options struct {
	Profile Profile
}

Options are a lint's settings. The zero value lints recipes.

type Profile

type Profile int

Profile chooses the rules a lint holds files to.

const (
	// Recipes holds Costroid's shipped recipes to every rule.
	Recipes Profile = iota
	// Customer holds a team's own agent workflows to the rules on who can
	// start a run and what the agent's job holds, each with a severity.
	Customer
)

type ReadTools

type ReadTools map[string][]string

ReadTools names, for each MCP server a plugin starts, the tools that server lists as only reading. A tool or a server it does not name is taken to write.

type Report

type Report struct {
	Files    int
	Agents   int
	Findings []Finding
	Notes    []Finding
}

Report is what one lint found. Agents counts the workflows the customer profile judged, the ones with an agent step.

func Lint

func Lint(paths []string) (Report, error)

Lint checks the files named and every YAML file under the directories named, under the recipe profile.

func LintBytes

func LintBytes(path string, data []byte) Report

LintBytes checks one file. A file that is no workflow, action or GitLab template is a finding, because a rule that sees nothing has proved nothing.

func LintCustomer

func LintCustomer(path string, data []byte) Report

LintCustomer checks one of a team's own workflows. Only a workflow with an agent step is judged; any other file passes with nothing said, and Agents stays 0. A file that is not YAML is a high finding, because nothing in it could be judged.

func LintMarketplace

func LintMarketplace(root string, readTools ReadTools) (Report, error)

LintMarketplace holds the marketplace at root, and every plugin it lists, to two rules. Each plugin is a directory of the repository, so the commit that holds the marketplace pins it, and the marketplace and the plugin state the same exact version. Each MCP server runs a command on PATH, or a package at an exact version, and every tool a command, skill or agent allows is one that only reads.

func LintWith

func LintWith(paths []string, options Options) (Report, error)

LintWith checks the files named and every YAML file under the directories named. Naming nothing to lint is an error, so a mistyped path cannot pass.

type Severity

type Severity string

Severity ranks a finding of the customer profile. A high finding fails costroid lint, a medium one fails it under --strict, and a note never does.

const (
	High   Severity = "high"
	Medium Severity = "medium"
	Note   Severity = "note"
)

The severities, from the most to the least serious.

Jump to

Keyboard shortcuts

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