scan: report .vex/ files and print VEX re-checks; vex: action for the central VEX repo
dtrack-panel now applies OpenVEX / CycloneDX VEX files as well as osv-scanner.toml [[IgnoredVulns]], and sends a statement's findings back to IN_TRIAGE when its review date passes, the package version moves on, or the CVE turns KEV. scan sends .vex/**/*.json with the report and turns the panel's answer into job annotations (re-check due, review date within 14 days, skipped statements). vex/ posts a whole repo's VEX files to /panel-ci/vex for statements about third-party images.
This commit is contained in:
1 parent
f9e42005ba
commit
2b4b140200
3 files changed
+107
-12
No files matched your search
@@ -0,0 +1,66 @@
|
||||
name: 'VEX statements to dtrack-panel'
|
||||
description: >
|
||||
Post every OpenVEX / CycloneDX VEX file of a repo (the central VEX repo) to
|
||||
dtrack-panel, which applies them as NOT_AFFECTED decisions in
|
||||
Dependency-Track: to the images a statement names, or wherever the package
|
||||
appears. The repo's complete set each time — a removed file or statement
|
||||
withdraws its decisions.
|
||||
author: 'janhouse'
|
||||
|
||||
# Usage (janhouse/vex .gitea/workflows/vex.yml, on push to main + weekly):
|
||||
# - uses: actions/checkout@v4
|
||||
# - uses: https://git.janhouse.lv/janhouse/sbom-tools-action/[email protected]
|
||||
# with:
|
||||
# dtrack-url: ${{ secrets.DEPENDENCY_TRACK_URL }}
|
||||
# dtrack-api-key: ${{ secrets.DEPENDENCY_TRACK_API_KEY }}
|
||||
|
||||
inputs:
|
||||
dtrack-url:
|
||||
description: 'Dependency-Track base URL (the panel answers on <dtrack-url>/panel-ci/)'
|
||||
required: true
|
||||
dtrack-api-key:
|
||||
description: 'Dependency-Track API key that may upload BOMs (authenticates the report)'
|
||||
required: true
|
||||
panel-url:
|
||||
description: 'dtrack-panel VEX URL (default: <dtrack-url>/panel-ci/vex)'
|
||||
required: false
|
||||
default: ''
|
||||
path:
|
||||
description: 'Directory to collect *.json VEX files from'
|
||||
required: false
|
||||
default: 'vex'
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Post VEX statements
|
||||
shell: bash
|
||||
env:
|
||||
DTRACK_URL: ${{ inputs.dtrack-url }}
|
||||
DTRACK_API_KEY: ${{ inputs.dtrack-api-key }}
|
||||
PANEL_URL: ${{ inputs.panel-url }}
|
||||
VEX_PATH: ${{ inputs.path }}
|
||||
REPO: ${{ github.repository }}
|
||||
COMMIT: ${{ github.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
url=${PANEL_URL:-${DTRACK_URL%/}/panel-ci/vex}
|
||||
files='[]'
|
||||
while IFS= read -r f; do
|
||||
files=$(jq --arg p "$f" --rawfile c "$f" '. + [{path: $p, content: $c}]' <<<"$files")
|
||||
done < <(find "$VEX_PATH" -name '*.json' -not -path '*/.git/*' | sort | head -500)
|
||||
jq -n --arg repo "$REPO" --arg commit "$COMMIT" --argjson files "$files" \
|
||||
'{repo: $repo, commit: $commit, files: $files}' > vex-report.json
|
||||
echo "Posting $(jq '.files | length' vex-report.json) VEX file(s) to ${url}"
|
||||
# -f: a rejected file (bad JSON, no justification) fails the job.
|
||||
code=$(curl -sS -o response.json -w '%{http_code}' -X POST "$url" \
|
||||
-H "X-Api-Key: ${DTRACK_API_KEY}" -H "Content-Type: application/json" \
|
||||
--data-binary @vex-report.json)
|
||||
if [ "$code" != 200 ]; then
|
||||
echo "::error::dtrack-panel answered HTTP $code: $(jq -r '.message // .' response.json 2>/dev/null || cat response.json)"
|
||||
exit 1
|
||||
fi
|
||||
jq -r '.vex | "VEX statements: \(.statements) (\(.added) new, \(.changed) changed, \(.removed) removed)"' response.json
|
||||
jq -r '.vex.skipped[]? | "::notice file=\(.path)::\(.id) skipped: \(.why)"' response.json || true
|
||||
jq -r '.reviewDue[]? | "::warning::VEX re-check due — \(.vulnId) in \(.package) (\(.image)): \(.detail)"' response.json || true
|
||||
jq -r '.expiringSoon[]? | "::notice file=\(.path)::\(.vulnId): review date \(.reviewBy[0:10]) is within 14 days"' response.json || true
|
||||
Reference in new issue
Block a user