fix(security): patch Next and OpenTelemetry dependencies with CI gates

This commit is contained in:
Vib Tools committed 2026-11-22 06:08:27 -08:00
1 parent 1a602551ad
commit 752d243ae8
29 files changed
+1138 -9280

No files matched your search

+1
View File
@@ -11,3 +11,4 @@
| [compose.portless.override.yaml](compose.portless.override.yaml) | CI-only override to clear inherited P02 proxy host port publishing; pending CI acceptance | P05-CI-02/P05-CI-03 |
| [backend_acceptance.sh](backend_acceptance.sh) | Backend-only runner preflight, four-service health, Postgres restart marker and OIDC/JWKS CI checks | P05-CI-03 |
| [backend_cleanup.sh](backend_cleanup.sh) | Always-run cleanup of marked CI-owned Compose project/volumes, with leftover verification | P05-CI-03 |
| [security_advisory_gate.py](security_advisory_gate.py) | Strict CI registry JSON gate: rejects incomplete reports and any Moderate/High/Critical finding | P05-SEC-01 |
+2
View File
@@ -14,4 +14,6 @@ No real credentials or production domains are used. Never print bootstrap PATs,
- `backend_cleanup.sh` (P05-CI-03) is the workflow's `always()` cleanup script. It tears down only a marked run-owned Compose project and verifies that no project containers, volumes or fixed network remain. Unverified cleanup is an explicit failure.
- Run from `.gitea/workflows/p05-backend-acceptance.yml` **only in isolated Gitea CI**, not on a production Docker host or local developer PC. **Run #86 PASS** on `03fb589`, including persistence and owned cleanup. No real user login/MFA E2E was run.
- `security_advisory_gate.py` (P05-SEC-01) takes npm or pnpm registry audit JSON, rejects missing/errored/inconsistent metadata and requires **zero Moderate/High/Critical findings**. It is independent of the existing HIGH+ audit command and `advisory_triage.py` detailed advisory ID report. Do not mark reported Moderate findings resolved without a green CI result. Dedicated `.gitea/workflows/p05-security-acceptance.yml` is manual only; frozen installs/builds run only on Gitea.
Add new CI checks and update `MINIFEST.md`, `project/`, `docs/`, and `notes/` in the same approved phase.
+76
View File
@@ -0,0 +1,76 @@
"""Fail-closed production advisory gate: reject Moderate, High and Critical.
Registry report must be complete and match the expected format.
This is CI-only; report data comes from npm/pnpm and never changes dependencies.
"""
from __future__ import annotations
import json
from pathlib import Path
import sys
LEVELS = ("moderate", "high", "critical")
ALL = ("info", "low", "moderate", "high", "critical")
def main() -> int:
if len(sys.argv) != 3 or sys.argv[1] not in ("npm", "pnpm"):
raise ValueError("Usage: security_advisory_gate.py npm|pnpm report.json")
manager, file = sys.argv[1:]
report = json.loads(Path(file).read_text(encoding="utf-8"))
if not isinstance(report, dict) or report.get("error"):
raise ValueError("Registry error or malformed audit report")
metadata = report.get("metadata")
if not isinstance(metadata, dict):
raise ValueError("Audit metadata missing")
counts = metadata.get("vulnerabilities")
if not isinstance(counts, dict):
raise ValueError("Audit vulnerability metadata missing")
for severity in ALL:
value = counts.get(severity)
if type(value) is not int or value < 0:
raise ValueError(f"Missing/non-integer {severity} audit count")
if manager == "npm":
packages = report.get("vulnerabilities")
if not isinstance(packages, dict):
raise ValueError("npm audit vulnerable package map missing")
discovered = {severity: 0 for severity in ALL}
for name, record in packages.items():
if not isinstance(record, dict) or record.get("severity") not in ALL:
raise ValueError(f"Invalid npm package vulnerability record: {name}")
discovered[record["severity"]] += 1
if any(counts[key] != discovered[key] for key in ALL):
raise ValueError("npm metadata and individual vulnerable package counts differ")
else:
records = report.get("advisories")
if not isinstance(records, dict):
raise ValueError("pnpm audit advisory map missing")
discovered = {severity: 0 for severity in ALL}
for identifier, record in records.items():
if not isinstance(record, dict) or record.get("severity") not in ALL:
raise ValueError(f"Invalid pnpm advisory record: {identifier}")
discovered[record["severity"]] += 1
if any(counts[key] != discovered[key] for key in ALL):
raise ValueError("pnpm metadata and individual advisory counts differ")
print(f"ZITPLANE_{manager.upper()}_ADVISORY_COUNTS={counts}", flush=True)
open_count = sum(counts[key] for key in LEVELS)
if open_count:
print(
f"ZITPLANE_{manager.upper()}_SECURITY_ACCEPTANCE_BLOCKED="
f"{open_count} Moderate/High/Critical findings; see preceding triage records",
file=sys.stderr,
flush=True,
)
return 1
print(f"ZITPLANE_{manager.upper()}_ZERO_MODERATE_HIGH_CRITICAL_PASS")
return 0
if __name__ == "__main__":
try:
sys.exit(main())
except (ValueError, OSError, KeyError, json.JSONDecodeError) as exc:
print(f"ZITPLANE_ADVISORY_GATE_INVALID_REPORT: {exc}", file=sys.stderr)
sys.exit(1)