From 258af21df0b772d77b22ffa85ef5a4b89816dbe8 Mon Sep 17 00:00:00 2001 From: Steven Hartland Date: Fri, 20 Nov 2026 16:48:38 +0000 Subject: [PATCH] ci: restrict token permissions and pin actions The workflows ran with the default GITHUB_TOKEN permissions, granting every job more access than it needs. They now default to read-only contents, with write access only on the job that publishes releases. Third-party actions are pinned to commit hashes, so a moved tag can't change what runs with the repository's token. --- .github/workflows/build.yaml | 5 ++++- .github/workflows/release.yaml | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e5a4ecc..42470a4 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,6 +6,9 @@ on: pull_request: branches: [ main ] +permissions: + contents: read + jobs: build_linux: runs-on: ubuntu-latest @@ -41,7 +44,7 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v6 - - uses: ilammy/msvc-dev-cmd@v1 + - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 - name: nmake debug build run: | nmake -f Makefile.noauto windows_debug diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index b8a00d9..6285975 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -5,6 +5,9 @@ on: tags: - 'v*' +permissions: + contents: read + jobs: build_linux: runs-on: ubuntu-latest @@ -45,7 +48,7 @@ jobs: QSTAT_VERSION: ${{ github.ref_name }} steps: - uses: actions/checkout@v6 - - uses: ilammy/msvc-dev-cmd@v1 + - uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 - name: nmake run: | nmake -f Makefile.noauto windows windows_debug @@ -57,6 +60,9 @@ jobs: # https://github.com/vmactions/freebsd-vm release: runs-on: ubuntu-latest + permissions: + # needed to create the GitHub release + contents: write needs: - build_windows - build_linux @@ -69,7 +75,7 @@ jobs: - name: zip run: zip -r release.zip bin/* qstat.cfg contrib.cfg LICENSE.* - name: Release - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: