mirror of
https://github.com/juanfont/headscale.git
synced 2026-11-24 22:26:29 +09:00
nix, .github: gate workflows on zizmor
Flake check, nix-checks job and prek hook; offline, starting at zero findings.
This commit is contained in:
1 parent
e52ba94b0c
commit
7d07d53837
5 files changed
+50
-1
No files matched your search
@@ -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.
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user