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
10 changes: 10 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ runs it blocking. A
later major release makes blocking the default. The checker runs with the
runner's system Python, which ships PyYAML (`ubuntu-24.04`).

**zizmor config.** After v4.7.0, zizmor runs with the shared
[`scripts/lint/zizmor.yml`](../scripts/lint/zizmor.yml), which ships with
`lint.yml` at the commit the caller pinned, unless the repository has its own
`.github/zizmor.yml` or `zizmor.yml` (or `.yaml`). zizmor loads one config only,
so a repository config replaces the shared one and has to repeat its rules. The
shared config disables the `self-repository` audit (zizmor 1.30+), which asks
to rewrite every workspace-relative `uses: ./...` as `uses: $/...`. We pick the
form per workflow instead: `$/` where a reusable workflow must call a sibling at
its own commit (`lint-include.yml` calling `lint.yml`), `./` in callers.

| Input | Description |
| ------------------------------ | ---------------------------------------------------------------------- |
| `mise-version` | **Required.** mise version to install. |
Expand Down
19 changes: 17 additions & 2 deletions scripts/lint/zizmor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@
# Audits GitHub Actions workflows with zizmor.
# A step of .github/workflows/lint.yml, run the same way in both lint modes.
# Env: UPLOAD_SARIF: write SARIF for code scanning instead of gating on the exit code.
#
# A repo without a zizmor config of its own gets the shared zizmor.yml next to
# this script. zizmor loads one config only, so a repo config replaces it.

set -eo pipefail

zizmor_args=()
local_config=false
for path in .github/zizmor.yml .github/zizmor.yaml zizmor.yml zizmor.yaml; do
if [ -f "${path}" ]; then
local_config=true
break
fi
done
if [ "${local_config}" = false ]; then
zizmor_args+=(--config "$(dirname "${BASH_SOURCE[0]}")/zizmor.yml")
fi

if [ "${UPLOAD_SARIF}" = "true" ]; then
mise exec -- zizmor --format sarif . >"${RUNNER_TEMP}/zizmor.sarif"
mise exec -- zizmor "${zizmor_args[@]}" --format sarif . >"${RUNNER_TEMP}/zizmor.sarif"
else
# No GitHub Advanced Security: gate on exit code with console output.
mise exec -- zizmor .
mise exec -- zizmor "${zizmor_args[@]}" .
fi
14 changes: 14 additions & 0 deletions scripts/lint/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# Shared zizmor configuration. scripts/lint/zizmor.sh passes it to zizmor for
# every repo that has no zizmor config of its own (.github/zizmor.yml or
# zizmor.yml). zizmor loads a single config, so a repo with its own config must
# carry these rules itself.
rules:
# zizmor 1.30 added self-repository, which asks to rewrite every
# workspace-relative `uses: ./...` as `uses: $/...`. We choose the form per
# workflow: `$/` where a reusable workflow must call a sibling at its own
# commit (lint-include.yml calls lint.yml, #552), `./` elsewhere. Callers in
# the fleet and in this repo use `./` on purpose, so the audit only adds noise
# and fails lint on gating (non-SARIF) repos.
self-repository:
disable: true
13 changes: 11 additions & 2 deletions tests/lint-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,20 @@ expect_status 1 "trivy without SARIF"
expect_log "trivy fs --scanners misconfig,secret --exit-code 1 ." "trivy without SARIF"
run zizmor
expect_status 0 "zizmor with SARIF"
expect_log "zizmor --format sarif ." "zizmor with SARIF"
expect_log "zizmor --config ${scripts}/zizmor.yml --format sarif ." "zizmor with SARIF"
[ -f "${RUNNER_TEMP}/zizmor.sarif" ] || fail "zizmor must write ${RUNNER_TEMP}/zizmor.sarif"
run zizmor UPLOAD_SARIF=false FAKE_EXIT=1
expect_status 1 "zizmor without SARIF"
expect_log "${repo}: zizmor ." "zizmor without SARIF"
expect_log "${repo}: zizmor --config ${scripts}/zizmor.yml ." "zizmor without SARIF"
# A repo's own zizmor config replaces the shared one (zizmor loads one config).
for own in .github/zizmor.yml zizmor.yaml; do
own_repo="${tmp_dir}/zizmor-own-${own//[\/.]/-}"
mkdir -p "${own_repo}/.github"
touch "${own_repo}/${own}"
run_in "${own_repo}" zizmor UPLOAD_SARIF=false
expect_status 0 "zizmor with its own ${own}"
expect_log "${own_repo}: zizmor ." "zizmor with its own ${own}"
done

# The language linters see the tracked files of their language, minus every
# path the shared dprint.json excludes (vendored and generated files).
Expand Down
Loading