From cc2761a01ead3d8cd0c23ab28828f20751c3bd28 Mon Sep 17 00:00:00 2001 From: Naji Obeid Date: Thu, 2 Jan 2025 22:10:12 +0000 Subject: [PATCH 1/2] integrate zizmor in github actions --- .github/workflows/codeql-analysis.yml | 3 ++- .github/workflows/test.yml | 1 + .github/workflows/zizmor.yml | 36 +++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/zizmor.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index e538d6d8..5ce7ddfa 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -23,12 +23,13 @@ jobs: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. fetch-depth: 2 + persist-credentials: false # If this run was triggered by a pull request event, then checkout # the head of the pull request instead of the merge commit. - run: git checkout HEAD^2 if: ${{ github.event_name == 'pull_request' }} - + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4ea9cb72..05d869b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: true + persist-credentials: false - uses: actions/setup-java@v4 with: distribution: ${{ matrix.distribution }} diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml new file mode 100644 index 00000000..d915605e --- /dev/null +++ b/.github/workflows/zizmor.yml @@ -0,0 +1,36 @@ +name: GitHub Actions Security Analysis with zizmor + +on: + push: + branches: ["main"] + pull_request: + branches: ["**"] + +jobs: + zizmor: + name: zizmor latest via PyPI + runs-on: ubuntu-latest + permissions: + security-events: write + # required for workflows in private repositories + contents: read + actions: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v5 + + - name: Run zizmor + run: uvx zizmor --format sarif . > results.sarif + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload SARIF file + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: results.sarif + category: zizmor From 88a9edb9a8ed906a5ee7f58d36830c75e78deec7 Mon Sep 17 00:00:00 2001 From: Naji Obeid Date: Tue, 7 Jan 2025 21:22:51 +0000 Subject: [PATCH 2/2] change zizmor output format to report warnings --- .github/workflows/zizmor.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index d915605e..c09cf120 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -23,14 +23,10 @@ jobs: - name: Install the latest version of uv uses: astral-sh/setup-uv@v5 + with: + enable-cache: false - name: Run zizmor - run: uvx zizmor --format sarif . > results.sarif + run: uvx zizmor --format plain . env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: results.sarif - category: zizmor