Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# actionlint configuration: https://github.com/rhysd/actionlint/blob/main/docs/config.md
paths:
.github/workflows/lint-include.yml:
ignore:
# actionlint (1.7.12) predates GitHub's `$/` self-repository syntax for
# reusable workflow calls (July 2026). Drop this once it supports it
# (#552).
- 'reusable workflow call "\$/\.github/workflows/lint\.yml" at "uses" is not following the format'
160 changes: 160 additions & 0 deletions .github/workflows/lint-include.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
---
name: Reusable — Lint (include mode)

# Include mode of the reusable Lint workflow: every linter is off unless the
# caller turns it on (`lint-gitleaks: true` runs gitleaks and nothing else).
# Linters added to lint.yml later stay off here until a caller enables them.
# lint.yml itself is the exclude mode: every linter on, `lint-<name>: false`
# turns one off. This file only redeclares lint.yml's inputs, with every
# `lint-<name>` linter defaulting to false, and passes them all through.
# tests/lint-include.py fails CI when an input of lint.yml is missing here,
# isn't passed through unchanged, or a linter doesn't default to false.
on:
workflow_call:
inputs:
mise-version:
description: "mise version to install"
required: true
type: string
golangci-lint-version:
description: "golangci-lint version to install (required only when Go linting runs)"
required: false
type: string
default: ""
go-version-file:
description: "Path to the Go version file"
required: false
type: string
default: "go.mod"
lint-config-dir:
description: "Directory containing optional linter config files"
required: false
type: string
default: ""
lint-fail-on-error:
description: "Fail the workflow when a linter fails"
required: false
type: boolean
default: false
lint-dprint:
description: "Run dprint (Markdown formatting)"
required: false
type: boolean
default: false
lint-yamlfmt:
description: "Run yamlfmt (YAML formatting)"
required: false
type: boolean
default: false
lint-yamllint:
description: "Run yamllint (YAML linting)"
required: false
type: boolean
default: false
lint-actionlint:
description: "Run actionlint (GitHub Actions linting)"
required: false
type: boolean
default: false
lint-gitleaks:
description: "Run gitleaks (secret scanning)"
required: false
type: boolean
default: false
lint-go:
description: "Run golangci-lint (Go linting)"
required: false
type: boolean
default: false
lint-shellcheck:
description: "Run shellcheck (shell linting)"
required: false
type: boolean
default: false
lint-shellcheck-exclude:
description: "Glob pattern for paths to exclude from shellcheck (passed to find -not -path)"
required: false
type: string
default: ""
lint-shfmt:
description: "Run shfmt (shell formatting)"
required: false
type: boolean
default: false
lint-shfmt-exclude:
description: "Glob pattern for paths to exclude from shfmt (passed to find -not -path)"
required: false
type: string
default: ""
lint-checkov:
description: "Run checkov (IaC security) — uploads SARIF"
required: false
type: boolean
default: false
lint-trivy:
description: "Run trivy fs (misconfig + secrets) — uploads SARIF"
required: false
type: boolean
default: false
lint-zizmor:
description: "Run zizmor (Actions security) — uploads SARIF"
required: false
type: boolean
default: false
lint-config-drift:
description: "Check local config files match central DevSecNinja/.github repo"
required: false
type: boolean
default: false
upload-sarif:
description: "Upload checkov/trivy/zizmor results to GitHub code scanning (requires GitHub Advanced Security). Set
false for private repos without GHAS to gate on exit codes with console output instead."
required: false
type: boolean
default: true
lint-job-mode:
description: "How linters are scheduled: auto (default), single or parallel. See lint.yml."
required: false
type: string
default: auto

permissions:
contents: read

