Workflow steps pin the code they run
github/actions-pinned-by-digest@v1
Every third party action a workflow uses is pinned to a full commit sha rather than to a tag or a branch.
| Id | github/actions-pinned-by-digest |
| Version | v1 |
| Category | github |
| Default severity | error |
| Interpreter | python3 |
| Timeout | 30 seconds |
| Violations tolerated | 0 |
| Collects | github |
Collectors
This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.
| Collector | Gathers | Inputs it is given |
|---|---|---|
github | What GitHub itself reads out of the repository: the Actions workflows in .github/workflows, read as they are written, and the CODEOWNERS file, read as rules. For a workflow, which events start it, what token permissions it hands a job, which runner each job asks for, and every action a step reaches for and how tightly it is pinned. For CODEOWNERS, every pattern in file order with the owners it names, and the owners that apply to the paths a guardrail asks about, resolved the way GitHub resolves them, where the last rule to match a path is the one that owns it. Names and shapes only, never a secret, an input value or an environment value. | workflows |
The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.
Configuration
{
"guardrails": {
"failOn": "error",
"comment": true,
"checks": [
{
"use": "github/actions-pinned-by-digest@v1",
"severity": "error",
"with": {
"workflows": ".github/workflows/*.yml,.github/workflows/*.yaml",
"allow": ""
},
"exemptions": []
}
]
}
}Inputs
| Input | Description | Default | Environment variable |
|---|---|---|---|
workflows | Comma separated globs naming the workflows to read. | .github/workflows/*.yml,.github/workflows/*.yaml | GUARDRAIL_INPUT_WORKFLOWS |
allow | Comma separated action names exempt from pinning, for the ones your own organisation publishes. actions/* is a glob. | `` | GUARDRAIL_INPUT_ALLOW |
How to fix
Replace the tag with the commit sha it points at today, keeping the tag beside it so a human can still read the version:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2A tag is a moving pointer that whoever owns the action can repoint at any time, so a workflow that trusts one runs whatever that account decides to publish, with your secrets in scope. dependabot and renovate both understand this form and will keep raising the sha for you.
More in github
github/codeowners-catch-all.CODEOWNERSdeclares a rule matching every path, so a file nobody thought about still has an owner.github/codeowners-no-unowned-rules. No rule inCODEOWNERSnames an empty set of owners, which would take ownership away from everything it matches.github/codeowners-owners-per-rule. Every rule inCODEOWNERSnames at least the minimum owners and no more than the maximum, so review is neither one person's bus factor nor everybody's problem.github/codeowners-parses. Every line ofCODEOWNERSthat is not a comment reads as a rule to GitHub, so no ownership is silently lost to a line GitHub ignores.github/codeowners-present. The repository carries aCODEOWNERSfile where GitHub looks for one, naming at least one rule, so every change has somebody to review it.github/codeowners-team-owned. Every rule inCODEOWNERSnames at least one GitHub team, so ownership survives the people currently in it.github/job-timeout-set. Every job declares how long it may run, so a hung job is cut off rather than holding a runner until GitHub's own limit.github/least-privilege-token. Every workflow declarespermissions, and none of them takes write access to everything.