wfpolicy

package module
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 9 Imported by: 1 module, 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.

README

Documentation

Overview

Package wfpolicy reports GitHub Actions workflow steps that resolve an action from a moving branch instead of a fixed ref.

`uses: owner/action@main` re-resolves on every run, so the code a workflow executes changes without a single line of that workflow changing — the supply-chain shape where an upstream force-push, or a compromised upstream, runs inside a job holding this repository's credentials. A tag or a commit SHA names something that does not move on its own — for an action we do NOT control. For one we publish the rule inverts, because a major tag moving is the point: see Owners.

The rule is a DENYLIST of refs that are branches by construction — main, master, HEAD and the handful of conventional development-branch names — and nothing else. The alternative, guessing whether an arbitrary ref is a tag or a branch, cannot be done from the text: `@release-1.0` is a plausible name for either, and a gate that guesses reports findings nobody can act on. A SHA and a `@v2` tag are both silent, which is what the fleet writes.

A local action (`uses: ./.github/actions/x`) names no ref at all and is this repository's own code, and a container action (`uses: docker://…`) names an image whose tag is not a git ref at all — telling an author their image tag is a branch would be false — so neither is read. The composite action a local reference points AT is read, because its steps run with the job's credentials and that file is where its own pins live.

Index

Constants

View Source
const Category = "workflow"

Category is the language group this analyzer belongs to, used by the yze suite to run it only when processing workflows.

View Source
const ErrNoPaths errs.Const = "no paths to analyze"

ErrNoPaths reports a run given nothing to analyze. A runner whose root placeholder expands to nothing would otherwise green the gate over a repository no analyzer ever looked at.

View Source
const ErrNotRegularFile = goyze.ErrNotRegularFile

ErrNotRegularFile reports a named path whose contents cannot be read. A FIFO blocks forever on open and a character device never ends, so a single such argument hangs the gate instead of failing it — the one outcome nobody can diagnose from a stuck CI job.

It IS the shared sentinel, not a second one beside it: the refusal is raised by the discovery this command walks with, and nothing here ever returned the local copy — a caller matched it only because the two happened to carry the same text, so rewording either would have broken `errors.Is` for everyone. That is the defect ErrTooLarge was already repaired for, one declaration away, and this was the third of the three siblings still carrying it.

View Source
const ErrParse errs.Const = "cannot parse workflow YAML"

ErrParse reports a file that is not YAML.

View Source
const ErrReadFile errs.Const = "cannot read workflow file"

ErrReadFile reports that a workflow file could not be read.

View Source
const ErrTooLarge = goyze.ErrTooLarge

ErrTooLarge reports a file past the size this rule will read. It IS the shared sentinel, not a second one beside it: the bound is enforced in two places — here, and at the one place the command reads a file — and two sentinels for one condition meant `errors.Is` answered false for whichever layer the caller had not thought of.

View Source
const Name = "wfpolicy"

Name is the analyzer's stable identifier. It MATCHES the repository suffix, as every other analyzer in the family does — `yze-go-errconst` emits `yze/errconst`. This one emitted `yze/wfpin` after the repository was renamed to describe both of its opposite rules rather than only the pinning half, and a rule id is the identifier a baseline, a ratchet and a `//nolint` all name. It could be corrected only before publication, and it was.

View Source
const Rule = Tool + "/" + Name

Rule is the stable, flat rule id every diagnostic carries: "yze/" + Name.

View Source
const SizeLimit goyze.ByteCount = 128 << 10

SizeLimit is the largest file read, in bytes.

A workflow is a few kilobytes; the largest in the fleet is under forty. A file past this is a data dump, generated output, or a mistake, and reading it costs its own size in memory for a rule that cannot apply — a 2 GB file reached 4.3 GB resident by BOTH entry points, because this analyzer had no bound at all while both its siblings did. The limit is generous by orders of magnitude over any real workflow, so it bounds the pathological case while still admitting every file anyone wrote.

View Source
const Tool = "yze"

Tool is the suite name stamped on every diagnostic.

Variables

This section is empty.

Functions

func Diagnostics

func Diagnostics(path Path, source Source, owners Owners) ([]goyze.Diagnostic, error)

Diagnostics reports every action reference that should not be where it is: a moving ref on somebody else's action, and a frozen or branch ref on one of the runner's own. path is stamped on each diagnostic's location.

The owner list is a PARAMETER, never read from the process. A library that reaches for the environment makes every caller — and every test — depend on what happened to be exported: this one did, and the suite passed or failed according to the developer's shell. Reading ambient state is main's job, at the one boundary where it is visible.

func Report

func Report(read FileReader, files []string, owners Owners) goyze.Report

Report runs the pin check over each file and aggregates the diagnostics into the lean stickler-json report.

It does not fail. A file that cannot be read, or that is not YAML, becomes one finding against that file and the run continues — a single unreadable file used to abort the run and return an empty report, so one bad file cost every other file its findings, and a gate reporting nothing is indistinguishable from a clean one. Both siblings already answered this way; this one did it for parse failures and not for read failures, which is the same outage reached through the one door still open.

func Unreadable

func Unreadable(paths []string) []goyze.Diagnostic

Unreadable is the finding for each path the walk could not read: a directory it could not enter, and a file it could not have read had it tried — a FIFO, a device, a link resolving to nothing. Both are REPORTED rather than skipped, because a path the gate cannot open is where an unchecked one would hide, and the run still yields every other file's findings.

Types

type FileReader

type FileReader func(path string) ([]byte, error)

FileReader reads a file's bytes; injected so aggregation is testable without the filesystem.

type Owner

type Owner string

Owner is an account or organisation whose actions this fleet owns.

type Owners

type Owners map[Owner]bool

Owners are the accounts whose actions must FLOAT. It is configuration rather than a constant, and it has NO default, because which accounts are "ours" is a property of whoever is running the check — never of this tool. Anyone can use this analyzer; they list their own accounts and the rule inverts for those. A list shipped in the tool would be wrong for every user but one, and would publish the account names of the one it was right for.

func ConfiguredOwners

func ConfiguredOwners(lookup func(string) string) Owners

ConfiguredOwners is the owner list this process was configured with, read from the environment. It is a function rather than a package variable so a test can set the variable and see the change, and so an unset variable is plainly an empty list rather than a nil surprise.

type Path

type Path string

Path is the file path stamped on each diagnostic's location.

type Source

type Source string

Source is the text of one workflow file.

Jump to

Keyboard shortcuts

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