diff --git a/.github/dependency-vulnerability-policy.md b/.github/dependency-vulnerability-policy.md index 7063a1c5..c2b12149 100644 --- a/.github/dependency-vulnerability-policy.md +++ b/.github/dependency-vulnerability-policy.md @@ -26,9 +26,14 @@ GitHub dependency review와 dependency submission은 GitHub.com API에만 있어 - 기본 이미지는 고칠 수 있는 최신 digest로 둔다(`Dockerfile`, 지금 `eclipse-temurin:21-jre-noble`). OS 패키지의 High/Critical도 아래 표대로 막는다. 고친 버전이 있으면 새 digest로 고친다. - 아직 고친 버전이 없는 High/Critical만 `.trivyignore.yaml`에 이유와 `expired_at`을 달아 둔다. -- 라이선스: 앱 의존성(`--pkg-types library`)의 금지 라이선스(Trivy CRITICAL)만 막는다. 그 밖의 라이선스 - 결과는 OS 패키지 것까지 보고만 한다. 배포판의 GPL 패키지는 이 애플리케이션의 이용 조건이 아니다. -- pull request의 `filesystem` 검사는 그대로다(앱 의존성의 High/Critical 라이선스도 막는다). +- 라이선스: 배포하는 의존성의 금지 라이선스(Trivy CRITICAL)만 막는다. 배포하는 것은 기본 조립의 jar이므로 + `src/bootstrap/app/gradle.lockfile`의 `runtimeClasspath` 항목을 본다. 그 밖의 라이선스 결과(OS 패키지, + 빌드 도구 SpotBugs·Checkstyle·Error Prone, 시험 라이브러리, restricted 등급)는 보고만 한다. 배포판의 GPL + 패키지는 이 애플리케이션의 이용 조건이 아니다. +- 이 라이선스 판정은 pull request의 `done` job이 빌드한 뒤에 돈다. Trivy는 같은 기계의 Gradle 캐시에서만 + lockfile의 라이선스를 읽고, 이미지 안 jar의 라이선스는 읽지 못한다. 예전의 따로 된 검사 job에는 캐시가 + 없어 라이선스 검사가 라이선스를 한 번도 보지 못했다(2026-11-12 확인). 캐시가 없으면 건너뛴다고 적고, + 캐시가 있는데 라이선스를 하나도 읽지 못하면 실패한다. ## 심각도와 대응 diff --git a/scripts/ci/trivy-scan.sh b/scripts/ci/trivy-scan.sh index e1f74bba..b98b0bf9 100755 --- a/scripts/ci/trivy-scan.sh +++ b/scripts/ci/trivy-scan.sh @@ -3,11 +3,13 @@ # (`filesystem`) and release.yml (`image `); not by Gradle and not on the desktop, because # it downloads and installs its tools (docs/work/operate.md 4.1). # -# bash scripts/ci/trivy-scan.sh filesystem dependency tree: block High/Critical, report -# Medium/Low, fail on any CISA KEV match +# bash scripts/ci/trivy-scan.sh filesystem dependency tree: block High/Critical +# vulnerabilities and a forbidden license on a +# shipped dependency (after a build), report the +# rest, fail on any CISA KEV match # bash scripts/ci/trivy-scan.sh image release image: write image-sbom.cdx.json, -# block High/Critical vulnerabilities and -# forbidden application licenses, report the rest +# block High/Critical vulnerabilities, report +# the rest and the licenses # # Tools are pinned release binaries with an asserted SHA-256, installed under RUNNER_TEMP (or a # temporary directory): a checksum is a supply-chain claim that can be checked offline, an action @@ -48,9 +50,36 @@ chmod 0755 "${tools}/trivy" "${tools}/jq" export PATH="${tools}:${PATH}" [ "$(jq --version)" = "jq-${JQ_VERSION}" ] || { echo "trivy-scan: unexpected $(jq --version)" >&2; exit 1; } +# A forbidden license on a dependency that ships fails (owner decision 2026-11-11). What ships is +# the default composition's jar, so the gate reads the bootstrap leaf's runtimeClasspath lockfile +# entries. Trivy finds a lockfile's licenses only in the Gradle cache of the same machine; the +# release image scan cannot read a jar's license at all (its Licenses column is empty for every +# jar), and the old separate scan job had no cache, so until the pull-request stage became one job +# that builds first no license gate here had ever seen a license. With no cache this says so and +# skips; with a cache and not one license read, the check would be empty, so it fails. +scan_shipped_licenses() { + local cache="${GRADLE_USER_HOME:-${HOME}/.gradle}/caches/modules-2" + if [ ! -d "${cache}" ]; then + echo "trivy-scan: no Gradle cache at ${cache}; the shipped-license gate runs after a build (pr.yml)" + return 0 + fi + local shipped="${tools}/shipped" + mkdir -p "${shipped}" + grep -E '=([^=]*,)?runtimeClasspath(,|$)' src/bootstrap/app/gradle.lockfile > "${shipped}/gradle.lockfile" \ + || { echo "trivy-scan: src/bootstrap/app/gradle.lockfile has no runtimeClasspath entry" >&2; exit 1; } + trivy fs --scanners license --format json --output "${tools}/shipped-licenses.json" "${shipped}" + jq -e '[.Results[]?.Licenses[]?] | length > 0' "${tools}/shipped-licenses.json" > /dev/null \ + || { echo "trivy-scan: Trivy read no license for the shipped dependencies; the gate would be empty" >&2; exit 1; } + trivy fs --scanners license --severity CRITICAL --exit-code 1 --ignorefile .trivyignore.yaml "${shipped}" +} + scan_filesystem() { - trivy fs --scanners vuln,license --severity CRITICAL,HIGH --exit-code 1 --ignorefile .trivyignore.yaml . - trivy fs --scanners vuln,license --severity MEDIUM,LOW --exit-code 0 --ignorefile .trivyignore.yaml . + trivy fs --scanners vuln --severity CRITICAL,HIGH --exit-code 1 --ignorefile .trivyignore.yaml . + trivy fs --scanners vuln --severity MEDIUM,LOW --exit-code 0 --ignorefile .trivyignore.yaml . + scan_shipped_licenses + # Every other license finding is reported only: the lockfiles also list build tools (SpotBugs, + # Checkstyle, Error Prone) and test libraries that never ship. + trivy fs --scanners license --exit-code 0 --ignorefile .trivyignore.yaml . trivy fs --scanners vuln --severity CRITICAL,HIGH,MEDIUM,LOW,UNKNOWN --exit-code 0 \ --ignorefile .trivyignore.yaml --format json --output "${tools}/trivy-kev.json" . @@ -103,13 +132,10 @@ scan_image() { # carried in .trivyignore.yaml with its expiry (owner decision 2026-11-11). trivy image --scanners vuln --severity CRITICAL,HIGH --exit-code 1 --ignorefile .trivyignore.yaml "$1" trivy image --scanners vuln --severity MEDIUM,LOW --exit-code 0 --ignorefile .trivyignore.yaml "$1" - # Licenses (same decision): an application dependency under a forbidden license (Trivy's - # CRITICAL) fails the release. Every other license finding, the OS packages' included, is - # reported and does not block: a distribution's GPL packages are not this application's terms. - trivy image --scanners license --pkg-types library --severity CRITICAL --exit-code 1 \ - --ignorefile .trivyignore.yaml "$1" - trivy image --scanners license --severity HIGH,MEDIUM,LOW,UNKNOWN --exit-code 0 \ - --ignorefile .trivyignore.yaml "$1" + # Licenses are reported only (same decision): the OS packages' are the distribution's terms, not + # this application's, and Trivy reads no license from a jar in an image. The shipped jars' gate is + # the filesystem scan's (scan_shipped_licenses), which pull requests run after building. + trivy image --scanners license --exit-code 0 --ignorefile .trivyignore.yaml "$1" } case "${1:-}" in