diff --git a/.github/AGENTS.md b/.github/AGENTS.md index 8baf4eda5..6278b78c2 100644 --- a/.github/AGENTS.md +++ b/.github/AGENTS.md @@ -7,3 +7,6 @@ with it; GitHub runs the locked commit and `check-generated` fails a stale lockfile. Same-repo actions are written `$/.github/actions/...`, not `./`, so the lockfile covers what they use. Never pass `--accept-moved`: a moved release tag needs a human. + +zizmor audits every workflow in CI and in the hooks. An exception goes in +`.github/zizmor.yml` with its reason. diff --git a/.github/workflows/nix-checks.yml b/.github/workflows/nix-checks.yml index b7f7d33e9..bc2f51df6 100644 --- a/.github/workflows/nix-checks.yml +++ b/.github/workflows/nix-checks.yml @@ -96,3 +96,14 @@ jobs: - uses: Mic92/hestia@v3.1.0 - name: nixos-module run: nix build -L .#checks.x86_64-linux.nixos-module + + zizmor: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + - uses: NixOS/nix-installer-action@v1.0.0 + - uses: Mic92/hestia@v3.1.0 + - name: zizmor + run: nix build -L .#checks.x86_64-linux.zizmor diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 315bc6dcc..467522ab7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -62,6 +62,15 @@ repos: types: [go] pass_filenames: false + # zizmor audits the whole tree at once: actions.lock and + # .github/zizmor.yml shape each file's findings. + - id: zizmor + name: zizmor + entry: nix develop --command -- zizmor --offline --no-progress . + language: system + files: ^(\.github/|\.pre-commit-config\.yaml$) + pass_filenames: false + # vendor-hash keeps flakehashes.json in sync with go.mod/go.sum. - id: vendor-hash name: vendor-hash diff --git a/AGENTS.md b/AGENTS.md index 10ffbf753..d58b8094a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -28,7 +28,7 @@ Read `cmd/hi/README.md` in full before any `hi` command. Never guess flags. ## Pre-commit `prek install` once in the dev shell; hooks match CI (treefmt, mdformat, -`golangci-lint --new-from-rev=HEAD~1`, vendor hash). Never skip them +zizmor, `golangci-lint --new-from-rev=HEAD~1`, vendor hash). Never skip them (`--no-verify`, `SKIP=`). ## Rules that are not visible in the code diff --git a/flake.nix b/flake.nix index dac0261e4..f0c8357df 100644 --- a/flake.nix +++ b/flake.nix @@ -149,6 +149,7 @@ gh gh-actions-lock + zizmor ksh ko yq-go @@ -392,6 +393,30 @@ grep -F '"file:\''${CREDENTIALS_DIRECTORY}/oidc_client_secret"' ${doc.optionsCommonMark} touch $out ''; + + # Offline, so a new advisory for some action cannot fail unrelated + # pull requests. Not named zizmor: that would shadow pkgs.zizmor in + # devDeps' `with pkgs`. + zizmor-check = + pkgs.runCommand "headscale-zizmor" + { + nativeBuildInputs = [ pkgs.zizmor ]; + src = pkgs.lib.fileset.toSource { + root = ./.; + fileset = pkgs.lib.fileset.unions [ + ./.github + ./.pre-commit-config.yaml + ]; + }; + } + '' + # zizmor reads actions.lock only from a directory with a .git. + cp -r "$src" tree + chmod -R u+w tree + mkdir tree/.git + zizmor --offline --no-progress --cache-dir "$TMPDIR" tree + touch $out + ''; in { # `nix develop` @@ -449,6 +474,7 @@ headscale-checks = pkgs.testers.runNixOSTest (import ./nix/tests/checks.nix self); nixos-module = import ./nix/tests/module.nix self pkgs; inherit nixos-options; + zizmor = zizmor-check; } ); }