Download scripts/ci/gate.d/sbom.sh from abr00kx/taper: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/abr00kx/taper/resolve/main/scripts/ci/gate.d/sbom.sh
- Command line
-
hf download hf://abr00kx/taper/scripts/ci/gate.d/sbom.sh
-
curl -L -o sbom.sh https://huggingface.co/abr00kx/taper/resolve/main/scripts/ci/gate.d/sbom.sh
1.92 kB
| # Sourced by scripts/ci/gate.sh. SBOM freshness, dependency documentation | |
| # and vulnerability scanning. | |
| SBOM_VENV="$ROOT/env/sbom" | |
| ensure_sbom_venv() { | |
| local stamp="$SBOM_VENV/.requirements.sha256" want | |
| want=$(sha256sum scripts/sbom/requirements.lock | cut -d' ' -f1) | |
| if [[ ! -x $SBOM_VENV/bin/python || ! -f $stamp || $(cat "$stamp") != "$want" ]]; then | |
| [[ $OFFLINE == 1 ]] && { echo "SBOM venv missing or stale and TAPER_GATE_OFFLINE=1"; return 1; } | |
| rm -rf "$SBOM_VENV" | |
| python3 -m venv "$SBOM_VENV" \ | |
| && "$SBOM_VENV/bin/pip" install -q --require-hashes --no-deps -r scripts/sbom/requirements.lock \ | |
| && echo "$want" > "$stamp" | |
| fi | |
| } | |
| ensure_site_deps() { | |
| [[ -d node_modules ]] && return 0 | |
| [[ $OFFLINE == 1 ]] && { echo "node_modules missing and TAPER_GATE_OFFLINE=1"; return 1; } | |
| npm ci --no-audit --no-fund | |
| } | |
| sbom_check() { "$SBOM_VENV/bin/python" scripts/sbom/generate.py --check; } | |
| vuln_scan() { | |
| local f rc=0 | |
| for f in sbom/*.cdx.json; do | |
| echo "== $f" | |
| grype "sbom:$f" --fail-on high -q -o table || rc=1 | |
| done | |
| return $rc | |
| } | |
| sbom_inputs='^(server/package(-lock)?\.json|client/package(-lock)?\.json|package(-lock)?\.json|go\.(mod|sum)|scripts/(requirements|sbom/)|sbom/|static/fonts/|DEPENDENCIES\.md)' | |
| if [[ $MODE == full ]] || touches "$sbom_inputs"; then | |
| step "SBOM tooling environment" ensure_sbom_venv | |
| step "Site dependencies" ensure_site_deps | |
| step "Client dependencies (for its SBOM)" ensure_client_deps | |
| step "SBOMs current, valid CycloneDX 1.6, deps documented" sbom_check | |
| else | |
| skip "SBOM checks" "no dependency files staged" | |
| fi | |
| if [[ $MODE == full ]]; then | |
| if [[ $OFFLINE == 1 ]]; then skip "Vulnerability scan (grype)" "offline" | |
| elif ! command -v grype >/dev/null; then | |
| RESULTS+=("${R}FAIL${N} Vulnerability scan (grype) — grype not installed"); FAILED=1 | |
| else step "No High/Critical vulnerabilities (grype)" vuln_scan; fi | |
| fi | |