fix(ci): resolve security findings and improve Trivy reporting
This commit is contained in:
1 parent
138666a7bb
commit
e9f56a6aa2
9 files changed
+110
-12
No files matched your search
+2
-2
@@ -247,12 +247,12 @@ require (
|
|||||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||||
github.com/moby/docker-image-spec v1.3.1 // indirect
|
github.com/moby/docker-image-spec v1.3.1 // indirect
|
||||||
github.com/moby/go-archive v0.2.0 // indirect
|
github.com/moby/go-archive v0.3.0 // indirect
|
||||||
github.com/moby/moby/api v1.55.0 // indirect
|
github.com/moby/moby/api v1.55.0 // indirect
|
||||||
github.com/moby/moby/client v0.5.1 // indirect
|
github.com/moby/moby/client v0.5.1 // indirect
|
||||||
github.com/moby/patternmatcher v0.6.1 // indirect
|
github.com/moby/patternmatcher v0.6.1 // indirect
|
||||||
github.com/moby/sys/sequential v0.7.0 // indirect
|
github.com/moby/sys/sequential v0.7.0 // indirect
|
||||||
github.com/moby/sys/user v0.4.0 // indirect
|
github.com/moby/sys/user v0.4.1 // indirect
|
||||||
github.com/moby/sys/userns v0.1.0 // indirect
|
github.com/moby/sys/userns v0.1.0 // indirect
|
||||||
github.com/moby/term v0.5.2 // indirect
|
github.com/moby/term v0.5.2 // indirect
|
||||||
github.com/moricho/tparallel v0.3.2 // indirect
|
github.com/moricho/tparallel v0.3.2 // indirect
|
||||||
|
|||||||
+4
-4
@@ -576,8 +576,8 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx
|
|||||||
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||||
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
|
||||||
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
|
||||||
github.com/moby/go-archive v0.2.0 h1:zg5QDUM2mi0JIM9fdQZWC7U8+2ZfixfTYoHL7rWUcP8=
|
github.com/moby/go-archive v0.3.0 h1:nos4BtzzUIqB406BgQnWGMI4qib9BZ8XUHU+ucv/n1c=
|
||||||
github.com/moby/go-archive v0.2.0/go.mod h1:mNeivT14o8xU+5q1YnNrkQVpK+dnNe/K6fHqnTg4qPU=
|
github.com/moby/go-archive v0.3.0/go.mod h1:Npdv43fFqlhZW7Xo8fbm3ZMYFvAGNviUPqX21VERbcE=
|
||||||
github.com/moby/moby/api v1.55.0 h1:2/sexvQyqIWS8pRSCFddBfpW2qE7vR7FCL+vN8pxwMc=
|
github.com/moby/moby/api v1.55.0 h1:2/sexvQyqIWS8pRSCFddBfpW2qE7vR7FCL+vN8pxwMc=
|
||||||
github.com/moby/moby/api v1.55.0/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs=
|
github.com/moby/moby/api v1.55.0/go.mod h1:+RQ6wluLwtYaTd1WnPLykIDPekkuyD/ROWQClE83pzs=
|
||||||
github.com/moby/moby/client v0.5.1 h1:tYNaJno4c0HXz12y5BiqEDy0rVTYkWzI26lGvnTMiJw=
|
github.com/moby/moby/client v0.5.1 h1:tYNaJno4c0HXz12y5BiqEDy0rVTYkWzI26lGvnTMiJw=
|
||||||
@@ -586,8 +586,8 @@ github.com/moby/patternmatcher v0.6.1 h1:qlhtafmr6kgMIJjKJMDmMWq7WLkKIo23hsrpR3x
|
|||||||
github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
|
github.com/moby/patternmatcher v0.6.1/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
|
||||||
github.com/moby/sys/sequential v0.7.0 h1:ASQNGNROJSuOO6LL6bPHbKvuZu6NU8P4ldPWk31zj/8=
|
github.com/moby/sys/sequential v0.7.0 h1:ASQNGNROJSuOO6LL6bPHbKvuZu6NU8P4ldPWk31zj/8=
|
||||||
github.com/moby/sys/sequential v0.7.0/go.mod h1:NfSTAp6V3fw4tmkD62PEcOKeZKquXT8VKCkf7aVR79o=
|
github.com/moby/sys/sequential v0.7.0/go.mod h1:NfSTAp6V3fw4tmkD62PEcOKeZKquXT8VKCkf7aVR79o=
|
||||||
github.com/moby/sys/user v0.4.0 h1:jhcMKit7SA80hivmFJcbB1vqmw//wU61Zdui2eQXuMs=
|
github.com/moby/sys/user v0.4.1 h1:RgjRlaDKi/Xmyrz4t8lyzXT6v2ooFeO/7xtchmhVWE0=
|
||||||
github.com/moby/sys/user v0.4.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs=
|
github.com/moby/sys/user v0.4.1/go.mod h1:E9QsW5WRe1kUAf7kW8hXKwu1uhsZEAdPLYHYSDudF4Y=
|
||||||
github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g=
|
github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g=
|
||||||
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
|
github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28=
|
||||||
github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ=
|
github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ=
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ down stops containers and keeps named volumes. Do not delete database or file vo
|
|||||||
|
|
||||||
ML uses a separate Compose file and project; it does not require or start Redis or SeaweedFS in the current scaffold. Its default host bind is 127.0.0.1:8000. Set ML_BIND_ADDRESS only after choosing a private address and preparing firewall rules. Prometheus does not scrape remote ML while ML_METRICS_TARGET is empty.
|
ML uses a separate Compose file and project; it does not require or start Redis or SeaweedFS in the current scaffold. Its default host bind is 127.0.0.1:8000. Set ML_BIND_ADDRESS only after choosing a private address and preparing firewall rules. Prometheus does not scrape remote ML while ML_METRICS_TARGET is empty.
|
||||||
|
|
||||||
|
The ML image uses `python:alpine` and upgrades system packages during the build. Dependencies are installed with uv only in the build stage; the final runtime contains the prepared virtual environment without pip or ensurepip. Current dependencies support musl. Check Alpine compatibility before adding inference or GPU libraries; glibc-dependent libraries will require a different validated runtime.
|
||||||
|
|
||||||
make -C deploy ml-config
|
make -C deploy ml-config
|
||||||
make -C deploy ml-up
|
make -C deploy ml-up
|
||||||
make -C deploy ml-logs
|
make -C deploy ml-logs
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ Image checks require Docker. The backend build context is `backend/`; frontend a
|
|||||||
|
|
||||||
Trivy findings of severity `HIGH` or `CRITICAL` fail the check, including findings without a published fix, unless an active, narrowly scoped exception applies. Gitleaks findings, configured Semgrep findings, govulncheck findings, and scanner errors also fail their targets. The existing Go lint configuration retains gosec; this complements the added checks.
|
Trivy findings of severity `HIGH` or `CRITICAL` fail the check, including findings without a published fix, unless an active, narrowly scoped exception applies. Gitleaks findings, configured Semgrep findings, govulncheck findings, and scanner errors also fail their targets. The existing Go lint configuration retains gosec; this complements the added checks.
|
||||||
|
|
||||||
Review the reported package, installed version, affected path, and available remediation before changing dependencies or configuration. Keep reports local: `security/reports/` is ignored. govulncheck uses text output so its native failure status is preserved.
|
Review the reported package, installed version, affected path, and available remediation before changing dependencies or configuration. Keep reports local: `security/reports/` is ignored. govulncheck uses text output so its native failure status is preserved. Trivy saves JSON reports and prints their tables in the check log. A scan error, missing report, or report conversion error keeps the check failing.
|
||||||
|
|
||||||
One temporary exception in [security/trivy/ignore.yml](../../security/trivy/ignore.yml) was approved by the project owner on 2026-10-05: `CVE-2026-93687` for `pkg:npm/braces@3.0.3` in `frontend/pnpm-lock.yaml`. At approval, no fixed release was available; the exception unblocks dependency CI until its expiry on 2026-10-19. Project maintainers own the exception and must remove it when a fix becomes available or review it before expiry. Trivy enforces the expiry date. Only filesystem scanning uses this exception file; suppressed findings remain visible in its JSON report. Image scanning is unaffected.
|
One temporary exception in [security/trivy/ignore.yml](../../security/trivy/ignore.yml) was approved by the project owner on 2026-10-05: `CVE-2026-93687` for `pkg:npm/braces@3.0.3` in `frontend/pnpm-lock.yaml`. At approval, no fixed release was available; the exception unblocks dependency CI until its expiry on 2026-10-19. Project maintainers own the exception and must remove it when a fix becomes available or review it before expiry. Trivy enforces the expiry date. Only filesystem scanning uses this exception file; suppressed findings remain visible in its JSON report. Image scanning is unaffected.
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ down останавливает контейнеры, сохраняя имен
|
|||||||
|
|
||||||
ML имеет отдельный Compose-файл и проект; Redis и SeaweedFS ему пока не требуются и здесь не запускаются. По умолчанию он слушает на 127.0.0.1:8000. Настройте ML_BIND_ADDRESS только если выбранный приватный адрес и firewall уже подготовлены. Метрики удаленного ML target не собираются, пока ML_METRICS_TARGET пуст.
|
ML имеет отдельный Compose-файл и проект; Redis и SeaweedFS ему пока не требуются и здесь не запускаются. По умолчанию он слушает на 127.0.0.1:8000. Настройте ML_BIND_ADDRESS только если выбранный приватный адрес и firewall уже подготовлены. Метрики удаленного ML target не собираются, пока ML_METRICS_TARGET пуст.
|
||||||
|
|
||||||
|
Образ ML использует `python:alpine` с обновлением системных пакетов при сборке. Зависимости устанавливаются через uv только на этапе сборки; итоговый runtime содержит готовое виртуальное окружение без pip и ensurepip. Текущие зависимости поддерживают musl. Перед добавлением библиотек inference или GPU проверьте их совместимость с Alpine; glibc-зависимым библиотекам потребуется другой проверенный runtime.
|
||||||
|
|
||||||
make -C deploy ml-config
|
make -C deploy ml-config
|
||||||
make -C deploy ml-up
|
make -C deploy ml-up
|
||||||
make -C deploy ml-logs
|
make -C deploy ml-logs
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ Gitleaks требует полный Git checkout. Отсутствие репо
|
|||||||
|
|
||||||
Находки Trivy с уровнем `HIGH` или `CRITICAL` завершают проверку ошибкой, включая уязвимости без опубликованного исправления, если для находки нет действующего адресного исключения. Находки Gitleaks, настроенных правил Semgrep, govulncheck и ошибки самих сканеров также завершают соответствующие цели ошибкой. В конфигурации Go-линтера остается gosec; новые проверки дополняют его.
|
Находки Trivy с уровнем `HIGH` или `CRITICAL` завершают проверку ошибкой, включая уязвимости без опубликованного исправления, если для находки нет действующего адресного исключения. Находки Gitleaks, настроенных правил Semgrep, govulncheck и ошибки самих сканеров также завершают соответствующие цели ошибкой. В конфигурации Go-линтера остается gosec; новые проверки дополняют его.
|
||||||
|
|
||||||
Перед изменением зависимостей или конфигурации проверьте указанный пакет, установленную версию, затронутый путь и доступное исправление. Отчеты хранятся локально: `security/reports/` исключен из Git. govulncheck использует текстовый вывод, чтобы сохранить собственный код завершения при находках.
|
Перед изменением зависимостей или конфигурации проверьте указанный пакет, установленную версию, затронутый путь и доступное исправление. Отчеты хранятся локально: `security/reports/` исключен из Git. govulncheck использует текстовый вывод, чтобы сохранить собственный код завершения при находках. Trivy сохраняет JSON-отчеты и печатает их таблицы в лог проверки. Ошибка сканирования, отсутствие отчета или ошибка его преобразования сохраняют блокирующий результат.
|
||||||
|
|
||||||
В [security/trivy/ignore.yml](../../security/trivy/ignore.yml) есть одно временное исключение, согласованное владельцем проекта 2026-10-05: `CVE-2026-93687` для `pkg:npm/braces@3.0.3` в `frontend/pnpm-lock.yaml`. На момент согласования исправленной версии не было; исключение разблокирует CI зависимостей до истечения срока 2026-10-19. Ответственные - сопровождающие проекта: исключение нужно удалить после появления исправления или пересмотреть до истечения срока. Trivy автоматически учитывает дату окончания. Файл исключений применяется только к проверке файлов; скрытые из блокирующего результата находки остаются видимыми в JSON-отчете. Проверка образов не изменяется.
|
В [security/trivy/ignore.yml](../../security/trivy/ignore.yml) есть одно временное исключение, согласованное владельцем проекта 2026-10-05: `CVE-2026-93687` для `pkg:npm/braces@3.0.3` в `frontend/pnpm-lock.yaml`. На момент согласования исправленной версии не было; исключение разблокирует CI зависимостей до истечения срока 2026-10-19. Ответственные - сопровождающие проекта: исключение нужно удалить после появления исправления или пересмотреть до истечения срока. Trivy автоматически учитывает дату окончания. Файл исключений применяется только к проверке файлов; скрытые из блокирующего результата находки остаются видимыми в JSON-отчете. Проверка образов не изменяется.
|
||||||
|
|
||||||
|
|||||||
+8
-3
@@ -1,4 +1,6 @@
|
|||||||
FROM python:slim AS base
|
FROM python:alpine AS base
|
||||||
|
|
||||||
|
RUN apk upgrade --no-cache
|
||||||
|
|
||||||
FROM base AS build
|
FROM base AS build
|
||||||
|
|
||||||
@@ -21,8 +23,11 @@ ENV PATH="/opt/venv/bin:${PATH}" \
|
|||||||
PYTHONUNBUFFERED=1
|
PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN groupadd --system --gid 10001 lincodex \
|
# Package installation belongs to the build stage, not the service runtime.
|
||||||
&& useradd --system --uid 10001 --gid lincodex --no-create-home lincodex
|
RUN python -m pip uninstall --yes pip \
|
||||||
|
&& python -c "import ensurepip, shutil; shutil.rmtree(ensurepip.__path__[0])" \
|
||||||
|
&& addgroup -S -g 10001 lincodex \
|
||||||
|
&& adduser -S -D -H -u 10001 -G lincodex lincodex
|
||||||
|
|
||||||
COPY --from=build --chown=lincodex:lincodex /opt/venv /opt/venv
|
COPY --from=build --chown=lincodex:lincodex /opt/venv /opt/venv
|
||||||
|
|
||||||
|
|||||||
+13
-1
@@ -49,6 +49,12 @@ filesystem: | $(REPORTS) $(CACHE) ## Scan dependency manifests and infrastructur
|
|||||||
@rm -f "$(REPORTS)/trivy-filesystem.json" "$(REPORTS)/trivy-version.txt"
|
@rm -f "$(REPORTS)/trivy-filesystem.json" "$(REPORTS)/trivy-version.txt"
|
||||||
@cd "$(ROOT)"; status=0; \
|
@cd "$(ROOT)"; status=0; \
|
||||||
$(TRIVY) fs --config security/trivy/filesystem.yml --cache-dir "$(CACHE)/trivy" --output "$(REPORTS)/trivy-filesystem.json" . || status=$$?; \
|
$(TRIVY) fs --config security/trivy/filesystem.yml --cache-dir "$(CACHE)/trivy" --output "$(REPORTS)/trivy-filesystem.json" . || status=$$?; \
|
||||||
|
if [ -f "$(REPORTS)/trivy-filesystem.json" ]; then \
|
||||||
|
$(TRIVY) convert --format table --scanners vuln,misconfig "$(REPORTS)/trivy-filesystem.json" || { if [ "$$status" -eq 0 ]; then status=1; fi; }; \
|
||||||
|
else \
|
||||||
|
echo 'Trivy did not create the filesystem report.' >&2; \
|
||||||
|
if [ "$$status" -eq 0 ]; then status=1; fi; \
|
||||||
|
fi; \
|
||||||
$(TRIVY) --cache-dir "$(CACHE)/trivy" --version > "$(REPORTS)/trivy-version.txt" || status=1; \
|
$(TRIVY) --cache-dir "$(CACHE)/trivy" --version > "$(REPORTS)/trivy-version.txt" || status=1; \
|
||||||
exit "$$status"
|
exit "$$status"
|
||||||
|
|
||||||
@@ -88,7 +94,13 @@ images: | $(REPORTS) $(CACHE) ## Build and scan the exact backend, frontend, and
|
|||||||
if $(DOCKER) build --pull -f "$(ROOT)/$$service/Dockerfile" -t "$$tag" "$$context"; then \
|
if $(DOCKER) build --pull -f "$(ROOT)/$$service/Dockerfile" -t "$$tag" "$$context"; then \
|
||||||
if image_id=$$($(DOCKER) image inspect --format '{{.Id}}' "$$tag"); then \
|
if image_id=$$($(DOCKER) image inspect --format '{{.Id}}' "$$tag"); then \
|
||||||
printf '%s\n' "$$image_id" > "$(REPORTS)/$$service-image-id.txt"; \
|
printf '%s\n' "$$image_id" > "$(REPORTS)/$$service-image-id.txt"; \
|
||||||
$(TRIVY) image --image-src docker --config trivy/image.yml --cache-dir "$(CACHE)/trivy" --output "$(REPORTS)/trivy-$$service.json" "$$image_id" || status=1; \
|
report="$(REPORTS)/trivy-$$service.json"; \
|
||||||
|
$(TRIVY) image --image-src docker --config trivy/image.yml --cache-dir "$(CACHE)/trivy" --output "$$report" "$$image_id" || status=1; \
|
||||||
|
if [ -f "$$report" ]; then \
|
||||||
|
$(TRIVY) convert --format table --scanners vuln,misconfig "$$report" || status=1; \
|
||||||
|
else \
|
||||||
|
printf 'Trivy did not create the %s image report.\n' "$$service" >&2; status=1; \
|
||||||
|
fi; \
|
||||||
else status=1; fi; \
|
else status=1; fi; \
|
||||||
else status=1; fi; \
|
else status=1; fi; \
|
||||||
done; \
|
done; \
|
||||||
|
|||||||
@@ -98,6 +98,83 @@ class SecurityChecksTest(unittest.TestCase):
|
|||||||
(reports / "govulncheck.txt").read_text(), "Synthetic scan result\n"
|
(reports / "govulncheck.txt").read_text(), "Synthetic scan result\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_trivy_reports_are_visible_without_masking_failures(self) -> None:
|
||||||
|
cases = [
|
||||||
|
("clean", 0, 0, True, True),
|
||||||
|
("findings", 1, 0, True, False),
|
||||||
|
("scan_error", 17, 0, False, False),
|
||||||
|
("conversion_error", 0, 7, True, False),
|
||||||
|
("both_errors", 17, 7, True, False),
|
||||||
|
("missing_report", 0, 0, False, False),
|
||||||
|
]
|
||||||
|
docker = self.folder / "docker"
|
||||||
|
docker.write_text(
|
||||||
|
"#!/usr/bin/env bash\n"
|
||||||
|
'if [ "$1" = build ]; then exit 0; fi\n'
|
||||||
|
'if [ "$1" = image ]; then echo sha256:fixture; exit 0; fi\n'
|
||||||
|
"exit 2\n"
|
||||||
|
)
|
||||||
|
docker.chmod(0o700)
|
||||||
|
for target in ("filesystem", "images"):
|
||||||
|
for name, scan_code, convert_code, write_report, success in cases:
|
||||||
|
with self.subTest(target=target, case=name):
|
||||||
|
reports = self.folder / f"{target}-{name}"
|
||||||
|
scanner = self.folder / "trivy"
|
||||||
|
scanner.write_text(
|
||||||
|
f"#!{sys.executable}\n"
|
||||||
|
"import json, sys\n"
|
||||||
|
"from pathlib import Path\n"
|
||||||
|
"args = sys.argv[1:]\n"
|
||||||
|
"if '--version' in args: sys.exit(0)\n"
|
||||||
|
"if args[0] == 'convert':\n"
|
||||||
|
" assert args[1:3] == ['--format', 'table']\n"
|
||||||
|
" assert args[3:5] == ['--scanners', 'vuln,misconfig']\n"
|
||||||
|
" report = json.loads(Path(args[-1]).read_text())\n"
|
||||||
|
f" if {convert_code}:\n"
|
||||||
|
" print('Report conversion failed', file=sys.stderr)\n"
|
||||||
|
f" sys.exit({convert_code})\n"
|
||||||
|
" print('Scan table:', report['result'])\n"
|
||||||
|
" sys.exit(0)\n"
|
||||||
|
"assert args[0] in ('fs', 'image')\n"
|
||||||
|
f"if {write_report}:\n"
|
||||||
|
" output = Path(args[args.index('--output') + 1])\n"
|
||||||
|
" output.write_text(json.dumps({'result': "
|
||||||
|
f"{'HIGH CVE-2099-0001' if scan_code else 'No findings'!r}}}))\n"
|
||||||
|
f"sys.exit({scan_code})\n"
|
||||||
|
)
|
||||||
|
scanner.chmod(0o700)
|
||||||
|
result = subprocess.run(
|
||||||
|
[
|
||||||
|
"make",
|
||||||
|
target,
|
||||||
|
f"TRIVY={scanner}",
|
||||||
|
f"DOCKER={docker}",
|
||||||
|
f"REPORTS={reports}",
|
||||||
|
],
|
||||||
|
cwd=SECURITY,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
check=False,
|
||||||
|
)
|
||||||
|
self.assertEqual(result.returncode == 0, success, result.stderr)
|
||||||
|
report_count = 1 if target == "filesystem" else 3
|
||||||
|
self.assertEqual(
|
||||||
|
len(list(reports.glob("trivy-*.json"))),
|
||||||
|
report_count if write_report else 0,
|
||||||
|
)
|
||||||
|
if write_report and not convert_code:
|
||||||
|
self.assertEqual(result.stdout.count("Scan table:"), report_count)
|
||||||
|
self.assertIn(
|
||||||
|
"HIGH CVE-2099-0001" if scan_code else "No findings",
|
||||||
|
result.stdout,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.assertNotIn("Scan table:", result.stdout)
|
||||||
|
if write_report and convert_code:
|
||||||
|
self.assertIn("Report conversion failed", result.stderr)
|
||||||
|
if scan_code and target == "filesystem":
|
||||||
|
self.assertIn(f"Error {scan_code}", result.stderr)
|
||||||
|
|
||||||
def test_failed_preflight_removes_previous_scan_reports(self) -> None:
|
def test_failed_preflight_removes_previous_scan_reports(self) -> None:
|
||||||
outputs = {
|
outputs = {
|
||||||
"filesystem": ["trivy-filesystem.json"],
|
"filesystem": ["trivy-filesystem.json"],
|
||||||
|
|||||||
Reference in new issue
Block a user