jobs:
lint:
# `$/` (self-repository syntax) resolves to this workflow's own repository
# at the commit that is running, so a caller pinning lint-include.yml@<sha>
# gets lint.yml from that same commit, and this repository's callers test
# local changes to both. `./` is workspace-relative, so it isn't
# guaranteed to resolve to this repository when another repository calls
# this workflow, and an `owner/repo/...@<sha>` pin would lag behind
# lint.yml. actionlint doesn't know `$/` yet: .github/actionlint.yaml
# ignores that one error (#552).
uses: $/.github/workflows/lint.yml
permissions:
contents: read
# checkov, trivy, zizmor and gitleaks history findings go to code scanning.
security-events: write
with:
mise-version: ${{ inputs.mise-version }}
golangci-lint-version: ${{ inputs.golangci-lint-version }}
go-version-file: ${{ inputs.go-version-file }}
lint-config-dir: ${{ inputs.lint-config-dir }}
lint-fail-on-error: ${{ inputs.lint-fail-on-error }}
lint-dprint: ${{ inputs.lint-dprint }}
lint-yamlfmt: ${{ inputs.lint-yamlfmt }}
lint-yamllint: ${{ inputs.lint-yamllint }}
lint-actionlint: ${{ inputs.lint-actionlint }}
lint-gitleaks: ${{ inputs.lint-gitleaks }}
lint-go: ${{ inputs.lint-go }}
lint-shellcheck: ${{ inputs.lint-shellcheck }}
lint-shellcheck-exclude: ${{ inputs.lint-shellcheck-exclude }}
lint-shfmt: ${{ inputs.lint-shfmt }}
lint-shfmt-exclude: ${{ inputs.lint-shfmt-exclude }}
lint-checkov: ${{ inputs.lint-checkov }}
lint-trivy: ${{ inputs.lint-trivy }}
lint-zizmor: ${{ inputs.lint-zizmor }}
lint-config-drift: ${{ inputs.lint-config-drift }}
upload-sarif: ${{ inputs.upload-sarif }}
lint-job-mode: ${{ inputs.lint-job-mode }}
15 changes: 4 additions & 11 deletions .github/workflows/secret-scan-caller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
jobs:
gitleaks:
# Local reference validates reusable workflow changes in this repository.
uses: ./.github/workflows/lint.yml
# Include mode: only the linters set to true run, so linters added to
# lint.yml later stay off here.
uses: ./.github/workflows/lint-include.yml
Comment thread
DevSecNinja marked this conversation as resolved.
Resolved
permissions:
contents: read
security-events: write
Expand All @@ -34,13 +36,4 @@
# History findings only report; this fails the run when the scan or the
# code scanning upload fails, so a silent gap can't look green.
lint-fail-on-error: true
lint-dprint: false
lint-yamlfmt: false
lint-yamllint: false
lint-actionlint: false
lint-go: false
lint-shellcheck: false
lint-shfmt: false
lint-checkov: false
lint-trivy: false
lint-zizmor: false
lint-gitleaks: true
1 change: 1 addition & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ run = [
"bash ./tests/release-please-auth-contract.sh",
"bash ./tests/automation-app-contract.sh",
"uv run --script ./tests/app-key-confinement.py",
"uv run --script ./tests/lint-include.py",
"bash ./tests/lint-job-modes-contract.sh",
"bash ./tests/open-pr-push.sh",
"bash ./tests/open-pr-api-commit.sh",
Expand Down
38 changes: 24 additions & 14 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ on the event (v4.1.0+):
Internal repositories, whose logs every enterprise member can read, and a
failed visibility lookup count as public.
Repositories whose Lint caller runs on pull requests only get the full-history
scan from a second caller, after each merge, weekly and on dispatch, with every
other linter off (this repository's `secret-scan-caller.yml`). A Lint caller
that also runs on push already scans the history there, so drop `push` below.
scan from a second caller, after each merge, weekly and on dispatch (this
repository's `secret-scan-caller.yml`). It calls the include mode,
[`lint-include.yml`](#lint-include-mode-lint-includeyml), with only
`lint-gitleaks: true`, so linters added to `lint.yml` later never start
running there. A Lint caller that also runs on push already scans the history
there, so drop `push` below.

```yaml
name: Secret scan
Expand All @@ -132,7 +135,7 @@ permissions:

jobs:
gitleaks:
uses: DevSecNinja/.github/.github/workflows/lint.yml@<sha> # v4.1.0
uses: DevSecNinja/.github/.github/workflows/lint-include.yml@<sha> # v4.4.0
permissions:
contents: read
security-events: write
Expand All @@ -142,16 +145,7 @@ jobs:
# Findings only report; fail the run if the scan or upload fails.
lint-fail-on-error: true
# upload-sarif: false # private repos without GitHub Advanced Security
lint-dprint: false
lint-yamlfmt: false
lint-yamllint: false
lint-actionlint: false
lint-go: false
lint-shellcheck: false
lint-shfmt: false
lint-checkov: false
lint-trivy: false
lint-zizmor: false
lint-gitleaks: true
```

| Input | Description |
Expand Down Expand Up @@ -209,6 +203,22 @@ jobs:
# lint-job-mode: auto # single | parallel
```

### Lint, include mode (`lint-include.yml`)

`lint.yml` is the exclude mode: every linter runs unless the caller sets
`lint-<name>: false`. `lint-include.yml` (v4.4.0+) is the include mode: every
linter is off unless the caller sets `lint-<name>: true`, and linters added to
`lint.yml` later stay off until a caller enables them. Use it when a caller
wants a few specific linters, such as the secret-scan caller above, instead of
keeping a list of linters to turn off.

It takes the same inputs as `lint.yml` with the same defaults, except that
every `lint-<name>` linter defaults to `false`, and passes them all to the
`lint.yml` of the same commit (through GitHub's `$/` self-repository syntax),
so linters behave exactly as described above. Grant the calling job
`contents: read` and `security-events: write`. `tests/lint-include.py` fails CI
when `lint.yml` gains an input that `lint-include.yml` doesn't forward.

### Auto-fix formatting (`autofix.yml`)

Runs dprint, yamlfmt, and shfmt in write mode, then commits and pushes any
Expand Down
Loading
Loading