workflow 15개(+ composite action, jq 설치 스크립트)가 모듈 모양으로 나뉘어 있었고, 그것을 읽는 판독기(ShellScript·WorkflowGradleInvocations· TaskSelectors, 운영 3,283줄과 그 시험 1,814줄)가 리뷰 라운드마다 새 셸 모양으로 결함을 냈다. 그런데 Gitea에서는 Actions가 꺼져 있어 workflow는 한 번도 돌지 않았다(design-docs repo-structure/03-ci.md 2.1·3.4절). 소유자가 정한 B안(같은 문서 7절, 11절 ①~⑧)대로 바꾼다. - .gitea/workflows/pr.yml: `gradle` job이 `./gradlew :prCheck`와 `./gradlew :verifyStrictLaneStages --dry-run` 두 줄, `vulnerabilities` (trivy), 필수 검사 하나 `done`. - main.yml: push마다 mainCheck·integrationCheck·build-logic 시험· configuration cache·lychee·trivy·http3(권고). nightly·수동 실행에서 PostgreSQL major·HTTP transport·Redis topology 행렬, NFS, 알림 chaos, jpa-next, compose smoke, 마지막에 `needs`로 performanceCheck. - release.yml: releaseCheck와 기존 release lane, 이미지를 이 Gitea 레지스트리에 올리고 cosign 키 쌍으로 서명한다. 수동 실행은 push·서명 앞까지 돈다. upload/download-artifact를 쓰지 않는다. JPA 승격은 `needs: jpa-release-gate`가 대신한다. - 새 집계 `prCheck` = ci + verifyDependencyLocks + compose 렌더링 + 저장소 배치 + 문서 검사(Exec). workflow와 verify.sh가 같은 한 줄을 쓴다. - verifyStrictLaneStages: 그래프 검사(모든 strict lane이 선언한 단계의 계획에 있다)는 그대로 두고, workflow 쪽은 고정 문자열 형식 검사로 바꾼다. 단계마다 workflow·이벤트·필터·job·옵션·조건을 build.gradle에 선언하고, 그 job의 step이 `run: ./gradlew <단계> <옵션>`을 가지며 다른 run도 셸 문법 없는 ./gradlew 한 줄이고, 선언 밖의 if:, 조건 없는 needs:, continue-on-error·shell:·defaults:, 따옴표 키·flow 형식, 다른 working-directory, 선언 밖의 이벤트 필터가 없는지 본다. PR 단계 job 하나는 이 검사 자신을 돌려야 한다. 셸 해석 코드와 그 시험을 지운다 (build-logic 운영 코드 −3,167줄, 시험 −2,231줄). 우회 입력 21가지를 TestKit 시험으로 둔다. - scripts/verify.sh <단계>: 사람·세션의 진입점. 무거운 단계는 지금 작업 트리를 패치로 desktop에 보내 잠금 아래에서 돌린다(operate.md 4.1절의 손 절차). scripts/ci/는 workflow가 부르는 trivy·Redis topology·포트 포워더·configuration cache 스크립트다. - workflow를 읽는 시험(DeveloperExperienceContractTest, JpaRelease RenderingTest, FileserverDocumentationCoverageTest)과 입력 선언을 .gitea로 옮기고, keyless 서명 시험을 키 쌍 서명 시험으로 바꾼다. - 문서: gates.md·operate.md·docs/ci-cd·AGENTS.md(검증 절)·build-logic AGENTS.md(셸 규칙 문단을 세 줄로)·leaf 문서의 workflow 참조, docs/upgrade B-57~B-61. 버린 것: workflow 하나에 if:로 단계를 나누기(파일만 보고 단계를 알 수 없다), 레지스트리에서 생성(같은 정보의 셋째 사본), 바뀐 모듈만 돌리기 (결정 30과 충돌). 판독기를 남기고 고치기는 6라운드 13건이 반증했다. 위험: PR이 어댑터 컨테이너 lane과 Redis standalone lane을 더는 막지 않는다(main·nightly에서 빨갛게 된다. 소유자 결정 ②). main push는 ci를 다시 돌리지 않는다. 성능 lane은 매 push가 아니라 nightly에서만 돈다. `.github/workflows/messaging-certification.yml`은 메시징 분리 작업이 지우므로 남겼다(.gitea가 있으면 Gitea가 읽지 않는다). 서명·push는 secret이 없어 실제 태그로는 돌려 보지 않았다. BREAKING CHANGE: workflow 파일 위치와 이름, strictLaneStages 문법, 릴리스 레지스트리·서명 방식이 바뀌었다. docs/upgrade/2026-11-maturity- review.md B-57~B-61을 따른다.
109 lines
6.0 KiB
Bash
Executable File
109 lines
6.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Vulnerability gate, shared by the stage workflows. Called by .gitea/workflows/pr.yml and main.yml
|
|
# (`filesystem`) and release.yml (`image <reference>`); 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 image <reference> release image: write image-sbom.cdx.json,
|
|
# block High/Critical, report Medium/Low
|
|
#
|
|
# 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
|
|
# pinned to a commit is not. .trivyignore.yaml is the one suppression source; each entry carries a
|
|
# reason and an expiry by policy (.github/dependency-vulnerability-policy.md).
|
|
# Optional mirrors: TRIVY_DOWNLOAD_BASE_URL, JQ_DOWNLOAD_BASE_URL, KEV_FEED_URL.
|
|
set -euo pipefail
|
|
|
|
readonly TRIVY_VERSION='0.71.2'
|
|
readonly TRIVY_SHA256_AMD64='0510e71e2fd39bf863856d499c8dc19feb4e7336546394c502a8f5cc7ab27460'
|
|
readonly TRIVY_SHA256_ARM64='fe1c7106e15a5365d485b098a8c338f91e3b7ba71cb0e4963b98a3a098763cfc'
|
|
readonly JQ_VERSION='1.8.1'
|
|
readonly JQ_SHA256_AMD64='020468de7539ce70ef1bceaf7cde2e8c4f2ca6c3afb84642aabc5c97d9fc2a0d'
|
|
readonly JQ_SHA256_ARM64='6bc62f25981328edd3cfcfe6fe51b073f2d7e7710d7ef7fcdac28d4e384fc3d4'
|
|
readonly DEFAULT_KEV_FEED_URL='https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json'
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
|
|
tools="$(mktemp -d "${RUNNER_TEMP:-/tmp}/trivy-scan.XXXXXX")"
|
|
trap 'rm -rf "${tools}"' EXIT
|
|
|
|
download() { # url, sha256, destination
|
|
curl --fail --show-error --silent --location --retry 3 --proto '=https' --tlsv1.2 "$1" --output "$3"
|
|
printf '%s %s\n' "$2" "$3" | sha256sum -c -
|
|
}
|
|
|
|
case "$(uname -m)" in
|
|
x86_64 | amd64) trivy_arch='64bit'; trivy_sha="${TRIVY_SHA256_AMD64}"; jq_asset='jq-linux-amd64'; jq_sha="${JQ_SHA256_AMD64}" ;;
|
|
aarch64 | arm64) trivy_arch='ARM64'; trivy_sha="${TRIVY_SHA256_ARM64}"; jq_asset='jq-linux-arm64'; jq_sha="${JQ_SHA256_ARM64}" ;;
|
|
*) echo "trivy-scan: unsupported architecture $(uname -m)" >&2; exit 1 ;;
|
|
esac
|
|
|
|
download "${TRIVY_DOWNLOAD_BASE_URL:-https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}}/trivy_${TRIVY_VERSION}_Linux-${trivy_arch}.tar.gz" \
|
|
"${trivy_sha}" "${tools}/trivy.tar.gz"
|
|
tar -xzf "${tools}/trivy.tar.gz" -C "${tools}" trivy
|
|
download "${JQ_DOWNLOAD_BASE_URL:-https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}}/${jq_asset}" \
|
|
"${jq_sha}" "${tools}/jq"
|
|
chmod 0755 "${tools}/trivy" "${tools}/jq"
|
|
export PATH="${tools}:${PATH}"
|
|
[ "$(jq --version)" = "jq-${JQ_VERSION}" ] || { echo "trivy-scan: unexpected $(jq --version)" >&2; exit 1; }
|
|
|
|
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,MEDIUM,LOW,UNKNOWN --exit-code 0 \
|
|
--ignorefile .trivyignore.yaml --format json --output "${tools}/trivy-kev.json" .
|
|
|
|
# A KEV-listed vulnerability fails regardless of its CVSS score. The feed and the scan are both
|
|
# checked for shape first: an empty or malformed input would otherwise intersect to nothing and
|
|
# print "no catalog match" for a check that never ran.
|
|
if ! curl --fail --show-error --silent --location --retry 3 --proto '=https' --tlsv1.2 \
|
|
"${KEV_FEED_URL:-${DEFAULT_KEV_FEED_URL}}" --output "${tools}/kev.json"; then
|
|
echo "trivy-scan: KEV feed unavailable; set KEV_FEED_URL to an approved mirror" >&2
|
|
exit 1
|
|
fi
|
|
jq -e '
|
|
(.catalogVersion | type == "string" and test("\\S"))
|
|
and (.dateReleased | type == "string" and test("\\S"))
|
|
and (.count | type == "number")
|
|
and (.count > 0)
|
|
and (.count == (.count | floor))
|
|
and (.vulnerabilities | type == "array")
|
|
and ((.vulnerabilities | length) > 0)
|
|
and (.count == (.vulnerabilities | length))
|
|
and (all(.vulnerabilities[]; (.cveID | type == "string" and test("^CVE-[0-9]{4}-[0-9]{4,}$"))))
|
|
and (([.vulnerabilities[].cveID] | unique | length) == .count)
|
|
' "${tools}/kev.json" > /dev/null || { echo "trivy-scan: the KEV feed is malformed" >&2; exit 1; }
|
|
jq -e '
|
|
(type == "object")
|
|
and (.Results | type == "array")
|
|
and ((.Results | length) > 0)
|
|
and (all(.Results[]; type == "object"))
|
|
and (all(.Results[]; (.Vulnerabilities == null) or (.Vulnerabilities | type == "array")))
|
|
and (all(.Results[]; all(.Vulnerabilities[]?;
|
|
(type == "object") and (.VulnerabilityID | type == "string" and test("\\S")))))
|
|
' "${tools}/trivy-kev.json" > /dev/null || { echo "trivy-scan: the Trivy KEV input is malformed" >&2; exit 1; }
|
|
jq -r '[.Results[]?.Vulnerabilities[]?.VulnerabilityID] | unique[]' "${tools}/trivy-kev.json" | sort -u > "${tools}/found.txt"
|
|
jq -r '.vulnerabilities[].cveID' "${tools}/kev.json" | sort -u > "${tools}/kev.txt"
|
|
hits="$(comm -12 "${tools}/found.txt" "${tools}/kev.txt")"
|
|
if [ -n "${hits}" ]; then
|
|
printf 'trivy-scan: CISA KEV-listed vulnerability found regardless of CVSS:\n%s\n' "${hits}" >&2
|
|
exit 1
|
|
fi
|
|
echo "trivy-scan: no KEV catalog match."
|
|
}
|
|
|
|
# The image scan sees the base image's OS packages, which the filesystem scan cannot. The SBOM is
|
|
# written before the blocking scan, so the inventory survives the run that refuses to publish.
|
|
scan_image() {
|
|
trivy image --format cyclonedx --scanners license --output image-sbom.cdx.json "$1"
|
|
test -s image-sbom.cdx.json
|
|
trivy image --scanners vuln,license --severity CRITICAL,HIGH --exit-code 1 --ignorefile .trivyignore.yaml "$1"
|
|
trivy image --scanners vuln,license --severity MEDIUM,LOW --exit-code 0 --ignorefile .trivyignore.yaml "$1"
|
|
}
|
|
|
|
case "${1:-}" in
|
|
filesystem) scan_filesystem ;;
|
|
image) scan_image "${2:?image reference}" ;;
|
|
*) sed -n '2,13p' "$0" >&2; exit 2 ;;
|
|
esac
|