From 45dfa1c3c1251aaae8ab07f9b4fdec6f17438ce0 Mon Sep 17 00:00:00 2001 From: Jean-Paul van Ravensberg <14926452+DevSecNinja@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:03:07 +0100 Subject: [PATCH] fix(lint): disable the zizmor self-repository audit in a shared config zizmor 1.30 added the self-repository audit, 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, #552) and `./` in callers. The audit fails lint on gating repos (home-assistant-win-companion#325) and adds code-scanning alerts here. - scripts/lint/zizmor.yml: shared config that disables self-repository, with the reason. It ships with lint.yml at the caller's pinned commit. - scripts/lint/zizmor.sh: pass it with --config unless the repo has its own .github/zizmor.yml or zizmor.yml (zizmor loads one config only). - tests/lint-scripts.sh: cover both cases. - docs/architecture.md: document the shared config. --- docs/architecture.md | 10 ++++++++++ scripts/lint/zizmor.sh | 19 +++++++++++++++++-- scripts/lint/zizmor.yml | 14 ++++++++++++++ tests/lint-scripts.sh | 13 +++++++++++-- 4 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 scripts/lint/zizmor.yml diff --git a/docs/architecture.md b/docs/architecture.md index 0807ff6a..6aae2130 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -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. | diff --git a/scripts/lint/zizmor.sh b/scripts/lint/zizmor.sh index 3d1d50a9..b887cf0e 100755 --- a/scripts/lint/zizmor.sh +++ b/scripts/lint/zizmor.sh @@ -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 diff --git a/scripts/lint/zizmor.yml b/scripts/lint/zizmor.yml new file mode 100644 index 00000000..e7eea7b7 --- /dev/null +++ b/scripts/lint/zizmor.yml @@ -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 diff --git a/tests/lint-scripts.sh b/tests/lint-scripts.sh index b3b4a89f..94717d39 100755 --- a/tests/lint-scripts.sh +++ b/tests/lint-scripts.sh @@ -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).