From 5ddcb0fcf5969e38af6d748e59a6e1742c82d054 Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 13 Nov 2026 18:59:32 -0500 Subject: [PATCH 1/4] ci: apply least privilege to workflows Default permissions to none, scope per job (publish drops unneeded contents:write, actions:read, packages:write), disable persisted checkout credentials except where release pushes, move expression interpolation in run steps to env vars, add timeouts and concurrency, fixed runner image. --- .github/workflows/build.yml | 29 +++++++++++++++++++++-------- .github/workflows/release.yml | 14 ++++++++------ .github/workflows/sast.yml | 7 ++++++- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index abc44c9e..25b48329 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,17 +12,25 @@ on: - synchronize workflow_dispatch: +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref_type != 'tag' && github.ref != 'refs/heads/master' }} + jobs: scan: + timeout-minutes: 15 permissions: packages: write contents: write # publish sbom to GH releases/tag assets - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Checkout branch uses: actions/checkout@v6 with: path: ${{ github.repository }} + persist-credentials: false # Perform SCA analysis for the code repository # Produces SBOM and CVE report @@ -35,7 +43,10 @@ jobs: build: needs: [scan] - runs-on: ubuntu-latest + timeout-minutes: 20 + runs-on: ubuntu-24.04 + permissions: + contents: read strategy: fail-fast: false matrix: @@ -43,6 +54,8 @@ jobs: steps: - name: Checkout branch uses: actions/checkout@v6 + with: + persist-credentials: false - name: Setup Node uses: actions/setup-node@v6 @@ -62,12 +75,11 @@ jobs: run: npm run build publish: - runs-on: ubuntu-latest + timeout-minutes: 15 + runs-on: ubuntu-24.04 permissions: - contents: write - id-token: write # For using token to sign images - actions: read # For getting workflow run info to build provenance - packages: write # Required for publishing provenance. Issue: https://github.com/slsa-framework/slsa-github-generator/tree/main/internal/builders/container#known-issues + contents: read + id-token: write # npm provenance (OIDC) if: ${{ github.ref_type == 'tag' && github.repository_owner == 'Kong' }} steps: # checkout tag @@ -75,6 +87,7 @@ jobs: uses: actions/checkout@v6 with: fetch-depth: 0 + persist-credentials: false - name: Setup Node.js uses: actions/setup-node@v6 @@ -89,6 +102,6 @@ jobs: run: npm run build - name: Publish to NPM - run: npm publish --no-git-checks --provenance --tag ${{ github.sha }} + run: npm publish --no-git-checks --provenance --tag "$GITHUB_SHA" env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b85ff9cf..207ed0e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,8 +7,7 @@ on: description: 'Tag version to release' required: true -permissions: - contents: write +permissions: {} env: # Release Tag to build and publish @@ -16,7 +15,10 @@ env: jobs: release: - runs-on: ubuntu-latest + timeout-minutes: 15 + runs-on: ubuntu-24.04 + permissions: + contents: read # writes use the GitHub App token steps: - name: Generate Insomnia Automation app token id: app-token @@ -30,7 +32,7 @@ jobs: with: fetch-depth: 0 token: ${{ steps.app-token.outputs.token }} - persist-credentials: true + persist-credentials: true # required: later steps push with the app token - name: Setup Node uses: actions/setup-node@v6 @@ -46,7 +48,7 @@ jobs: git config user.email "2326064+insomnia-automation@users.noreply.github.com" - name: Create new package version - run: npm version "${{ env.TAG }}" + run: npm version "$TAG" - name: DEBUG see tags run: | @@ -55,7 +57,7 @@ jobs: - name: Push version commit and tags run: | - git push origin v${{ env.TAG }} + git push origin "v${TAG}" git push origin master - name: Create Tag and Release diff --git a/.github/workflows/sast.yml b/.github/workflows/sast.yml index a45de59e..ca820ba2 100644 --- a/.github/workflows/sast.yml +++ b/.github/workflows/sast.yml @@ -7,10 +7,13 @@ on: - master workflow_dispatch: {} +permissions: {} + jobs: semgrep: name: Semgrep SAST - runs-on: ubuntu-latest + timeout-minutes: 10 + runs-on: ubuntu-24.04 permissions: # required for all workflows security-events: write @@ -22,4 +25,6 @@ jobs: steps: - uses: actions/checkout@v6 + with: + persist-credentials: false - uses: Kong/public-shared-actions/security-actions/semgrep@a18abf762d6e2444bcbfd20de70451ea1e3bc1b1 From 51a4e67abe9f57fd99bad656f3ba3a63be97bb76 Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 13 Nov 2026 18:59:32 -0500 Subject: [PATCH 2/4] ci: add step-security harden-runner to all workflows --- .github/workflows/build.yml | 15 +++++++++++++++ .github/workflows/release.yml | 5 +++++ .github/workflows/sast.yml | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 25b48329..4f171341 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,6 +26,11 @@ jobs: contents: write # publish sbom to GH releases/tag assets runs-on: ubuntu-24.04 steps: + - name: Harden Runner + uses: step-security/harden-runner@v2 + with: + egress-policy: audit + - name: Checkout branch uses: actions/checkout@v6 with: @@ -52,6 +57,11 @@ jobs: matrix: node-version: [20, 22, 24] steps: + - name: Harden Runner + uses: step-security/harden-runner@v2 + with: + egress-policy: audit + - name: Checkout branch uses: actions/checkout@v6 with: @@ -82,6 +92,11 @@ jobs: id-token: write # npm provenance (OIDC) if: ${{ github.ref_type == 'tag' && github.repository_owner == 'Kong' }} steps: + - name: Harden Runner + uses: step-security/harden-runner@v2 + with: + egress-policy: audit + # checkout tag - name: Checkout code uses: actions/checkout@v6 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 207ed0e9..d14fb785 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,11 @@ jobs: permissions: contents: read # writes use the GitHub App token steps: + - name: Harden Runner + uses: step-security/harden-runner@v2 + with: + egress-policy: audit + - name: Generate Insomnia Automation app token id: app-token uses: actions/create-github-app-token@v3 diff --git a/.github/workflows/sast.yml b/.github/workflows/sast.yml index ca820ba2..28caff83 100644 --- a/.github/workflows/sast.yml +++ b/.github/workflows/sast.yml @@ -24,6 +24,11 @@ jobs: if: (github.actor != 'dependabot[bot]') steps: + - name: Harden Runner + uses: step-security/harden-runner@v2 + with: + egress-policy: audit + - uses: actions/checkout@v6 with: persist-credentials: false From c9d8935ef8c4f8a8951b2060192ff2c726a9eef3 Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 13 Nov 2026 18:59:33 -0500 Subject: [PATCH 3/4] ci: pin actions to commit SHAs and bump to latest --- .github/workflows/build.yml | 18 +++++++++--------- .github/workflows/release.yml | 10 +++++----- .github/workflows/sast.yml | 6 +++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f171341..2fa203ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,12 +27,12 @@ jobs: runs-on: ubuntu-24.04 steps: - name: Harden Runner - uses: step-security/harden-runner@v2 + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit - name: Checkout branch - uses: actions/checkout@v6 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: path: ${{ github.repository }} persist-credentials: false @@ -41,7 +41,7 @@ jobs: # Produces SBOM and CVE report # Helps understand vulnerabilities / license compliance across third party dependencies - id: sca-project - uses: Kong/public-shared-actions/security-actions/sca@a18abf762d6e2444bcbfd20de70451ea1e3bc1b1 + uses: Kong/public-shared-actions/security-actions/sca@e33f6f6d5ccdaa8af245f29896a51fada48c5d7e # sca@4.1.4 with: dir: ${{ github.repository }} upload-sbom-release-assets: true @@ -58,17 +58,17 @@ jobs: node-version: [20, 22, 24] steps: - name: Harden Runner - uses: step-security/harden-runner@v2 + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit - name: Checkout branch - uses: actions/checkout@v6 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Setup Node - uses: actions/setup-node@v6 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: ${{ matrix.node-version }} @@ -93,19 +93,19 @@ jobs: if: ${{ github.ref_type == 'tag' && github.repository_owner == 'Kong' }} steps: - name: Harden Runner - uses: step-security/harden-runner@v2 + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit # checkout tag - name: Checkout code - uses: actions/checkout@v6 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 persist-credentials: false - name: Setup Node.js - uses: actions/setup-node@v6 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 registry-url: 'https://registry.npmjs.org' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d14fb785..2cea329e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,26 +21,26 @@ jobs: contents: read # writes use the GitHub App token steps: - name: Harden Runner - uses: step-security/harden-runner@v2 + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit - name: Generate Insomnia Automation app token id: app-token - uses: actions/create-github-app-token@v3 + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: app-id: ${{ secrets.GHA_INSOMNIA_AUTOMATION_APP_ID }} private-key: ${{ secrets.GHA_INSOMNIA_AUTOMATION_PRIVATE_KEY }} - name: Checkout code - uses: actions/checkout@v6 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 token: ${{ steps.app-token.outputs.token }} persist-credentials: true # required: later steps push with the app token - name: Setup Node - uses: actions/setup-node@v6 + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 @@ -66,7 +66,7 @@ jobs: git push origin master - name: Create Tag and Release - uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1 + uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0 id: core_tag_and_release with: tag: v${{ env.TAG }} diff --git a/.github/workflows/sast.yml b/.github/workflows/sast.yml index 28caff83..e8206390 100644 --- a/.github/workflows/sast.yml +++ b/.github/workflows/sast.yml @@ -25,11 +25,11 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@v2 + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 with: egress-policy: audit - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: Kong/public-shared-actions/security-actions/semgrep@a18abf762d6e2444bcbfd20de70451ea1e3bc1b1 + - uses: Kong/public-shared-actions/security-actions/semgrep@916a6f6221b7eab6f5ae53d061274d588c965ae6 # semgrep@4.0.4 From b83c1946311c5d77c4c5b2e6e82779ea05a4360e Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 13 Nov 2026 19:02:36 -0500 Subject: [PATCH 4/4] ci: keep semgrep action at last known-good pin Newer semgrep action (4.0.4) installs semgrep 1.135.0, which fails with 'No module named pkg_resources' on Python 3.12. --- .github/workflows/sast.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sast.yml b/.github/workflows/sast.yml index e8206390..2f6fdd5c 100644 --- a/.github/workflows/sast.yml +++ b/.github/workflows/sast.yml @@ -32,4 +32,4 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - - uses: Kong/public-shared-actions/security-actions/semgrep@916a6f6221b7eab6f5ae53d061274d588c965ae6 # semgrep@4.0.4 + - uses: Kong/public-shared-actions/security-actions/semgrep@a18abf762d6e2444bcbfd20de70451ea1e3bc1b1 # semgrep@4.0.1 (4.0.4 fails: semgrep needs pkg_resources)