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
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,46 @@ jobs:
upload-sarif: ${{ github.event_name != 'pull_request' }}
- if: steps.key.outputs.present == 'true'
run: test "${{ steps.radar.outputs.gate-tripped }}" = false

# Runs the action against a local stub that replays a fixture response.
fixture:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- run: |
python3 - <<'PY' &
from http.server import BaseHTTPRequestHandler, HTTPServer
body = open("test/scan-incomplete.json", "rb").read()
class H(BaseHTTPRequestHandler):
def do_POST(self):
self.rfile.read(int(self.headers["Content-Length"]))
self.send_response(200)
self.send_header("Content-Type", "application/json")
self.end_headers()
self.wfile.write(body)
HTTPServer(("127.0.0.1", 8080), H).serve_forever()
PY
until curl -s -o /dev/null http://127.0.0.1:8080; do sleep 0.2; done
- id: radar
continue-on-error: true
uses: ./
with:
api-key: test
file: test/package-lock.json
fail-on: high
upload-sarif: false
api-url: http://127.0.0.1:8080
- id: tolerant
uses: ./
with:
api-key: test
file: test/package-lock.json
fail-on: high
fail-on-incomplete: false
upload-sarif: false
api-url: http://127.0.0.1:8080
- run: |
test "${{ steps.radar.outcome }}" = failure
test "${{ steps.radar.outputs.gate-tripped }}" = false
test "${{ steps.radar.outputs.gate-incomplete }}" = true
test "${{ steps.tolerant.outputs.gate-incomplete }}" = true
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Get an API key in [Console → Settings](https://radar.offseq.com/console) and s
| `api-key` | – | Radar API key. Required. |
| `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. |
| `upload-sarif` | `true` | Upload SARIF to code scanning. Needs `security-events: write`. |
| `api-url` | `https://radar.offseq.com` | Radar base URL. |

Expand All @@ -49,6 +50,7 @@ Get an API key in [Console → Settings](https://radar.offseq.com/console) and s
| Output | |
|---|---|
| `gate-tripped` | `true` when `fail-on` matched. |
| `gate-incomplete` | `true` when the gate could not evaluate every package. |
| `sarif-file` | Path of the SARIF report. |

## Supported files
Expand Down
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ inputs:
description: Fail the job on a confirmed finding at this level - critical, high, medium, low, kev or exploited. Empty never fails.
required: false
default: ''
fail-on-incomplete:
description: Fail the job when the gate could not evaluate every package, so an incomplete scan never passes.
required: false
default: 'true'
upload-sarif:
description: Upload the SARIF report to GitHub code scanning (needs security-events write permission).
required: false
Expand All @@ -29,6 +33,9 @@ outputs:
gate-tripped:
description: '"true" when fail-on matched a confirmed finding.'
value: ${{ steps.scan.outputs.gate-tripped }}
gate-incomplete:
description: '"true" when the gate could not evaluate every package.'
value: ${{ steps.scan.outputs.gate-incomplete }}
sarif-file:
description: Path of the SARIF report, when upload-sarif is true.
value: ${{ steps.scan.outputs.sarif-file }}
Expand Down Expand Up @@ -63,7 +70,10 @@ runs:
fi

jq -r '.markdown' "$out" >> "$GITHUB_STEP_SUMMARY"
jq -r '(.data.truncated // []) as $t | select($t | length > 0) |
"\n**Incomplete:** \($t | length) package(s) not fully evaluated: \($t | map("`\(.purl)` (\(.reason))") | join(", "))."' "$out" >> "$GITHUB_STEP_SUMMARY"
echo "gate-tripped=$(jq -r '.data.gate.tripped == true' "$out")" >> "$GITHUB_OUTPUT"
echo "gate-incomplete=$(jq -r '.data.gate.incomplete == true' "$out")" >> "$GITHUB_OUTPUT"

if [ "$RADAR_UPLOAD" = true ]; then
jq '.sarif' "$out" > "$RUNNER_TEMP/radar.sarif"
Expand All @@ -83,3 +93,9 @@ runs:
run: |
echo "::error::OffSeq Radar found a confirmed $RADAR_FAIL_ON finding. See the job summary."
exit 1

- if: steps.scan.outputs.gate-incomplete == 'true' && inputs.fail-on-incomplete == 'true'
shell: bash
run: |
echo "::error::OffSeq Radar could not evaluate every package, so the gate is incomplete. See the job summary."
exit 1
9 changes: 9 additions & 0 deletions test/scan-incomplete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"markdown": "## OffSeq Radar\n\nNo confirmed findings.\n",
"sarif": { "version": "2.1.0", "runs": [] },
"summary": { "truncated": 1 },
"data": {
"gate": { "tripped": false, "incomplete": true },
"truncated": [{ "purl": "pkg:npm/lodash@4.17.21", "reason": "candidate-cap" }]
}
}
Loading