From 053db5f3525d9066bdaec1389bf71efad5f5d509 Mon Sep 17 00:00:00 2001 From: waleed Date: Wed, 28 Oct 2026 14:47:20 +0200 Subject: [PATCH 1/3] fix: fail fast on non-Linux runners and document the Linux-only agent The Cimon agent is built on eBPF and exists only for Linux. The Windows and macOS releases of cimon are attest-only builds with no `agent` command, so pointing this action at them (or letting it download the Linux tarball on a Windows runner) ended in a confusing `unknown command "agent" for "cimon-attest"` from the binary. The main step now throws an explanatory error before downloading anything when process.platform is not linux, honouring fail-on-error like every other startup error. The post step skips its stop call on non-Linux runners instead of trying to run the Linux install script. The README gains a Supported platforms table pointing Windows and macOS users at the attest sub-action, and the action description says the same. Co-Authored-By: Claude Fable 5.1 --- README.md | 18 ++++++++++++++++++ action.yml | 2 +- dist/main/index.js | 14 ++++++++++++++ dist/post/index.js | 10 ++++++++++ src/main/index.js | 14 ++++++++++++++ src/post/index.js | 10 ++++++++++ 6 files changed, 67 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index de29fac..04bce74 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,24 @@ This action helps seamlessly deploy the agent into any desired GitHub Actions bu Learn more about Cimon in our [docs](https://docs.cimon.build). +## 🖥️ Supported platforms + +| Runner OS | `cycodelabs/cimon-action` (agent) | `cycodelabs/cimon-action/attest` | +| --------- | --------------------------------- | -------------------------------- | +| Linux | ✅ | ✅ | +| Windows | ❌ | ✅ | +| macOS | ❌ | ✅ | + +The agent deployed by this action (runtime monitoring, hardening, process and +file reports, automatic SBOM generation and the `CIMON_SBOM_*` settings) is +built on eBPF and runs **only on Linux runners**. The action fails fast with an +explanatory error on any other OS. + +The Windows and macOS releases of `cimon` are attest-only builds. Use the +[attest sub-action](./attest/README.md) there to generate and sign SLSA +provenance, and to sign an SBOM produced by another tool with +`cimon attest sbom`. + ## 🏃‍♂️ Getting Started with Cimon Getting started with Cimon is as simple as introducing a single step in the pipeline. Cimon Action should be the first step in each of your jobs. diff --git a/action.yml b/action.yml index b8b9b63..8d03eaf 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: Cimon by Cycode -description: Runtime Security Solution for your CI/CD Pipeline +description: Runtime Security Solution for your CI/CD Pipeline. Deploys the Cimon agent (Linux runners only; use cimon-action/attest on Windows and macOS). branding: icon: shield color: green diff --git a/dist/main/index.js b/dist/main/index.js index ed9a823..bf4854d 100644 --- a/dist/main/index.js +++ b/dist/main/index.js @@ -27653,6 +27653,20 @@ async function sudoExists() { } async function run(config) { + // The Cimon agent is built on eBPF and exists only for Linux. The + // Windows/macOS cimon releases are attest-only builds with no `agent` + // command, so bail out before downloading anything rather than + // failing later with `unknown command "agent" for "cimon-attest"`. + if (process.platform !== 'linux') { + throw new Error( + `cimon-action runs the Cimon agent (runtime monitoring, hardening, ` + + `SBOM generation), which is built on eBPF and is Linux-only; this ` + + `runner is ${process.platform}. On Windows and macOS use the attest ` + + `sub-action (cycodelabs/cimon-action/attest@v1) for provenance and ` + + `SBOM attestation instead.` + ); + } + let releasePath; if (config.cimon.releasePath != '') { diff --git a/dist/post/index.js b/dist/post/index.js index e29987b..a2e981f 100644 --- a/dist/post/index.js +++ b/dist/post/index.js @@ -127798,6 +127798,16 @@ function getCimonPath() { } async function run(config) { + // The main step refuses to start the agent on non-Linux runners (see + // src/main/index.js), so there is nothing to stop here. Skip instead + // of trying to download the Linux install script. + if (process.platform !== 'linux') { + _actions_core__WEBPACK_IMPORTED_MODULE_0__.info( + `Cimon agent is Linux-only; nothing to stop on ${process.platform}` + ); + return; + } + const cimonPath = getCimonPath(); // Ensure the Cimon binary is available (fallback: download from S3). diff --git a/src/main/index.js b/src/main/index.js index e45e272..eb528ea 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -221,6 +221,20 @@ async function sudoExists() { } async function run(config) { + // The Cimon agent is built on eBPF and exists only for Linux. The + // Windows/macOS cimon releases are attest-only builds with no `agent` + // command, so bail out before downloading anything rather than + // failing later with `unknown command "agent" for "cimon-attest"`. + if (process.platform !== 'linux') { + throw new Error( + `cimon-action runs the Cimon agent (runtime monitoring, hardening, ` + + `SBOM generation), which is built on eBPF and is Linux-only; this ` + + `runner is ${process.platform}. On Windows and macOS use the attest ` + + `sub-action (cycodelabs/cimon-action/attest@v1) for provenance and ` + + `SBOM attestation instead.` + ); + } + let releasePath; if (config.cimon.releasePath != '') { diff --git a/src/post/index.js b/src/post/index.js index 0fb0d38..d1056e6 100644 --- a/src/post/index.js +++ b/src/post/index.js @@ -67,6 +67,16 @@ function getCimonPath() { } async function run(config) { + // The main step refuses to start the agent on non-Linux runners (see + // src/main/index.js), so there is nothing to stop here. Skip instead + // of trying to download the Linux install script. + if (process.platform !== 'linux') { + core.info( + `Cimon agent is Linux-only; nothing to stop on ${process.platform}` + ); + return; + } + const cimonPath = getCimonPath(); // Ensure the Cimon binary is available (fallback: download from S3). From 0cf76a053ac3feb47bf15719c0967520eca9ddc5 Mon Sep 17 00:00:00 2001 From: waleed Date: Wed, 28 Oct 2026 14:47:28 +0200 Subject: [PATCH 2/3] feat(attest): add sbom input to sign a tool-generated SBOM attestation On Windows and macOS there is no Cimon agent, so automatic SBOM generation is not available. cimon v1.0.27 ships `cimon attest sbom`, which wraps an SBOM produced by another tool (CycloneDX JSON/XML, SPDX 2.x JSON/YAML/tag-value) in a signed in-toto attestation over the build artifacts. Expose it through the action: - `sbom`: path to the SBOM file. When set, the action runs `cimon attest sbom` after the provenance run, over the same subjects and with the same key / keyless / KMS / timestamp settings. - `signed-sbom-output`: output path (default sbom.intoto.jsonl.sig), also published as the `signed-sbom-path` step output and uploaded as a workflow artifact when report-artifact is on. The backend and signing flags are factored into helpers shared by both subcommands so the two attestations cannot drift apart. A bad `sbom` path fails before the provenance run. The Windows verify-pr job now exercises the input with a minimal CycloneDX document. Co-Authored-By: Claude Fable 5.1 --- .github/workflows/verify-pr.yaml | 17 +++- attest/README.md | 42 ++++++++ attest/action.yml | 20 ++++ attest/dist/index.js | 170 +++++++++++++++++++++---------- attest/index.js | 170 +++++++++++++++++++++---------- 5 files changed, 311 insertions(+), 108 deletions(-) diff --git a/.github/workflows/verify-pr.yaml b/.github/workflows/verify-pr.yaml index 692e61e..28b1cd0 100644 --- a/.github/workflows/verify-pr.yaml +++ b/.github/workflows/verify-pr.yaml @@ -43,6 +43,16 @@ jobs: run: | & "C:\Program Files\Git\usr\bin\openssl.exe" genrsa -out private-key.pem 3072 + # The agent (automatic SBOM generation) is Linux-only, so on Windows + # an SBOM comes from another tool and is signed via the `sbom` input. + # A minimal CycloneDX document stands in for a real generator here. + - name: Write sample CycloneDX SBOM + shell: pwsh + run: | + @' + {"bomFormat":"CycloneDX","specVersion":"1.5","version":1,"components":[{"type":"application","name":"sample","version":"0.0.1"}]} + '@ | Set-Content -Path sbom.cdx.json + - name: Cimon Attest (Windows, keyed) uses: ./attest with: @@ -50,13 +60,16 @@ jobs: secret: ${{ secrets.CIMON_SECRET }} subjects: dist\sample.exe sign-key: private-key.pem + sbom: sbom.cdx.json report-job-summary: true report-artifact: true fail-on-error: true - - name: Show provenance + - name: Show provenance and SBOM attestation shell: pwsh - run: Get-Content provenance.intoto.jsonl + run: | + Get-Content provenance.intoto.jsonl + Get-Item sbom.intoto.jsonl.sig | Select-Object FullName, Length verify: runs-on: ubuntu-22.04 diff --git a/attest/README.md b/attest/README.md index cf59fbe..dfacf19 100644 --- a/attest/README.md +++ b/attest/README.md @@ -35,6 +35,39 @@ matching `cimon` binary (`cimon.exe` on Windows). It uses `$RUNNER_TEMP` so it cooperates with on-prem GHES self-hosted runners that may not have `/tmp` writable. +## SBOM attestation (Windows, macOS, or any tool-generated SBOM) + +The Cimon agent that generates SBOMs automatically is Linux-only. On any +runner you can instead produce an SBOM with the tool of your choice and +have Cimon sign it as an in-toto attestation over the same artifacts, next +to the provenance, by passing it through the `sbom` input: + +```yaml +- name: Generate SBOM + shell: pwsh + run: syft dir:dist -o cyclonedx-json=sbom.cdx.json # any generator works + +- uses: cycodelabs/cimon-action/attest@v1 + with: + subjects: dist\my-app.exe dist\my-app.dll + sbom: sbom.cdx.json + sign-key: private-key.pem + signed-sbom-output: sbom.intoto.jsonl.sig +``` + +Accepted SBOM formats: CycloneDX (JSON or XML) and SPDX 2.x (JSON, YAML or +tag-value). The SBOM is signed with the same `sign-key` / `keyless` / KMS +settings as the provenance. Verify it with: + +```bash +cimon attest verify --type sbom --subjects "dist/my-app.exe dist/my-app.dll" \ + --key public-key.pem --signed-prov sbom.intoto.jsonl.sig +``` + +The same can be done by hand after the action, since it exports the binary +as `CIMON_PATH` and on `PATH`: `cimon attest sbom --sbom sbom.cdx.json +--subjects ... --key private-key.pem`. Requires cimon v1.0.27 or later. + ## GHES support The action honors `GITHUB_API_URL` and `GITHUB_SERVER_URL` (set @@ -98,12 +131,21 @@ releases accept these inputs and produce no timestamp. | `allow-submit-data-to-public-sigstore` | **Keyless only.** Required when using public Sigstore | `false` | | `provenance-output` | Path for unsigned provenance | `provenance.intoto.jsonl` | | `signed-provenance-output` | Path for signed provenance | `provenance.intoto.jsonl.sig` | +| `sbom` | Path to an SBOM produced by another tool (CycloneDX JSON/XML or SPDX 2.x JSON/YAML/tag-value) to sign as an SBOM attestation over the same subjects. Requires cimon v1.0.27 or later | — | +| `signed-sbom-output` | Path for the signed SBOM attestation. Used only when `sbom` is set | `sbom.intoto.jsonl.sig` | | `report-job-summary` | Render provenance in the workflow job summary | `true` | | `report-artifact` | Upload provenance as a workflow artifact | `true` | | `github-token` | Token used for build metadata enrichment | `${{ github.token }}` | | `log-level` | `trace` / `debug` / `info` | `info` | | `fail-on-error` | Fail the step on attestation errors | `false` | +## Outputs + +| Name | Description | +|---|---| +| `cimon-path` | Absolute path to the installed `cimon` / `cimon.exe` binary (also exported as `CIMON_PATH` and added to `PATH`) | +| `signed-sbom-path` | Path of the signed SBOM attestation. Empty unless `sbom` is set | + ## Development After editing `index.js`, rebuild the bundled distribution: diff --git a/attest/action.yml b/attest/action.yml index 387fe0a..4c07389 100644 --- a/attest/action.yml +++ b/attest/action.yml @@ -78,6 +78,22 @@ inputs: description: Signed provenance output path. Can be absolute path, or relative path to the default working directory required: false default: 'provenance.intoto.jsonl.sig' + sbom: + description: | + Path to an SBOM produced by another tool (syft, Microsoft sbom-tool, + cyclonedx-py, ...) to attest alongside the provenance. Accepts + CycloneDX (JSON or XML) and SPDX 2.x (JSON, YAML or tag-value). When + set, the action runs `cimon attest sbom` over the same subjects with + the same signing settings after the provenance run. Requires cimon + v1.0.27 or later. This is the way to get a signed SBOM attestation + on Windows and macOS, where the Cimon agent (automatic SBOM + generation) is not available. + required: false + default: '' + signed-sbom-output: + description: Signed SBOM attestation output path. Can be absolute path, or relative path to the default working directory. Used only when sbom is set + required: false + default: 'sbom.intoto.jsonl.sig' github-token: description: GitHub token for enriching build information required: false @@ -106,6 +122,10 @@ outputs: this action invocation. Downstream steps in the same job can also reach the binary via the CIMON_PATH env var, or call `cimon` / `cimon.exe` directly since the action adds the install dir to PATH. + signed-sbom-path: + description: | + Path of the signed SBOM attestation written by `cimon attest sbom`. + Empty when the sbom input is not set. runs: using: node20 diff --git a/attest/dist/index.js b/attest/dist/index.js index 0769217..6ab6c88 100644 --- a/attest/dist/index.js +++ b/attest/dist/index.js @@ -127706,6 +127706,8 @@ function getActionConfig() { skipSourceTreeCheck: _actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput( 'skip-source-tree-check' ), + sbom: _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput('sbom'), + signedSbomOutput: _actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput('signed-sbom-output'), }, report: { reportJobSummary: _actions_core__WEBPACK_IMPORTED_MODULE_0__.getBooleanInput('report-job-summary'), @@ -127714,6 +127716,60 @@ function getActionConfig() { }; } +// backendArgs returns the Cycode backend and logging flags shared by every +// `cimon attest` subcommand. +function backendArgs(config) { + const args = []; + if (config.cimon.clientId !== '') + args.push('--client-id', config.cimon.clientId); + if (config.cimon.secret !== '') args.push('--secret', config.cimon.secret); + if (config.cimon.url !== '') args.push('--url', config.cimon.url); + if (config.cimon.logLevel !== '') + args.push('--log-level', config.cimon.logLevel); + return args; +} + +// signingArgs returns the key / keyless / Sigstore / timestamp flags shared +// by `attest generate-and-sign` and `attest sbom`, so both attestations are +// signed the same way. +function signingArgs(config) { + const args = []; + if (config.attest.signKey !== '') args.push('--key', config.attest.signKey); + if (config.attest.keyless) { + args.push('--keyless'); + + args.push(`--tlog-upload=${config.attest.tlogUpload}`); + args.push(`--include-timestamp=${config.attest.includeTimestamp}`); + args.push(`--yes=${config.attest.allowSubmitDataToPublicSigstore}`); + + if (config.attest.fulcioServerUrl !== '') { + args.push(`--fulcio-server-url=${config.attest.fulcioServerUrl}`); + } + + if (config.attest.rekorServerUrl !== '') { + args.push(`--rekor-server-url=${config.attest.rekorServerUrl}`); + } + + if (config.attest.timestampServerUrl !== '') { + args.push( + `--timestamp-server-url=${config.attest.timestampServerUrl}` + ); + } + } else if (config.attest.signKey !== '' && config.attest.includeTimestamp) { + // Key-based signing only timestamps on an explicit request, so the + // inputs are forwarded only when include-timestamp is true. Older + // cimon releases accept and ignore them. + args.push('--include-timestamp=true'); + + if (config.attest.timestampServerUrl !== '') { + args.push( + `--timestamp-server-url=${config.attest.timestampServerUrl}` + ); + } + } + return args; +} + async function run(config) { let releasePath; @@ -127784,71 +127840,50 @@ async function run(config) { config.attest.subjects = config.attest.imageRef; } - // Prepare CLI arguments conditionally - const args = ['attest', 'generate-and-sign']; + // Validate the optional SBOM input up front so a bad path fails before + // the provenance run rather than after it. + if (config.attest.sbom !== '' && !fs__WEBPACK_IMPORTED_MODULE_6__.existsSync(config.attest.sbom)) { + throw new Error( + `SBOM file does not exist: ${config.attest.sbom}. Generate it ` + + `with an SBOM tool (syft, sbom-tool, cyclonedx-py, ...) in an ` + + `earlier step, or unset the sbom input.` + ); + } + + const provenanceArgs = ['attest', 'generate-and-sign']; if (config.attest.subjects !== '') - args.push('--subjects', config.attest.subjects); + provenanceArgs.push('--subjects', config.attest.subjects); if (config.attest.provenanceOutput !== '') - args.push('--output-prov', config.attest.provenanceOutput); + provenanceArgs.push('--output-prov', config.attest.provenanceOutput); if (config.attest.signedProvenanceOutput !== '') - args.push('--output-signed-prov', config.attest.signedProvenanceOutput); - if (config.attest.signKey !== '') args.push('--key', config.attest.signKey); + provenanceArgs.push( + '--output-signed-prov', + config.attest.signedProvenanceOutput + ); if (config.attest.sourcePath !== '') - args.push('--source-path', config.attest.sourcePath); + provenanceArgs.push('--source-path', config.attest.sourcePath); if (config.attest.skipSourceTreeCheck) - args.push('--skip-source-tree-check'); - if (config.cimon.clientId !== '') - args.push('--client-id', config.cimon.clientId); - if (config.cimon.secret !== '') args.push('--secret', config.cimon.secret); - if (config.cimon.url !== '') args.push('--url', config.cimon.url); - if (config.cimon.logLevel !== '') - args.push('--log-level', config.cimon.logLevel); - if (config.report.reportJobSummary) args.push('--report-job-summary'); - if (config.attest.keyless) { - args.push('--keyless'); - - args.push(`--tlog-upload=${config.attest.tlogUpload}`); - args.push(`--include-timestamp=${config.attest.includeTimestamp}`); - args.push(`--yes=${config.attest.allowSubmitDataToPublicSigstore}`); - - if (config.attest.fulcioServerUrl !== '') { - args.push(`--fulcio-server-url=${config.attest.fulcioServerUrl}`); - } - - if (config.attest.rekorServerUrl !== '') { - args.push(`--rekor-server-url=${config.attest.rekorServerUrl}`); - } - - if (config.attest.timestampServerUrl !== '') { - args.push( - `--timestamp-server-url=${config.attest.timestampServerUrl}` - ); - } - } else if (config.attest.signKey !== '' && config.attest.includeTimestamp) { - // Key-based signing only timestamps on an explicit request, so the - // inputs are forwarded only when include-timestamp is true. Older - // cimon releases accept and ignore them. - args.push('--include-timestamp=true'); + provenanceArgs.push('--skip-source-tree-check'); + if (config.report.reportJobSummary) + provenanceArgs.push('--report-job-summary'); + provenanceArgs.push(...backendArgs(config), ...signingArgs(config)); - if (config.attest.timestampServerUrl !== '') { - args.push( - `--timestamp-server-url=${config.attest.timestampServerUrl}` - ); - } - } - - await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(releasePath, args, { + const execOptions = { env: { ...process.env, GITHUB_TOKEN: config.github.token, }, - }); + }; + + await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(releasePath, provenanceArgs, execOptions); - if (config.report.reportArtifact) { - const client = new _actions_artifact__WEBPACK_IMPORTED_MODULE_3__.DefaultArtifactClient(); - const jobId = process.env.GITHUB_JOB; - const randomSuffix = Math.floor(Math.random() * 1000); + const client = config.report.reportArtifact + ? new _actions_artifact__WEBPACK_IMPORTED_MODULE_3__.DefaultArtifactClient() + : null; + const jobId = process.env.GITHUB_JOB; + const randomSuffix = Math.floor(Math.random() * 1000); + if (client) { client.uploadArtifact( `provenance-${jobId}-${randomSuffix}`, [config.attest.provenanceOutput], @@ -127866,6 +127901,35 @@ async function run(config) { } _actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Build runtime SLSA provenance finished successfully`); + + // Optional SBOM attestation: wrap an SBOM produced by another tool in a + // signed in-toto statement over the same subjects. On Windows/macOS + // the agent (automatic SBOM generation) does not exist, so this is the + // only way to get an SBOM attestation there. + if (config.attest.sbom !== '') { + const sbomArgs = ['attest', 'sbom', '--sbom', config.attest.sbom]; + if (config.attest.subjects !== '') + sbomArgs.push('--subjects', config.attest.subjects); + if (config.attest.signedSbomOutput !== '') + sbomArgs.push('--output-signed-sbom', config.attest.signedSbomOutput); + sbomArgs.push(...backendArgs(config), ...signingArgs(config)); + + await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(releasePath, sbomArgs, execOptions); + + if (config.attest.signedSbomOutput !== '') { + _actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput('signed-sbom-path', config.attest.signedSbomOutput); + if (client) { + client.uploadArtifact( + `signed-sbom-${jobId}-${randomSuffix}`, + [config.attest.signedSbomOutput], + path__WEBPACK_IMPORTED_MODULE_5__.dirname(config.attest.signedSbomOutput), + { continueOnError: true } + ); + } + } + + _actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`SBOM attestation finished successfully`); + } } try { diff --git a/attest/index.js b/attest/index.js index a98d0df..d9761bb 100644 --- a/attest/index.js +++ b/attest/index.js @@ -146,6 +146,8 @@ function getActionConfig() { skipSourceTreeCheck: core.getBooleanInput( 'skip-source-tree-check' ), + sbom: core.getInput('sbom'), + signedSbomOutput: core.getInput('signed-sbom-output'), }, report: { reportJobSummary: core.getBooleanInput('report-job-summary'), @@ -154,6 +156,60 @@ function getActionConfig() { }; } +// backendArgs returns the Cycode backend and logging flags shared by every +// `cimon attest` subcommand. +function backendArgs(config) { + const args = []; + if (config.cimon.clientId !== '') + args.push('--client-id', config.cimon.clientId); + if (config.cimon.secret !== '') args.push('--secret', config.cimon.secret); + if (config.cimon.url !== '') args.push('--url', config.cimon.url); + if (config.cimon.logLevel !== '') + args.push('--log-level', config.cimon.logLevel); + return args; +} + +// signingArgs returns the key / keyless / Sigstore / timestamp flags shared +// by `attest generate-and-sign` and `attest sbom`, so both attestations are +// signed the same way. +function signingArgs(config) { + const args = []; + if (config.attest.signKey !== '') args.push('--key', config.attest.signKey); + if (config.attest.keyless) { + args.push('--keyless'); + + args.push(`--tlog-upload=${config.attest.tlogUpload}`); + args.push(`--include-timestamp=${config.attest.includeTimestamp}`); + args.push(`--yes=${config.attest.allowSubmitDataToPublicSigstore}`); + + if (config.attest.fulcioServerUrl !== '') { + args.push(`--fulcio-server-url=${config.attest.fulcioServerUrl}`); + } + + if (config.attest.rekorServerUrl !== '') { + args.push(`--rekor-server-url=${config.attest.rekorServerUrl}`); + } + + if (config.attest.timestampServerUrl !== '') { + args.push( + `--timestamp-server-url=${config.attest.timestampServerUrl}` + ); + } + } else if (config.attest.signKey !== '' && config.attest.includeTimestamp) { + // Key-based signing only timestamps on an explicit request, so the + // inputs are forwarded only when include-timestamp is true. Older + // cimon releases accept and ignore them. + args.push('--include-timestamp=true'); + + if (config.attest.timestampServerUrl !== '') { + args.push( + `--timestamp-server-url=${config.attest.timestampServerUrl}` + ); + } + } + return args; +} + async function run(config) { let releasePath; @@ -224,71 +280,50 @@ async function run(config) { config.attest.subjects = config.attest.imageRef; } - // Prepare CLI arguments conditionally - const args = ['attest', 'generate-and-sign']; + // Validate the optional SBOM input up front so a bad path fails before + // the provenance run rather than after it. + if (config.attest.sbom !== '' && !fs.existsSync(config.attest.sbom)) { + throw new Error( + `SBOM file does not exist: ${config.attest.sbom}. Generate it ` + + `with an SBOM tool (syft, sbom-tool, cyclonedx-py, ...) in an ` + + `earlier step, or unset the sbom input.` + ); + } + + const provenanceArgs = ['attest', 'generate-and-sign']; if (config.attest.subjects !== '') - args.push('--subjects', config.attest.subjects); + provenanceArgs.push('--subjects', config.attest.subjects); if (config.attest.provenanceOutput !== '') - args.push('--output-prov', config.attest.provenanceOutput); + provenanceArgs.push('--output-prov', config.attest.provenanceOutput); if (config.attest.signedProvenanceOutput !== '') - args.push('--output-signed-prov', config.attest.signedProvenanceOutput); - if (config.attest.signKey !== '') args.push('--key', config.attest.signKey); + provenanceArgs.push( + '--output-signed-prov', + config.attest.signedProvenanceOutput + ); if (config.attest.sourcePath !== '') - args.push('--source-path', config.attest.sourcePath); + provenanceArgs.push('--source-path', config.attest.sourcePath); if (config.attest.skipSourceTreeCheck) - args.push('--skip-source-tree-check'); - if (config.cimon.clientId !== '') - args.push('--client-id', config.cimon.clientId); - if (config.cimon.secret !== '') args.push('--secret', config.cimon.secret); - if (config.cimon.url !== '') args.push('--url', config.cimon.url); - if (config.cimon.logLevel !== '') - args.push('--log-level', config.cimon.logLevel); - if (config.report.reportJobSummary) args.push('--report-job-summary'); - if (config.attest.keyless) { - args.push('--keyless'); - - args.push(`--tlog-upload=${config.attest.tlogUpload}`); - args.push(`--include-timestamp=${config.attest.includeTimestamp}`); - args.push(`--yes=${config.attest.allowSubmitDataToPublicSigstore}`); - - if (config.attest.fulcioServerUrl !== '') { - args.push(`--fulcio-server-url=${config.attest.fulcioServerUrl}`); - } + provenanceArgs.push('--skip-source-tree-check'); + if (config.report.reportJobSummary) + provenanceArgs.push('--report-job-summary'); + provenanceArgs.push(...backendArgs(config), ...signingArgs(config)); - if (config.attest.rekorServerUrl !== '') { - args.push(`--rekor-server-url=${config.attest.rekorServerUrl}`); - } - - if (config.attest.timestampServerUrl !== '') { - args.push( - `--timestamp-server-url=${config.attest.timestampServerUrl}` - ); - } - } else if (config.attest.signKey !== '' && config.attest.includeTimestamp) { - // Key-based signing only timestamps on an explicit request, so the - // inputs are forwarded only when include-timestamp is true. Older - // cimon releases accept and ignore them. - args.push('--include-timestamp=true'); - - if (config.attest.timestampServerUrl !== '') { - args.push( - `--timestamp-server-url=${config.attest.timestampServerUrl}` - ); - } - } - - await exec.exec(releasePath, args, { + const execOptions = { env: { ...process.env, GITHUB_TOKEN: config.github.token, }, - }); + }; + + await exec.exec(releasePath, provenanceArgs, execOptions); - if (config.report.reportArtifact) { - const client = new DefaultArtifactClient(); - const jobId = process.env.GITHUB_JOB; - const randomSuffix = Math.floor(Math.random() * 1000); + const client = config.report.reportArtifact + ? new DefaultArtifactClient() + : null; + const jobId = process.env.GITHUB_JOB; + const randomSuffix = Math.floor(Math.random() * 1000); + if (client) { client.uploadArtifact( `provenance-${jobId}-${randomSuffix}`, [config.attest.provenanceOutput], @@ -306,6 +341,35 @@ async function run(config) { } core.info(`Build runtime SLSA provenance finished successfully`); + + // Optional SBOM attestation: wrap an SBOM produced by another tool in a + // signed in-toto statement over the same subjects. On Windows/macOS + // the agent (automatic SBOM generation) does not exist, so this is the + // only way to get an SBOM attestation there. + if (config.attest.sbom !== '') { + const sbomArgs = ['attest', 'sbom', '--sbom', config.attest.sbom]; + if (config.attest.subjects !== '') + sbomArgs.push('--subjects', config.attest.subjects); + if (config.attest.signedSbomOutput !== '') + sbomArgs.push('--output-signed-sbom', config.attest.signedSbomOutput); + sbomArgs.push(...backendArgs(config), ...signingArgs(config)); + + await exec.exec(releasePath, sbomArgs, execOptions); + + if (config.attest.signedSbomOutput !== '') { + core.setOutput('signed-sbom-path', config.attest.signedSbomOutput); + if (client) { + client.uploadArtifact( + `signed-sbom-${jobId}-${randomSuffix}`, + [config.attest.signedSbomOutput], + path.dirname(config.attest.signedSbomOutput), + { continueOnError: true } + ); + } + } + + core.info(`SBOM attestation finished successfully`); + } } try { From 5a293f44d8c1e37d19b38adb38d53789303a87c6 Mon Sep 17 00:00:00 2001 From: waleed Date: Wed, 28 Oct 2026 18:19:39 +0200 Subject: [PATCH 3/3] attest: review follow-ups for the sbom input and platform docs - Check the sbom path only after the provenance run, so a wrong value for this optional input can no longer block the provenance attestation (with the default fail-on-error: false it used to skip both and warn). - README: say the step logs an explanatory error and fails only with fail-on-error: true. - action.yml: shorten the Marketplace description to under 125 chars. - attest/README: add client-id/secret to the sbom and verify examples and note the CIMON_CLIENT_ID/CIMON_SECRET env alternative; drop the KMS mention (the kms input lands separately in #135). - Rebuild attest/dist. Co-Authored-By: Claude Fable 5.1 --- README.md | 5 +++-- action.yml | 2 +- attest/README.md | 20 ++++++++++++++++---- attest/dist/index.js | 22 +++++++++++----------- attest/index.js | 22 +++++++++++----------- 5 files changed, 42 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 04bce74..443c573 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,9 @@ Learn more about Cimon in our [docs](https://docs.cimon.build). The agent deployed by this action (runtime monitoring, hardening, process and file reports, automatic SBOM generation and the `CIMON_SBOM_*` settings) is -built on eBPF and runs **only on Linux runners**. The action fails fast with an -explanatory error on any other OS. +built on eBPF and runs **only on Linux runners**. On any other OS the action +stops before installing anything and logs an explanatory error (the step +fails with `fail-on-error: true`). The Windows and macOS releases of `cimon` are attest-only builds. Use the [attest sub-action](./attest/README.md) there to generate and sign SLSA diff --git a/action.yml b/action.yml index 8d03eaf..cf59e43 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: Cimon by Cycode -description: Runtime Security Solution for your CI/CD Pipeline. Deploys the Cimon agent (Linux runners only; use cimon-action/attest on Windows and macOS). +description: Runtime Security Solution for your CI/CD Pipeline. Linux runners only; use cimon-action/attest on Windows and macOS. branding: icon: shield color: green diff --git a/attest/README.md b/attest/README.md index dfacf19..b97ed08 100644 --- a/attest/README.md +++ b/attest/README.md @@ -49,6 +49,8 @@ to the provenance, by passing it through the `sbom` input: - uses: cycodelabs/cimon-action/attest@v1 with: + client-id: ${{ secrets.CIMON_CLIENT_ID }} + secret: ${{ secrets.CIMON_SECRET }} subjects: dist\my-app.exe dist\my-app.dll sbom: sbom.cdx.json sign-key: private-key.pem @@ -56,17 +58,27 @@ to the provenance, by passing it through the `sbom` input: ``` Accepted SBOM formats: CycloneDX (JSON or XML) and SPDX 2.x (JSON, YAML or -tag-value). The SBOM is signed with the same `sign-key` / `keyless` / KMS +tag-value). The SBOM is signed with the same `sign-key` / `keyless` settings as the provenance. Verify it with: ```bash -cimon attest verify --type sbom --subjects "dist/my-app.exe dist/my-app.dll" \ +cimon attest verify --client-id "$CIMON_CLIENT_ID" --secret "$CIMON_SECRET" \ + --type sbom --subjects "dist/my-app.exe dist/my-app.dll" \ --key public-key.pem --signed-prov sbom.intoto.jsonl.sig ``` The same can be done by hand after the action, since it exports the binary -as `CIMON_PATH` and on `PATH`: `cimon attest sbom --sbom sbom.cdx.json ---subjects ... --key private-key.pem`. Requires cimon v1.0.27 or later. +as `CIMON_PATH` and on `PATH`: + +```bash +cimon attest sbom --client-id "$CIMON_CLIENT_ID" --secret "$CIMON_SECRET" \ + --sbom sbom.cdx.json --subjects "dist/my-app.exe dist/my-app.dll" \ + --key private-key.pem +``` + +`cimon attest sbom` and `cimon attest verify` need the Cycode credentials +either as `--client-id` / `--secret` or as the `CIMON_CLIENT_ID` / +`CIMON_SECRET` environment variables. Requires cimon v1.0.27 or later. ## GHES support diff --git a/attest/dist/index.js b/attest/dist/index.js index 6ab6c88..f6b1b0d 100644 --- a/attest/dist/index.js +++ b/attest/dist/index.js @@ -127840,16 +127840,6 @@ async function run(config) { config.attest.subjects = config.attest.imageRef; } - // Validate the optional SBOM input up front so a bad path fails before - // the provenance run rather than after it. - if (config.attest.sbom !== '' && !fs__WEBPACK_IMPORTED_MODULE_6__.existsSync(config.attest.sbom)) { - throw new Error( - `SBOM file does not exist: ${config.attest.sbom}. Generate it ` + - `with an SBOM tool (syft, sbom-tool, cyclonedx-py, ...) in an ` + - `earlier step, or unset the sbom input.` - ); - } - const provenanceArgs = ['attest', 'generate-and-sign']; if (config.attest.subjects !== '') provenanceArgs.push('--subjects', config.attest.subjects); @@ -127905,8 +127895,18 @@ async function run(config) { // Optional SBOM attestation: wrap an SBOM produced by another tool in a // signed in-toto statement over the same subjects. On Windows/macOS // the agent (automatic SBOM generation) does not exist, so this is the - // only way to get an SBOM attestation there. + // only way to get an SBOM attestation there. The path is checked only + // here, after the provenance run, so a bad value for this optional + // input never blocks the provenance attestation. if (config.attest.sbom !== '') { + if (!fs__WEBPACK_IMPORTED_MODULE_6__.existsSync(config.attest.sbom)) { + throw new Error( + `SBOM file does not exist: ${config.attest.sbom}. Generate it ` + + `with an SBOM tool (syft, sbom-tool, cyclonedx-py, ...) in an ` + + `earlier step, or unset the sbom input.` + ); + } + const sbomArgs = ['attest', 'sbom', '--sbom', config.attest.sbom]; if (config.attest.subjects !== '') sbomArgs.push('--subjects', config.attest.subjects); diff --git a/attest/index.js b/attest/index.js index d9761bb..dc845e9 100644 --- a/attest/index.js +++ b/attest/index.js @@ -280,16 +280,6 @@ async function run(config) { config.attest.subjects = config.attest.imageRef; } - // Validate the optional SBOM input up front so a bad path fails before - // the provenance run rather than after it. - if (config.attest.sbom !== '' && !fs.existsSync(config.attest.sbom)) { - throw new Error( - `SBOM file does not exist: ${config.attest.sbom}. Generate it ` + - `with an SBOM tool (syft, sbom-tool, cyclonedx-py, ...) in an ` + - `earlier step, or unset the sbom input.` - ); - } - const provenanceArgs = ['attest', 'generate-and-sign']; if (config.attest.subjects !== '') provenanceArgs.push('--subjects', config.attest.subjects); @@ -345,8 +335,18 @@ async function run(config) { // Optional SBOM attestation: wrap an SBOM produced by another tool in a // signed in-toto statement over the same subjects. On Windows/macOS // the agent (automatic SBOM generation) does not exist, so this is the - // only way to get an SBOM attestation there. + // only way to get an SBOM attestation there. The path is checked only + // here, after the provenance run, so a bad value for this optional + // input never blocks the provenance attestation. if (config.attest.sbom !== '') { + if (!fs.existsSync(config.attest.sbom)) { + throw new Error( + `SBOM file does not exist: ${config.attest.sbom}. Generate it ` + + `with an SBOM tool (syft, sbom-tool, cyclonedx-py, ...) in an ` + + `earlier step, or unset the sbom input.` + ); + } + const sbomArgs = ['attest', 'sbom', '--sbom', config.attest.sbom]; if (config.attest.subjects !== '') sbomArgs.push('--subjects', config.attest.subjects);