Files
grpc-library/scripts/release/vulnerability-scan.sh
T
DongHyeonka 239547bc2c fix(release): 리허설·릴리스 태스크가 프로젝트 좌표를 읽게 한다
releaseRehearsal과 release가 태스크 설정 블록 안에서 `path`·`group`·
`version`을 읽었다. 그 자리에서 셋은 프로젝트가 아니라 태스크의 속성이라
루트 publish 태스크 경로를 `:releaseRehearsal:publish…`로 만들고, 좌표를
`release:<모듈>:0.0.0`으로 찾았다. 좌표를 루트에서 한 번 잡아 쓴다.

같이 고친 것:
- grpc-core-api의 test fixtures 변형을 publication에서 뺀다. 이 repo
  시험끼리 쓰는 지원 코드이고(배포하는 testkit은 grpc-testkit), Maven이
  표현하지 못하는 capability라 POM 경고를 냈다.
- Trivy 호출에 --skip-version-check. 새 버전 알림이 매번 네트워크를
  부르고 로그를 덮었다.

검증(desktop): releaseRehearsal rc=0. 9개 모듈 + SBOM(733 components)이
staging에 올라가고 파일·체크섬 넷·POM/module 의존성 버전 확인 통과.
의존성 검사는 HIGH·CRITICAL 0, KEV 일치 0. 버리는 시험 키로 서명한
리허설도 rc=0, gpg --verify Good signature(키는 임시 폴더째 지웠다).
2026-11-08 11:20:11 +09:00

48 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# The release's dependency gate over the committed lockfiles, the backend template's policy:
# 1. HIGH and CRITICAL fail.
# 2. MEDIUM and LOW are reported and do not fail.
# 3. Any finding listed in the CISA Known Exploited Vulnerabilities catalog fails, whatever its
# severity. An unreachable or malformed catalog fails too: a cross-check that did not run must
# not read as "no match".
# Suppressions: .trivyignore.yaml only (each entry with a statement and an expiry).
#
# scripts/release/vulnerability-scan.sh <report directory>
set -euo pipefail
root=$(git rev-parse --show-toplevel)
out=${1:?usage: vulnerability-scan.sh <report directory>}
mkdir -p "$out"
trivy=$("$root/scripts/tool.sh" trivy)
cd "$root"
"$trivy" fs --skip-version-check --scanners vuln --severity CRITICAL,HIGH --exit-code 1 --ignorefile .trivyignore.yaml .
"$trivy" fs --skip-version-check --scanners vuln --severity MEDIUM,LOW --exit-code 0 --ignorefile .trivyignore.yaml .
"$trivy" fs --skip-version-check --scanners vuln --severity CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN --exit-code 0 \
--ignorefile .trivyignore.yaml --format json --output "$out/trivy-all.json" .
kev_url=${KEV_FEED_URL:-https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json}
if ! curl --fail --show-error --silent --location --retry 3 --proto '=https' --tlsv1.2 \
"$kev_url" --output "$out/kev.json"; then
echo "vulnerability-scan: KEV feed unavailable ($kev_url); set KEV_FEED_URL to an approved mirror." >&2
exit 1
fi
python3 - "$out/trivy-all.json" "$out/kev.json" <<'PY'
import json, re, sys
findings, kev = (json.load(open(p, encoding="utf-8")) for p in sys.argv[1:3])
ids = kev.get("vulnerabilities")
if not isinstance(ids, list) or not ids or kev.get("count") != len(ids):
sys.exit("vulnerability-scan: KEV feed is malformed, empty or count-inconsistent")
catalog = {v.get("cveID") for v in ids}
if not all(isinstance(c, str) and re.fullmatch(r"CVE-\d{4}-\d{4,}", c) for c in catalog):
sys.exit("vulnerability-scan: KEV feed holds an invalid cveID")
results = findings.get("Results")
if not isinstance(results, list) or not results:
sys.exit("vulnerability-scan: Trivy found no lockfile to scan")
found = {v["VulnerabilityID"] for r in results for v in (r.get("Vulnerabilities") or [])}
hits = sorted(found & catalog)
if hits:
sys.exit("vulnerability-scan: CISA KEV-listed vulnerability found regardless of severity: " + ", ".join(hits))
print(f"vulnerability-scan: {len(found)} finding(s) below HIGH, none in the KEV catalog ({len(catalog)} entries).")
PY