Unverified Commit 1d252528 authored by Bruno Borges's avatar Bruno Borges Committed by GitHub
Browse files

chore: Harden workflows: least-privilege permissions + zizmor integration (#1039)

* Harden workflows with least-privilege permissions and zizmor

Apply GitHub Actions security best practices to the action's own
workflows and integrate zizmor to catch regressions.

- Add explicit least-privilege `permissions:` to every workflow
  (contents: read for read-only workflows; default-deny `{}` with
  job-scoped grants for codeql, publish-immutable-actions and
  update-config-files).
- Set `persist-credentials: false` on all checkout steps that don't
  need the GITHUB_TOKEN afterwards.
- Move `${{ ... }}` expansions out of `run:` blocks into `env:` vars
  to avoid template injection.
- Pin the alpine container image (alpine:latest -> alpine:3.21).
- Add a zizmor CI workflow that uploads SARIF to code scanning, plus a
  `.github/zizmor.yml` pinning policy (ref-pin for actions/* and
  github/*, hash-pin for third-party actions).

zizmor now reports no findings (offline and online).

Co-authored-by: default avatarCopilot <[email protected]>

* Potential fix for pull request finding

Co-authored-by: default avatarCopilot Autofix powered by AI <[email protected]>

* Fix indentation of if: in zizmor SARIF upload step

The `if:` key on the "Upload SARIF results to code scanning" step had no
indentation, producing invalid YAML ("Nested mappings are not allowed in
compact mappings"). This broke `npm run format-check` (prettier) in Basic
validation.

Indent `if:` to 8 spaces so it nests under the step alongside uses/with.

Co-authored-by: default avatarCopilot <[email protected]>

---------

Co-authored-by: default avatarCopilot <[email protected]>
Co-authored-by: default avatarCopilot Autofix powered by AI <[email protected]>
parent 668c1ea9
Loading
Loading
Loading
Loading
+3
Changes for .github/workflows/basic-validation.yml: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@ on:
    paths-ignore:
      - '**.md'

permissions:
  contents: read

jobs:
  call-basic-validation:
    name: Basic validation
+3
Changes for .github/workflows/check-dist.yml: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@ on:
      - '**.md'
  workflow_dispatch:

permissions:
  contents: read

jobs:
  call-check-dist:
    name: Check dist/
+2
Changes for .github/workflows/codeql-analysis.yml: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ on:
  schedule:
    - cron: '0 3 * * 0'

permissions: {}

jobs:
  call-codeQL-analysis:
    permissions:
+9
Changes for .github/workflows/e2e-cache-dependency-path.yml: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@ on:
    paths-ignore:
      - '**.md'

permissions:
  contents: read

defaults:
  run:
    shell: bash
@@ -25,6 +28,8 @@ jobs:
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for gradle
        uses: ./
        id: setup-java
@@ -52,6 +57,8 @@ jobs:
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for gradle
        uses: ./
        id: setup-java
@@ -77,6 +84,8 @@ jobs:
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for gradle
        uses: ./
        id: setup-java
+15
Changes for .github/workflows/e2e-cache.yml: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@ on:
    paths-ignore:
      - '**.md'

permissions:
  contents: read

defaults:
  run:
    shell: bash
@@ -25,6 +28,8 @@ jobs:
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for gradle
        uses: ./
        id: setup-java
@@ -51,6 +56,8 @@ jobs:
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for gradle
        uses: ./
        id: setup-java
@@ -74,6 +81,8 @@ jobs:
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for maven
        uses: ./
        id: setup-java
@@ -98,6 +107,8 @@ jobs:
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for maven
        uses: ./
        id: setup-java
@@ -125,6 +136,8 @@ jobs:
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for sbt
        uses: ./
        id: setup-java
@@ -175,6 +188,8 @@ jobs:
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          persist-credentials: false
      - name: Run setup-java with the cache for sbt
        uses: ./
        id: setup-java
Loading