Skip to content

Self-improving AI Employees for everyone

security(workflows): zizmor hardening pass — close 30 advisory alerts

trohitg2bbbe083bd8c
diff --git a/.github/workflows/check-zizmor.yml b/.github/workflows/check-zizmor.yml
index 624efee0..3a6568ab 100644
--- a/.github/workflows/check-zizmor.yml
+++ b/.github/workflows/check-zizmor.yml
@@ -42,14 +42,23 @@ on:
permissions:
contents: read
+# zizmor/concurrency-limits — cancel an in-flight zizmor run on the same
+# ref when a new push arrives (PRs typically push multiple times; only
+# the latest matters).
+concurrency:
+ group: check-zizmor-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
zizmor:
name: Lint workflows
runs-on: ubuntu-latest
+ # zizmor's static analysis emits SARIF that GitHub renders in the
+ # Security → Code scanning tab. ``security-events: write`` is the
+ # minimum scope for that upload; ``contents``/``actions: read``
+ # cover repository + workflow metadata the analyzer reads.
permissions:
- # SARIF upload to the Security tab so findings render alongside
- # CodeQL results.
security-events: write
contents: read
actions: read
@@ -57,6 +66,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index d5a3bf7b..a39b0473 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -13,12 +13,27 @@ on:
permissions:
contents: read
+# zizmor/concurrency-limits — coalesce in-flight deploys to the latest
+# commit so a fast-pushed docs change doesn't deploy a stale revision
+# after a fresh one. Mintlify's deploy endpoint is idempotent.
+concurrency:
+ group: docs-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
deploy:
+ name: Deploy to Mintlify
runs-on: ubuntu-latest
+ # zizmor/secrets-outside-env — pin secret access to a deployment
+ # environment so ``MINTLIFY_TOKEN`` is only available to runs that
+ # pass the ``docs`` environment's protection rules (configure on
+ # the repo Settings → Environments page).
+ environment: docs
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
diff --git a/.github/workflows/predeploy.yml b/.github/workflows/predeploy.yml
index 88f3206f..5f56433e 100644
--- a/.github/workflows/predeploy.yml
+++ b/.github/workflows/predeploy.yml
@@ -42,6 +42,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Detect changed paths
id: filter
@@ -80,6 +82,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup environment
uses: ./.github/actions/setup
@@ -135,6 +139,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup environment
uses: ./.github/actions/setup
@@ -158,6 +164,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup environment
uses: ./.github/actions/setup
@@ -190,6 +198,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup environment
uses: ./.github/actions/setup
diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml
index 3b64d9f6..43cd53bb 100644
--- a/.github/workflows/publish-pypi.yml
+++ b/.github/workflows/publish-pypi.yml
@@ -44,6 +44,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
@@ -85,11 +87,12 @@ jobs:
name: Generate SLSA build provenance
needs: build
runs-on: ubuntu-latest
+ # ``actions/attest-build-provenance`` needs ``id-token: write``
+ # (OIDC token exchanged for a Sigstore signing key) and
+ # ``attestations: write`` (POST to the GitHub attestations
+ # endpoint). ``contents: read`` covers tarball checkout.
permissions:
- # OIDC token issuance for attestation signing.
id-token: write
- # Required to write the attestation back to the GitHub
- # attestations endpoint.
attestations: write
contents: read
steps:
@@ -120,8 +123,10 @@ jobs:
name: pypi
url: https://pypi.org/p/machinaos-server
+ # ``id-token: write`` is the OIDC scope ``pypa/gh-action-pypi-publish``
+ # exchanges for a short-lived PyPI upload token. No other scope is
+ # needed: the artifact comes from the prior job's upload-artifact.
permissions:
- # Required for the OIDC token exchange with PyPI.
id-token: write
steps:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index cef3577b..74160144 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -37,6 +37,14 @@ on:
permissions:
contents: read
+# zizmor/concurrency-limits — DO NOT cancel an in-flight release.
+# Concurrent releases against the same tag would race on npm publish
+# anyway; the group key here is purely so two operators can't manually
+# dispatch the workflow twice in the same minute and both hit npm.
+concurrency:
+ group: release-${{ github.ref }}
+ cancel-in-progress: false
+
# `dry_run` is only meaningful on workflow_dispatch; tag-pushed
# releases always publish. Computed once and surfaced to each
# publish job via `if:` gates below.
@@ -60,6 +68,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup environment
uses: ./.github/actions/setup
@@ -79,6 +89,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup environment
uses: ./.github/actions/setup
@@ -99,12 +111,26 @@ jobs:
name: Publish to npm (with provenance)
needs: build-for-publish
runs-on: ubuntu-latest
+ # zizmor/secrets-outside-env — pin ``NPM_TOKEN`` access to the
+ # ``npm`` environment so it's only available to runs that pass
+ # the environment's protection rules (manual approval / branch
+ # restrictions configured on Settings → Environments).
+ environment:
+ name: npm
+ url: https://www.npmjs.com/package/machinaos
+ # ``id-token: write`` powers npm provenance (Sigstore-signed
+ # publish via OIDC exchange) AND the ``attest-build-provenance``
+ # action below; ``contents: read`` for the source-tree
+ # checkout. ``NPM_TOKEN`` is read from secrets at the env-var
+ # level, so no extra scope.
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup Node.js
# ``cache:`` key intentionally omitted (release-job hardening).
@@ -167,12 +193,18 @@ jobs:
name: Publish to GitHub Packages
needs: build-for-publish
runs-on: ubuntu-latest
+ # ``packages: write`` is the scope ``npm publish`` against
+ # npm.pkg.github.com needs; ``contents: read`` for the source-tree
+ # checkout. No ``id-token`` because GHCR uses the workflow's
+ # default ``GITHUB_TOKEN`` rather than OIDC.
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup Node.js
# ``cache:`` key intentionally omitted (release-job hardening
@@ -225,6 +257,9 @@ jobs:
publish-pypi:
name: Publish to PyPI
needs: [predeploy, audit]
+ # The reusable ``publish-pypi.yml`` workflow declares its own
+ # ``id-token: write`` at the job level (the only scope OIDC needs);
+ # the caller passes through ``contents: read`` for source checkout.
permissions:
contents: read
id-token: write
@@ -242,6 +277,9 @@ jobs:
# and we don't want to leave stale release notes around.
if: needs.publish-npm.result == 'success' && github.event.inputs.dry_run != 'true'
runs-on: ubuntu-latest
+ # ``contents: write`` is the scope ``gh release create`` needs to
+ # publish the release notes back to the repo. No other scope; this
+ # job neither pushes commits nor reads secrets.
permissions:
contents: write
steps:
@@ -249,6 +287,7 @@ jobs:
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
+ persist-credentials: false # zizmor/artipacked — gh release uses GH_TOKEN env, no git push
- name: Extract version from tag
id: version
diff --git a/.github/workflows/rollback.yml b/.github/workflows/rollback.yml
index b444d389..cc5a5e93 100644
--- a/.github/workflows/rollback.yml
+++ b/.github/workflows/rollback.yml
@@ -48,10 +48,25 @@ on:
permissions:
contents: read
+# zizmor/concurrency-limits — serialize rollbacks on the same version
+# so two operators can't double-deprecate the same npm tarball or
+# open duplicate revert PRs. ``cancel-in-progress: false`` because
+# rolling back a rollback would leave the registry in an inconsistent
+# state.
+concurrency:
+ group: rollback-${{ inputs.version }}
+ cancel-in-progress: false
+
jobs:
deprecate-npm:
name: npm deprecate
runs-on: ubuntu-latest
+ # zizmor/secrets-outside-env — share the ``npm`` environment with
+ # publish-npm so ``NPM_TOKEN`` is gated by the same protection
+ # rules.
+ environment:
+ name: npm
+ url: https://www.npmjs.com/package/machinaos
# No id-token needed -- this uses NPM_TOKEN, not OIDC, because
# `npm deprecate` is not in the trusted-publisher allowlist.
permissions:
@@ -59,6 +74,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
@@ -120,6 +137,10 @@ jobs:
needs: deprecate-npm
if: inputs.open_revert_pr == true
runs-on: ubuntu-latest
+ # ``contents: write`` for ``git push`` of the revert branch;
+ # ``pull-requests: write`` for ``gh pr create``. The
+ # ``persist-credentials: true`` on the checkout below is
+ # intentional and audited by zizmor accordingly.
permissions:
contents: write
pull-requests: write
diff --git a/.github/workflows/test-install.yml b/.github/workflows/test-install.yml
index 0ba3bf68..a2d6b71b 100644
--- a/.github/workflows/test-install.yml
+++ b/.github/workflows/test-install.yml
@@ -10,9 +10,17 @@ on:
permissions:
contents: read
+# zizmor/concurrency-limits — coalesce in-flight test-install runs
+# against the same ref (and the workflow_call invocation from
+# release.yml). Latest run wins.
+concurrency:
+ group: test-install-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
# Test npm install from registry (post-release)
test-npm-install:
+ name: npm install (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@@ -25,6 +33,8 @@ jobs:
# separate git clone -- this checkout is only used to source
# the toolchain version file (single source of truth).
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup pnpm
uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4
@@ -117,6 +127,7 @@ jobs:
# Test git clone + pnpm run build (source contributor path)
test-git-clone:
+ name: git clone + build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@@ -129,6 +140,8 @@ jobs:
# separate git clone -- this checkout is only used to source
# the toolchain version file (single source of truth).
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false # zizmor/artipacked — read-only checkout
- name: Setup pnpm
uses: pnpm/action-setup@f40ffcd9367d9f12939873eb1018b921a783ffaa # v4
@@ -222,6 +235,7 @@ jobs:
# Test install.sh script (Linux/macOS)
test-install-script-unix:
+ name: install.sh (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@@ -238,6 +252,7 @@ jobs:
# Test install.ps1 script (Windows)
test-install-script-windows:
+ name: install.ps1 (windows)
runs-on: windows-latest
steps:
- name: Run install script