From aeb6033990e5263bcb96875ea94172123339e6db Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 12 Nov 2026 02:26:58 +0900 Subject: [PATCH] =?UTF-8?q?fix(ci):=20=EB=9D=BC=EC=9D=B4=EC=84=A0=EC=8A=A4?= =?UTF-8?q?=20=ED=8C=90=EC=A0=95=EC=9D=84=20=EB=B0=B0=ED=8F=AC=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EC=9D=98=EC=A1=B4=EC=84=B1=EC=97=90=20=EB=91=90?= =?UTF-8?q?=EA=B3=A0=20=EB=B9=8C=EB=93=9C=ED=95=9C=20=EB=92=A4=EC=97=90=20?= =?UTF-8?q?=EB=8F=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: PR 단계를 job 하나로 접자 Trivy filesystem 검사가 Gradle 빌드 뒤에 돌게 됐고, 처음으로 lockfile의 라이선스를 읽었다(run 95). Trivy는 같은 기계의 Gradle 캐시에서만 lockfile의 라이선스를 읽는데, 예전의 따로 된 검사 job에는 캐시가 없어 「High/Critical 라이선스는 막는다」는 검사가 라이선스를 한 번도 본 적이 없었다. 보이게 되자 lockfile마다 SpotBugs·Checkstyle(LGPL), Error Prone dataflow(GPL+CPE), Jakarta API(EPL/GPL 이중), org.reflections(WTFPL, Trivy 분류 forbidden) 등이 걸렸다. 대부분 배포하지 않는 빌드 도구·시험 구성이다. 한편 릴리스 이미지 검사는 jar의 라이선스를 읽지 못한다(run 62의 Licenses 칸이 모든 jar에서 비어 있다). 그래서 앞 커밋의 「앱 의존성 금지 라이선스는 이미지에서 막는다」도 빈 검사였다. 고른 방법(2026-11-11 소유자 결정 「배포하는 의존성의 금지 라이선스만 실패」): - filesystem 검사가 `src/bootstrap/app/gradle.lockfile`의 runtimeClasspath 항목 (기본 조립 jar에 실리는 것)만 골라 forbidden(CRITICAL)이면 실패한다. - Gradle 캐시가 없으면 건너뛴다고 적는다. 캐시가 있는데 라이선스를 하나도 읽지 못하면 빈 검사이므로 실패한다. - 나머지 라이선스 결과(OS, 도구, 시험, restricted)는 보고만 한다. 이미지 검사의 빈 라이선스 gate는 지우고 보고만 남긴다. 정책 문서를 실제 동작에 맞춘다. 버린 대안: lockfile 전체에 High/Critical을 그대로 막고 예외를 다는 것. Trivy의 라이선스 예외는 라이선스 이름 단위라 도구용 LGPL을 빼면 배포 의존성의 LGPL도 빠진다. 위험·한계: main.yml의 vulnerabilities job은 빌드하지 않아 라이선스 판정을 건너뛴다. 판정은 병합을 막는 PR 단계에 있다. runtimeClasspath 밖에서 jar에 실리는 것(다른 조립)이 생기면 grep 조건을 넓혀야 한다. 검증: runner PR `pr / done`(이 PR 본문에 적는다). --- .github/dependency-vulnerability-policy.md | 11 +++-- scripts/ci/trivy-scan.sh | 52 ++++++++++++++++------ 2 files changed, 47 insertions(+), 16 deletions(-) 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