From 0280be3f9f0bb12d57f3cc9cf807f1e97073bcd1 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Nov 2026 07:27:59 +0000 Subject: [PATCH 1/3] ci(pmg): move to PMG v0.34.0 in baseline mode The CI and release jobs ran PMG v1 in server mode without kernel enforcement. A step could bypass the proxy, and each job stopped PMG in its own step. The local action setup-pmg now runs safedep/pmg v0.34.0 with kernel enforcement, a network profile path for each job and network-mode audit. The profile files do not exist yet, so PMG applies no network policy and the job summary proposes a profile for each path. The post step of the action stops PMG, so the stop steps are gone. .github/pmg/config.yml turns on the cooldown with the 3 day window of pnpm-workspace.yaml. The SafeDep API SDK and safedep/dry skip it. The lint job of golangci-lint.yml gets PMG too. build-test-lint gets a timeout, because a proxy that hangs makes the job hang. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZuNMXjeREjigBHZu4DD4o --- .github/actions/setup-pmg/action.yml | 40 ++++++++++++++++++++++++++++ .github/pmg/config.yml | 17 ++++++++++++ .github/workflows/ci.yml | 29 +++++++++++--------- .github/workflows/golangci-lint.yml | 7 +++++ .github/workflows/goreleaser.yml | 28 +++++++++---------- 5 files changed, 93 insertions(+), 28 deletions(-) create mode 100644 .github/actions/setup-pmg/action.yml create mode 100644 .github/pmg/config.yml diff --git a/.github/actions/setup-pmg/action.yml b/.github/actions/setup-pmg/action.yml new file mode 100644 index 0000000..8a76d3d --- /dev/null +++ b/.github/actions/setup-pmg/action.yml @@ -0,0 +1,40 @@ +name: Set up PMG +description: >- + Starts the PMG proxy as root with kernel enforcement, so every process of the + job goes through it. Call it right after the checkout. At the end of the job, + the post step of safedep/pmg stops PMG, fails the job when PMG blocked a + package, and writes a job summary with a proposed network profile. See + https://github.com/safedep/pmg/blob/main/docs/github-action.md. + +inputs: + api-key: + description: SafeDep Cloud API key for the audit events. Empty sends none. + required: false + default: "" + tenant-id: + description: SafeDep Cloud tenant of the API key. + required: false + default: "" + network-profile: + description: >- + The network profile of the job, a path under .github/pmg/network/. While + the file does not exist, PMG applies no network policy, and the job + summary proposes a profile for this path. + required: true + +runs: + using: composite + steps: + - uses: safedep/pmg@ee9c6ccfb8c7cc31280fb91f1fa5031ec1c6ff18 # v0.34.0 + with: + api-key: ${{ inputs.api-key }} + tenant-id: ${{ inputs.tenant-id }} + endpoint-id: CICD_GHA_SAFEDEP_CLI + enforce: true + # The cooldown and its skip list. The path is relative to the checkout. + config-file: .github/pmg/config.yml + network-profile: ${{ inputs.network-profile }} + # audit lets every connection through and reports each destination + # that the profile does not allow. Change it to enforce when each job + # has a reviewed profile. + network-mode: audit diff --git a/.github/pmg/config.yml b/.github/pmg/config.yml new file mode 100644 index 0000000..2aab8bb --- /dev/null +++ b/.github/pmg/config.yml @@ -0,0 +1,17 @@ +# PMG settings for the CI jobs of this repository. setup-pmg passes this file +# to safedep/pmg as config-file. PMG reads the keys that it does not set from +# its own template. +dependency_cooldown: + enabled: true + # The same window as minimumReleaseAge (4320 minutes) in pnpm-workspace.yaml. + days: 3 + # We release these modules, and the SDK bump takes the build that BSR makes + # right after an API merge. The cooldown would block that build. PMG still + # runs malware analysis on them. List only modules that go.mod requires. + skip: + - purl: pkg:golang/buf.build/gen/go/safedep/api/grpc/go + reason: "SafeDep API SDK, generated by BSR" + - purl: pkg:golang/buf.build/gen/go/safedep/api/protocolbuffers/go + reason: "SafeDep API SDK, generated by BSR" + - purl: pkg:golang/github.com/safedep/dry + reason: "SafeDep shared library" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e090327..8f1e089 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,10 +8,20 @@ on: jobs: build-test-lint: runs-on: ubuntu-latest + # Under PMG the traffic of the runner goes through the proxy. A proxy that + # hangs makes the job hang until this timeout. + timeout-minutes: 30 steps: # actions/checkout v6.0.2 - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd + - name: Set up PMG + uses: ./.github/actions/setup-pmg + with: + api-key: ${{ secrets.SAFEDEP_CLOUD_API_KEY }} + tenant-id: ${{ secrets.SAFEDEP_CLOUD_TENANT_DOMAIN }} + network-profile: .github/pmg/network/ci-build-test-lint.yml + # actions/setup-go v6.4.0 - uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c with: @@ -45,6 +55,13 @@ jobs: with: fetch-depth: 0 + - name: Set up PMG + uses: ./.github/actions/setup-pmg + with: + api-key: ${{ secrets.SAFEDEP_CLOUD_API_KEY }} + tenant-id: ${{ secrets.SAFEDEP_CLOUD_TENANT_DOMAIN }} + network-profile: .github/pmg/network/ci-release-preflight.yml + - name: Set up Go uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: @@ -60,14 +77,6 @@ jobs: node-version: "24" cache: "pnpm" - - name: Install and configure PMG - uses: safedep/pmg@5ac0f275b83d9d5a9342c6aae977ec32fa330daa # v1 - with: - server-mode: true - api-key: ${{ secrets.SAFEDEP_CLOUD_API_KEY }} - tenant-id: ${{ secrets.SAFEDEP_CLOUD_TENANT_DOMAIN }} - endpoint-id: CICD_GHA_SAFEDEP_CLI - - name: Install dependencies run: pnpm install --frozen-lockfile @@ -79,7 +88,3 @@ jobs: - name: Release preflight run: pnpm nx run safedep-cli:release-preflight - - - name: Stop PMG proxy - if: always() - run: pmg proxy stop --fail-on-violation diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index e4ce5e3..f6192d4 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -21,6 +21,13 @@ jobs: steps: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 + - name: Set up PMG + uses: ./.github/actions/setup-pmg + with: + api-key: ${{ secrets.SAFEDEP_CLOUD_API_KEY }} + tenant-id: ${{ secrets.SAFEDEP_CLOUD_TENANT_DOMAIN }} + network-profile: .github/pmg/network/golangci-lint-golangci.yml + - uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6 with: go-version-file: go.mod diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 28a75dd..f8eae2d 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -25,6 +25,13 @@ jobs: with: fetch-depth: 0 + - name: Set up PMG + uses: ./.github/actions/setup-pmg + with: + api-key: ${{ secrets.SAFEDEP_CLOUD_API_KEY }} + tenant-id: ${{ secrets.SAFEDEP_CLOUD_TENANT_DOMAIN }} + network-profile: .github/pmg/network/goreleaser-release.yml + - name: Set up Go uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 with: @@ -41,14 +48,6 @@ jobs: registry-url: "https://registry.npmjs.org" cache: "pnpm" - - name: Install and configure PMG - uses: safedep/pmg@5ac0f275b83d9d5a9342c6aae977ec32fa330daa # v1 - with: - server-mode: true - api-key: ${{ secrets.SAFEDEP_CLOUD_API_KEY }} - tenant-id: ${{ secrets.SAFEDEP_CLOUD_TENANT_DOMAIN }} - endpoint-id: CICD_GHA_SAFEDEP_CLI - - name: Install dependencies run: pnpm install --frozen-lockfile @@ -73,20 +72,17 @@ jobs: with: subject-checksums: dist/checksums.txt + # Limitation: the post step of PMG gives its verdict at the end of the + # job, after the GitHub release and the npm publish. So it alerts but + # cannot stop a release. A block of a required dependency already fails + # its install step. The gap is an optional dependency. pnpm skips the + # block, exits 0 and reaches publish. - name: Publish npm packages (sync + build + publish via Nx) run: pnpm nx run safedep-cli:publish-npm env: VERSION: ${{ steps.version.outputs.version }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - # Limitation: runs after publish, so it alerts but cannot stop a - # release. A required dep block already fails the earlier install step. The - # gap is an optional dep: pnpm skips the block and exits 0, reaching - # publish. - - name: Stop PMG proxy - if: always() - run: pmg proxy stop --fail-on-violation - test-installation: needs: release runs-on: ${{ matrix.os }} From f7d071463ae8a08c517faf84fa17aebb36aa173d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Nov 2026 07:47:22 +0000 Subject: [PATCH 2/3] ci(pmg): pin the PMG binary to v0.34.0 The setup action pinned the safedep/pmg action to the v0.34.0 SHA, but passed no version. The action then installed the latest PMG release on each run. A new release reached CI on the day it shipped, under action scripts from v0.34.0. The binary is now v0.34.0, the same as the SHA. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZuNMXjeREjigBHZu4DD4o --- .github/actions/setup-pmg/action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/actions/setup-pmg/action.yml b/.github/actions/setup-pmg/action.yml index 8a76d3d..4967514 100644 --- a/.github/actions/setup-pmg/action.yml +++ b/.github/actions/setup-pmg/action.yml @@ -27,6 +27,8 @@ runs: steps: - uses: safedep/pmg@ee9c6ccfb8c7cc31280fb91f1fa5031ec1c6ff18 # v0.34.0 with: + # Dependabot updates only the SHA above. Keep this tag equal to it. + version: v0.34.0 api-key: ${{ inputs.api-key }} tenant-id: ${{ inputs.tenant-id }} endpoint-id: CICD_GHA_SAFEDEP_CLI From 0bb62e47093842552acd9fcd33227592a6dee0cd Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Nov 2026 07:51:52 +0000 Subject: [PATCH 3/3] ci(pmg): keep the PMG binary on the latest release The team keeps the PMG binary on the latest release, so CI tries each new release first. This reverts the pin to v0.34.0. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GZuNMXjeREjigBHZu4DD4o --- .github/actions/setup-pmg/action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/actions/setup-pmg/action.yml b/.github/actions/setup-pmg/action.yml index 4967514..8a76d3d 100644 --- a/.github/actions/setup-pmg/action.yml +++ b/.github/actions/setup-pmg/action.yml @@ -27,8 +27,6 @@ runs: steps: - uses: safedep/pmg@ee9c6ccfb8c7cc31280fb91f1fa5031ec1c6ff18 # v0.34.0 with: - # Dependabot updates only the SHA above. Keep this tag equal to it. - version: v0.34.0 api-key: ${{ inputs.api-key }} tenant-id: ${{ inputs.tenant-id }} endpoint-id: CICD_GHA_SAFEDEP_CLI