diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index abc44c9e..2fa203ad 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,40 +12,63 @@ 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: Harden Runner + 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 # Perform SCA analysis for the code repository # 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 build: needs: [scan] - runs-on: ubuntu-latest + timeout-minutes: 20 + runs-on: ubuntu-24.04 + permissions: + contents: read strategy: fail-fast: false matrix: node-version: [20, 22, 24] steps: + - name: Harden Runner + 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 }} @@ -62,22 +85,27 @@ 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: + - name: Harden Runner + 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' @@ -89,6 +117,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..2cea329e 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,24 +15,32 @@ 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: Harden Runner + 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 + 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 @@ -46,7 +53,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,11 +62,11 @@ 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 - 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 a45de59e..2f6fdd5c 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 @@ -21,5 +24,12 @@ jobs: if: (github.actor != 'dependabot[bot]') steps: - - uses: actions/checkout@v6 - - uses: Kong/public-shared-actions/security-actions/semgrep@a18abf762d6e2444bcbfd20de70451ea1e3bc1b1 + - name: Harden Runner + uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 + with: + egress-policy: audit + + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: Kong/public-shared-actions/security-actions/semgrep@a18abf762d6e2444bcbfd20de70451ea1e3bc1b1 # semgrep@4.0.1 (4.0.4 fails: semgrep needs pkg_resources)