Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Keep positive npm advisory evidence fail-closed
pulse-triage[bot]6ef79688a5d1
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.mdindex 3f1b8cc843..13dc89ef77 100644--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md@@ -4645,7 +4645,17 @@ no JavaScript. It separates the two and nothing else. A conclusive result isacted on immediately and any vulnerability at any severity still fails, evenif the same response also carries a transport error, so a severity thresholdmust never be introduced; only an unreachable endpoint is-retried. Finding diagnostics must use that same captured JSON response, never+retried. A nonempty package-finding map or any positive integer+summary count must fail immediately, even when the total is missing or+contradicts that evidence; a later response must not replace a known finding.+A clean verdict requires all six known summary counts to be integer zero,+no endpoint error and an absent or empty package-finding map. Booleans,+strings, nulls, negative counts and partial summaries are not zero-finding+evidence. Without positive evidence, malformed reports retain the existing+bounded outage policy, never a clean verdict. Summary diagnostics may print+only validated nonnegative integer counts (or `unknown`) and the package-record+count, not raw metadata strings capable of emitting workflow commands.+Finding diagnostics must use that same captured JSON response, nevera second registry request: such a request could hang outside the watchdog ordescribe a different verdict. Logs retain the affected package, severity,range, locked paths, advisory source/title/link and fix availability through@@ -4654,7 +4664,9 @@ details. Missing package-level detail leaves the vulnerability failure intact;it must not trigger another request. `scripts/tests/test_npm_audit_retry.py`executes changed-second-response, missing-detail, escaping and single-requestfixtures, including production argument forwarding and findings accompanied by-transport errors. Retrying is bounded by wall clock and not by attempt count alone,+transport errors, positive package/severity evidence with missing or zero+totals, malformed zero summaries under both outage modes, and metadata+annotation injection. Retrying is bounded by wall clock and not by attempt count alone,because npm's own `fetch-timeout` defaults to five minutes and it retriesinternally: on 2026-09-04 three attempts against a hanging endpoint ran for10m56s and cancelled the Frontend job at its own timeout with every testdiff --git a/scripts/npm-audit-retry.sh b/scripts/npm-audit-retry.shindex b4e210099f..95ddc1d2d9 100755--- a/scripts/npm-audit-retry.sh+++ b/scripts/npm-audit-retry.sh@@ -132,65 +132,75 @@ except ValueError:meta = report.get("metadata") if isinstance(report, dict) else Nonevulns = meta.get("vulnerabilities") if isinstance(meta, dict) else None-if isinstance(vulns, dict) and "total" in vulns:- # A usable advisory verdict takes precedence even if npm also includes a- # transport error. Never turn a real finding into a retryable outage.- total = vulns.get("total", 0)+findings = report.get("vulnerabilities") if isinstance(report, dict) else None+count_names = ("total", "critical", "high", "moderate", "low", "info")+# Counts are numbers, not arbitrary registry strings. In particular, Python+# bools are ints too, but neither false nor null is evidence of zero findings.+counts = {}+if isinstance(vulns, dict):+ for name in count_names:+ value = vulns.get(name)+ if type(value) is int and value >= 0:+ counts[name] = value+has_findings = isinstance(findings, dict) and bool(findings)+if has_findings or any(count > 0 for count in counts.values()):+ # Any positive package or severity evidence wins, even if the summary is+ # missing/inconsistent or npm also reports a transport error. Retrying must+ # never replace an already observed finding with a later clean response.detail = " ".join(- f"{name}={vulns.get(name, 0)}"- for name in ("critical", "high", "moderate", "low", "info")+ "{}={}".format(name, counts.get(name, "unknown")) for name in count_names)- print("vulnerable" if total else "clean")- print(f"total={total} {detail}")- if total:- # Do not query npm again for human-readable detail. A second request- # can hang outside the watchdog or return different advisory evidence.- # JSON encoding keeps registry text from becoming terminal escapes or- # GitHub workflow commands; transport errors and unknown fields stay out.- findings = report.get("vulnerabilities")- emitted = False- if isinstance(findings, dict):- for name, finding in sorted(findings.items()):- if not isinstance(finding, dict):- continue- projected = {"name": name}- for key in ("name", "severity", "isDirect", "range", "nodes"):- if key in finding:- projected[key] = finding[key]- via = finding.get("via")- if isinstance(via, list):- projected["via"] = [- {key: advisory[key] for key in- ("source", "name", "dependency", "title", "url", "severity", "range")- if key in advisory}- if isinstance(advisory, dict) else advisory- for advisory in via if isinstance(advisory, (dict, str))- ]- fix = finding.get("fixAvailable")- if isinstance(fix, bool):- projected["fixAvailable"] = fix- elif isinstance(fix, dict):- projected["fixAvailable"] = {- key: fix[key] for key in ("name", "version", "isSemVerMajor")- if key in fix- }- print("audit finding " + json.dumps(projected, ensure_ascii=True, sort_keys=True))- emitted = True- if not emitted:- print("npm audit: package-level detail unavailable in captured verdict")+ if has_findings:+ detail += f" package_records={len(findings)}"+ print("vulnerable")+ print(detail)+ # Do not query npm again for human-readable detail. A second request+ # can hang outside the watchdog or return different advisory evidence.+ # JSON encoding keeps registry text from becoming terminal escapes or+ # GitHub workflow commands; transport errors and unknown fields stay out.+ emitted = False+ if isinstance(findings, dict):+ for name, finding in sorted(findings.items()):+ if not isinstance(finding, dict):+ continue+ projected = {"name": name}+ for key in ("name", "severity", "isDirect", "range", "nodes"):+ if key in finding:+ projected[key] = finding[key]+ via = finding.get("via")+ if isinstance(via, list):+ projected["via"] = [+ {key: advisory[key] for key in+ ("source", "name", "dependency", "title", "url", "severity", "range")+ if key in advisory}+ if isinstance(advisory, dict) else advisory+ for advisory in via if isinstance(advisory, (dict, str))+ ]+ fix = finding.get("fixAvailable")+ if isinstance(fix, bool):+ projected["fixAvailable"] = fix+ elif isinstance(fix, dict):+ projected["fixAvailable"] = {+ key: fix[key] for key in ("name", "version", "isSemVerMajor")+ if key in fix+ }+ print("audit finding " + json.dumps(projected, ensure_ascii=True, sort_keys=True))+ emitted = True+ if not emitted:+ print("npm audit: package-level detail unavailable in captured verdict")sys.exit(0)-if isinstance(report, dict) and report.get("error"):- # npm reports an unusable endpoint as an error object, ENOAUDIT being the- # code it uses for 5xx, timeouts and offline runs alike.+if (+ isinstance(report, dict) and not report.get("error")+ and len(counts) == len(count_names) and all(count == 0 for count in counts.values())+ and ("vulnerabilities" not in report or isinstance(findings, dict))+):+ print("clean")+ print(" ".join(f"{name}=0" for name in count_names))+else:+ # A malformed/partial zero summary or endpoint error is not a clean verdict.+ # With no positive finding, retain the existing bounded outage policy.print("unreachable")- sys.exit(0)--if not isinstance(vulns, dict) or "total" not in vulns:- # No usable verdict in the payload: treat as unreachable rather than- # silently passing on a shape we do not understand.- print("unreachable")- sys.exit(0)'}diff --git a/scripts/tests/test_npm_audit_retry.py b/scripts/tests/test_npm_audit_retry.pyindex 8684fda4ab..667a4754ff 100755--- a/scripts/tests/test_npm_audit_retry.py+++ b/scripts/tests/test_npm_audit_retry.py@@ -75,6 +75,11 @@ class NpmAuditRetryTest(unittest.TestCase):fiexit 1;;+ captured-report)+ # Malformed reports must remain the same on retry.+ cat "$FAKE_NPM_REPORT"+ exit 1+ ;;garbage)echo 'not json'exit 1@@ -236,6 +241,104 @@ class NpmAuditRetryTest(unittest.TestCase):self.assertNotIn("\n::error::injected", result.stdout)self.assertNotIn("\x1b", result.stdout)+ def test_package_findings_fail_even_when_summary_is_missing_or_zero(self) -> None:+ for metadata in [None, {}, {"vulnerabilities": {"total": 0}}]:+ for require in ["true", "false"]:+ with self.subTest(metadata=metadata, require=require):+ report = {+ "vulnerabilities": {+ "dependency": {"name": "dependency", "severity": "high"}+ }+ }+ if metadata is not None:+ report["metadata"] = metadata+ result, calls = self.run_check(+ "captured-vulnerability", "all", require=require, report=report+ )+ self.assertEqual(result.returncode, 1, result.stdout)+ self.assertEqual(calls, ["audit --json"], result.stdout)+ self.assertIn("vulnerabilities present", result.stdout)+ self.assertIn("package_records=1", result.stdout)+ self.assertNotIn("no vulnerabilities", result.stdout)++ def test_positive_severity_counts_fail_without_a_consistent_total(self) -> None:+ for severity in ["info", "low", "moderate", "high", "critical"]:+ for total in [None, 0]:+ with self.subTest(severity=severity, total=total):+ counts = {severity: 1}+ if total is not None:+ counts["total"] = total+ report = {+ "metadata": {"vulnerabilities": counts},+ "error": {"code": "ETIMEDOUT"},+ }+ result, calls = self.run_check(+ "captured-vulnerability", "production",+ require="false", report=report,+ )+ self.assertEqual(result.returncode, 1, result.stdout)+ self.assertEqual(calls, ["audit --json --omit=dev"], result.stdout)+ self.assertIn("vulnerabilities present", result.stdout)++ def test_malformed_zero_verdicts_cannot_pass_as_clean(self) -> None:+ zero_counts = dict.fromkeys(+ ["info", "low", "moderate", "high", "critical", "total"], 0+ )+ reports = [+ {"metadata": {"vulnerabilities": {**zero_counts, "total": value}}}+ for value in [None, False, -1, 0.0, "0", [], {}]+ ]+ reports.extend([+ {"metadata": {"vulnerabilities": {**zero_counts, "high": "0"}}},+ {"metadata": {"vulnerabilities": {**zero_counts, "high": None}}},+ {"metadata": {"vulnerabilities": {"total": 0}}},+ {"metadata": {"vulnerabilities": zero_counts}, "vulnerabilities": []},+ {"metadata": {"vulnerabilities": zero_counts}, "vulnerabilities": None},+ {+ "metadata": {"vulnerabilities": zero_counts},+ "error": {"code": "ENOAUDIT"},+ },+ ])+ for report in reports:+ for require in ["true", "false"]:+ with self.subTest(report=report, require=require):+ result, calls = self.run_check(+ "captured-report", "all", require=require, report=report+ )+ self.assertEqual(+ result.returncode, 1 if require == "true" else 0, result.stdout+ )+ self.assertEqual(calls, ["audit --json"] * 3, result.stdout)+ self.assertNotIn("no vulnerabilities", result.stdout)+ self.assertIn("could not reach", result.stdout)+ if require == "false":+ self.assertIn("::warning::", result.stdout)++ def test_summary_cannot_emit_untrusted_metadata_as_workflow_commands(self) -> None:+ unsafe = "0\n::error::injected metadata\x1b[31m"+ report = {"metadata": {"vulnerabilities": {"total": 1, "high": unsafe}}}+ result, calls = self.run_check("captured-vulnerability", "all", report=report)+ self.assertEqual(result.returncode, 1, result.stdout)+ self.assertEqual(calls, ["audit --json"])+ self.assertIn("vulnerabilities present", result.stdout)+ self.assertIn("high=unknown", result.stdout)+ self.assertNotIn("injected metadata", result.stdout)+ self.assertNotIn("\x1b", result.stdout)++ def test_passes_a_complete_zero_summary_and_empty_package_map(self) -> None:+ report = {+ "metadata": {+ "vulnerabilities": dict.fromkeys(+ ["info", "low", "moderate", "high", "critical", "total"], 0+ )+ },+ "vulnerabilities": {},+ }+ result, calls = self.run_check("captured-report", "all", report=report)+ self.assertEqual(result.returncode, 0, result.stdout)+ self.assertEqual(calls, ["audit --json"])+ self.assertIn("no vulnerabilities", result.stdout)+def test_persistent_outage_fails_when_a_result_is_required(self) -> None:result, calls = self.run_check("transient-failure", "all")self.assertEqual(result.returncode, 1)