Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,19 @@ jobs:
test "${{ steps.radar.outputs.gate-tripped }}" = false
test "${{ steps.radar.outputs.gate-incomplete }}" = true
test "${{ steps.tolerant.outputs.gate-incomplete }}" = true

# An empty key outside fork and Dependabot pull requests must fail, never pass.
keyless:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- id: keyless
continue-on-error: true
uses: ./
with:
api-key: ''
file: test/package-lock.json
upload-sarif: false
- run: |
test "${{ steps.keyless.outcome }}" = failure
test "${{ steps.keyless.outputs.skipped }}" = ""
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7
- uses: offseq/radar-scan-action@v1
with:
api-key: ${{ secrets.RADAR_API_KEY }}
Expand All @@ -38,7 +38,7 @@ Get an API key in [Console → Settings](https://radar.offseq.com/console) and s

| Input | Default | |
|---|---|---|
| `api-key` | – | Radar API key. Required. |
| `api-key` | – | Radar API key. On fork and Dependabot pull requests, which get no secrets, an empty key skips the scan with a warning (`skipped` is `true`); anywhere else an empty key fails the step. |
| `file` | – | SBOM or lockfile to scan. Required. |
| `fail-on` | empty | `critical`, `high`, `medium`, `low`, `kev` or `exploited`. Only version-confirmed findings count. Empty never fails. |
| `fail-on-incomplete` | `true` | Fail when the gate could not evaluate every package, e.g. over the server's candidate cap. The job summary lists the packages. |
Expand Down
22 changes: 19 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ branding:

inputs:
api-key:
description: Radar API key (store it as a secret).
required: true
description: Radar API key (store it as a secret). On fork and Dependabot pull requests, which get no secrets, an empty key skips the scan with a warning; anywhere else it is an error.
required: false
default: ''
file:
description: SBOM or lockfile to scan, e.g. package-lock.json, yarn.lock, poetry.lock, go.sum, bom.cdx.json.
required: true
Expand Down Expand Up @@ -39,6 +40,9 @@ outputs:
sarif-file:
description: Path of the SARIF report, when upload-sarif is true.
value: ${{ steps.scan.outputs.sarif-file }}
skipped:
description: '"true" when the scan was skipped for want of an API key.'
value: ${{ steps.scan.outputs.skipped }}

runs:
using: composite
Expand All @@ -51,8 +55,20 @@ runs:
RADAR_FAIL_ON: ${{ inputs.fail-on }}
RADAR_UPLOAD: ${{ inputs.upload-sarif }}
RADAR_URL: ${{ inputs.api-url }}
RADAR_NO_SECRETS: ${{ github.event_name == 'pull_request' && (github.event.pull_request.head.repo.fork || github.actor == 'dependabot[bot]') }}
run: |
set -euo pipefail
if [ -z "$RADAR_API_KEY" ]; then
# Fail closed: a missing secret anywhere else must not pass the gate.
[ "$RADAR_NO_SECRETS" = true ] || { echo "::error::api-key is empty. Set the RADAR_API_KEY secret."; exit 1; }
echo "::warning::No Radar API key (secrets are not passed to fork or Dependabot pull requests); skipping the scan."
echo "skipped=true" >> "$GITHUB_OUTPUT"
exit 0
fi
case "$RADAR_FAIL_ON" in
''|critical|high|medium|low|kev|exploited) ;;
*) echo "::error::fail-on must be critical, high, medium, low, kev, exploited or empty, not '$RADAR_FAIL_ON'"; exit 1 ;;
esac
[ -f "$RADAR_FILE" ] || { echo "::error::File not found: $RADAR_FILE"; exit 1; }
body="$RUNNER_TEMP/radar-body.json"
out="$RUNNER_TEMP/radar-scan.json"
Expand Down Expand Up @@ -80,7 +96,7 @@ runs:
echo "sarif-file=$RUNNER_TEMP/radar.sarif" >> "$GITHUB_OUTPUT"
fi

- if: inputs.upload-sarif == 'true'
- if: steps.scan.outputs.sarif-file != ''
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: ${{ steps.scan.outputs.sarif-file }}
Expand Down
Loading