github-actions-security-no-cancel
github-actions-security-no-cancel
- Package
- lint-meta-rules v1.1.0
- Runs under
@noctcore/harnesslint-meta, not ESLint- Factory
createGithubActionsSecurityNoCancelRule- Entry point
@noctcore/lint-meta-rules- Category
ci- Fails CI by default
- Yes
A security scan workflow never sets a literal cancel-in-progress: true, so a newer run cannot cancel a scan halfway.
A scan that a newer push cancels part way leaves the earlier commit with no finished result. When the scan is a required check or the only gate on a branch, that commit can merge without ever having been scanned in full. Cancelling is right for a build or a test run, whose result a newer run replaces, and wrong for a scan whose whole point is to finish on every commit.
What it flags
Section titled “What it flags”A cancel-in-progress set to a literal true (true, True or TRUE, quoted or not) in a
concurrency mapping, at workflow level or at job level, written as a block or as a flow mapping. Only
workflows whose file base name matches securityWorkflowPattern are read. The violation points at the
cancel-in-progress line of a block, and at the concurrency: line of a flow mapping.
# Badconcurrency: group: sast-${{ github.ref }} cancel-in-progress: true
jobs: scan: concurrency: { group: scan, cancel-in-progress: true }
# Goodconcurrency: group: sast-${{ github.ref }} cancel-in-progress: falseWhat it does not flag
Section titled “What it does not flag”- An expression value, such as
cancel-in-progress: ${{ github.event_name == 'pull_request' }}. It cannot be resolved from the text, so it is a known limit. - The string form,
concurrency: ${{ github.workflow }}, which sets nocancel-in-progress. cancel-in-progress: truetext that is not a direct child of aconcurrencykey, for example inside arun: |script, and a line that is commented out.- A workflow whose base name does not match the pattern (
ci.yml,build.yml). Only the base name counts, never the directory.
Line-based text, not a YAML parse. A flow mapping that wraps over several lines is not read.
Options
Section titled “Options”createGithubActionsSecurityNoCancelRule(options?: GithubActionsSecurityNoCancelOptions): IMetaRule| Option | Type | Default | Meaning |
|---|---|---|---|
workflowGlobs |
string[] |
['.github/workflows/*.yml', '.github/workflows/*.yaml'] |
Workflow files to scan. |
securityWorkflowPattern |
RegExp |
/security|sast|secrets|codeql|scan/iu |
A workflow whose file base name matches is a security scan workflow. A g or y flag is ignored. |
ciCritical |
boolean |
true |
Whether a violation fails CI. |
When not to use it
Section titled “When not to use it”If your scans run on a schedule only, or a newer scan always supersedes the older one on purpose, a cancelled run costs nothing and this adds nothing.
Related
Section titled “Related”github-actions-timeout-requiredbounds how long a hung scan can hold its runner.