fix(ci): #314 review — reap ZAP container in the cleanup() trap; warn on missing semgrep
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 6s
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 7s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 15s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 16s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 4m34s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 5m40s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (push) Has been skipped
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (push) Has been skipped
Build ErsatzTV Image / Docs update reminder (push) Has been skipped
Build ErsatzTV Image / decisions.md append-only (push) Has been skipped
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (push) Successful in 4m34s
Build ErsatzTV Image / Build & test (.NET) (push) Successful in 5m39s
Build ErsatzTV Image / Build & push image (amd64) (push) Successful in 4m35s

Cold review of PR #331:
- Move the ZAP-container reap from an inline post-scan line into cleanup() (the
  EXIT trap) so a SIGINT/timeout kill mid-scan can't leave it running.
- semgrep absent now prints a stderr WARN instead of silently skipping the SAST
  pass (no false confidence for a release gate).

refs #314

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit was merged in pull request #331.
This commit is contained in:
2026-07-13 08:36:08 +02:00
co-authored by Claude Opus 4.8
parent 366d5d316c
commit a042623a53
+10 -3
View File
@@ -39,6 +39,9 @@ command -v docker >/dev/null || { echo "error: docker not found — run this on
CFG="$(mktemp -d /tmp/etv-secscan-cfg-XXXXXX)"
cleanup() {
# Reap the ZAP scanner container too — in the trap (not just inline after the scan) so an interrupt
# (SIGINT/SIGTERM) or a `timeout` kill mid-scan doesn't leave it running.
docker ps --filter ancestor="$ZAP_IMAGE" -q | xargs -r docker kill >/dev/null 2>&1 || true
docker rm -f "$TARGET_NAME" >/dev/null 2>&1 || true
rm -rf "$CFG" 2>/dev/null || true
}
@@ -85,11 +88,15 @@ timeout "${ETV_SCAN_TIMEOUT:-45m}" docker run --rm --network host -v "$OUT":/zap
zap_rc=$?
[ "$zap_rc" = 124 ] && echo "NOTE: ZAP wrapper hit the ${ETV_SCAN_TIMEOUT:-45m} timeout (usually a post-scan cleanup hang) — the report written before the hang is still valid; triage it."
set -e
# A timed-out `docker run` leaves the ZAP container; reap any stragglers so a re-run is clean.
docker ps --filter ancestor="$ZAP_IMAGE" -q | xargs -r docker kill >/dev/null 2>&1 || true
# (The ZAP container + target + temp dir are reaped by cleanup() on the EXIT trap — every path, incl.
# a `timeout` kill or Ctrl-C mid-scan.)
echo "==> ZAP report: $OUT/zap-api-report.html (+ .md/.json). Exit code: $zap_rc"
if [ "${ETV_SCAN_SKIP_SEMGREP:-0}" != "1" ] && command -v semgrep >/dev/null; then
if [ "${ETV_SCAN_SKIP_SEMGREP:-0}" = "1" ]; then
echo "==> semgrep SAST skipped (ETV_SCAN_SKIP_SEMGREP=1)"
elif ! command -v semgrep >/dev/null; then
echo "WARN: semgrep not installed — SAST cross-check SKIPPED (install semgrep for full coverage)" >&2
else
echo "==> semgrep SAST cross-check (repo root)"
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
semgrep scan --config p/security-audit --config p/secrets --config p/csharp \