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
Guard diagnostics against internal analytics
rcourtman0714fec8afe0
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 6c0ca15e2e..4c61c9286e 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -1802,7 +1802,11 @@ That same diagnostics boundary now explicitly excludes maintainer analytics.funnel, pricing/checkout conversion, or infrastructure onboarding telemetry in`/api/diagnostics`; local upgrade/onboarding metrics remain owned by thelicensing/admin metrics routes and their admin gates rather than the customer-support diagnostics contract.+support diagnostics contract. `frontend-modern/scripts/settings-diagnostics-boundary-audit.mjs`+now checks `internal/api/diagnostics.go` alongside the Settings diagnostics+frontend boundary through the canonical frontend audit runner, so this+admin-analytics payload class cannot return as a customer-visible diagnostics+contract.That same public-demo API boundary must also hide runtime-admin operationssurfaces instead of treating them as harmless reads. Demo sessions must receive`404` for `/api/diagnostics`, `/api/diagnostics/docker/prepare-token`, and thediff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex 80b9043dfa..7c317a2503 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -151,10 +151,11 @@ work extends shared components instead of creating new local variants.125. `frontend-modern/src/components/Settings/DataHandlingPanel.tsx`126. `frontend-modern/src/components/Settings/dataHandlingPanelModel.ts`127. `frontend-modern/scripts/canonical-platform-audit.mjs`-128. `frontend-modern/src/utils/platformSupportManifest.generated.ts`-129. `frontend-modern/src/utils/platformSupportManifest.ts`-130. `frontend-modern/src/utils/sourcePlatformOptions.ts`-131. `frontend-modern/src/utils/sourcePlatforms.ts`+128. `frontend-modern/scripts/settings-diagnostics-boundary-audit.mjs`+129. `frontend-modern/src/utils/platformSupportManifest.generated.ts`+130. `frontend-modern/src/utils/platformSupportManifest.ts`+131. `frontend-modern/src/utils/sourcePlatformOptions.ts`+132. `frontend-modern/src/utils/sourcePlatforms.ts`## Shared Boundaries@@ -1757,6 +1758,10 @@ customer diagnostics surface. `DiagnosticsResultsPanel.tsx`,preserve commercial funnel, sales funnel, pricing/checkout conversion, orinfrastructure onboarding telemetry from `/api/diagnostics`; those signalsbelong in admin-owned metrics surfaces instead of Settings support UI.+`frontend-modern/scripts/settings-diagnostics-boundary-audit.mjs`, called by+the canonical frontend audit runner, enforces that boundary by failing if the+diagnostics API, diagnostics results panel, or diagnostics payload model+reintroduce those analytics fields outside the defensive strip helper.Diagnostics cards that summarize Docker and Podman agent coverage must use theshared `docker` source-platform label from`frontend-modern/src/utils/sourcePlatforms.ts` for their heading and body copy,diff --git a/docs/release-control/v6/internal/subsystems/registry.json b/docs/release-control/v6/internal/subsystems/registry.jsonindex 938f0bb01a..b88c313b9f 100644--- a/docs/release-control/v6/internal/subsystems/registry.json+++ b/docs/release-control/v6/internal/subsystems/registry.json@@ -2979,6 +2979,7 @@"owned_files": ["frontend-modern/scripts/canonical-platform-audit.mjs","frontend-modern/scripts/header-audit.mjs",+ "frontend-modern/scripts/settings-diagnostics-boundary-audit.mjs","frontend-modern/src/components/Settings/AIChatMaintenanceSection.tsx","frontend-modern/src/components/Settings/AIModelSelectionSection.tsx","frontend-modern/src/components/Settings/AIProviderConfigurationSection.tsx",@@ -3348,6 +3349,22 @@"frontend-modern/src/utils/__tests__/diagnosticsPresentation.test.ts"]},+ {+ "id": "settings-diagnostics-boundary-audit",+ "label": "settings diagnostics internal analytics boundary proof",+ "match_prefixes": [],+ "match_files": [+ "frontend-modern/scripts/settings-diagnostics-boundary-audit.mjs"+ ],+ "allow_same_subsystem_tests": false,+ "test_prefixes": [],+ "exact_files": [+ "frontend-modern/scripts/__tests__/settings-diagnostics-boundary-audit.test.mjs",+ "frontend-modern/src/components/Settings/__tests__/diagnosticsModel.test.ts",+ "frontend-modern/src/components/Settings/__tests__/DiagnosticsResultsPanel.test.tsx",+ "frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts"+ ]+ },{"id": "settings-shell-presentation-helper","label": "settings shell presentation helper proof",diff --git a/frontend-modern/scripts/__tests__/settings-diagnostics-boundary-audit.test.mjs b/frontend-modern/scripts/__tests__/settings-diagnostics-boundary-audit.test.mjsnew file mode 100644index 0000000000..f6635a1185--- /dev/null+++ b/frontend-modern/scripts/__tests__/settings-diagnostics-boundary-audit.test.mjs@@ -0,0 +1,85 @@+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';++import { afterEach, describe, expect, it } from 'vitest';++import { collectUserDiagnosticsInternalAnalyticsFindings } from '../settings-diagnostics-boundary-audit.mjs';++const tmpRoots = [];++function writeFixture(root, repoRoot, files) {+ const requiredFiles = {+ [path.join(repoRoot, 'internal', 'api', 'diagnostics.go')]:+ 'package api\n\ntype DiagnosticsInfo struct {}\n',+ [path.join(root, 'src', 'components', 'Settings', 'DiagnosticsResultsPanel.tsx')]:+ 'export function DiagnosticsResultsPanel() { return null; }\n',+ [path.join(root, 'src', 'components', 'Settings', 'diagnosticsModel.ts')]:+ 'export interface DiagnosticsInfo { version: string; }\n',+ ...files,+ };++ for (const [filePath, content] of Object.entries(requiredFiles)) {+ fs.mkdirSync(path.dirname(filePath), { recursive: true });+ fs.writeFileSync(filePath, content);+ }+}++function makeFixture(files = {}) {+ const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'pulse-diagnostics-boundary-'));+ tmpRoots.push(tmpRoot);+ const repoRoot = path.join(tmpRoot, 'repo');+ const root = path.join(repoRoot, 'frontend-modern');+ const fixtureFiles = typeof files === 'function' ? files({ root, repoRoot }) : files;+ writeFixture(root, repoRoot, fixtureFiles);+ return { root, repoRoot };+}++afterEach(() => {+ while (tmpRoots.length > 0) {+ fs.rmSync(tmpRoots.pop(), { force: true, recursive: true });+ }+});++describe('settings diagnostics boundary audit', () => {+ it('reports admin analytics fields on the user diagnostics boundary', () => {+ const { root, repoRoot } = makeFixture(({ root, repoRoot }) => ({+ [path.join(repoRoot, 'internal', 'api', 'diagnostics.go')]:+ 'package api\n\ntype CommercialFunnel struct { PricingViews int }\n',+ [path.join(root, 'src', 'components', 'Settings', 'DiagnosticsResultsPanel.tsx')]:+ "export const label = 'Pricing Views';\n",+ [path.join(root, 'src', 'components', 'Settings', 'diagnosticsModel.ts')]:+ 'export interface InfrastructureOnboardingDiagnostic { commercialFunnel?: unknown; }\n',+ }));++ const findings = collectUserDiagnosticsInternalAnalyticsFindings({ root, repoRoot });++ expect(findings.map((finding) => finding.rule)).toEqual([+ 'canonical-settings/no-internal-analytics-in-diagnostics-api',+ 'canonical-settings/no-internal-analytics-in-diagnostics-ui',+ 'canonical-settings/no-internal-analytics-diagnostics-types',+ 'canonical-settings/no-internal-analytics-diagnostics-types',+ ]);+ expect(findings[0]).toMatchObject({+ file: '../internal/api/diagnostics.go',+ line: 3,+ });+ });++ it('allows the diagnostics model to strip stale internal analytics keys defensively', () => {+ const { root, repoRoot } = makeFixture(({ root }) => ({+ [path.join(root, 'src', 'components', 'Settings', 'diagnosticsModel.ts')]: `+const INTERNAL_ANALYTICS_DIAGNOSTICS_FIELDS = ['commercialFunnel', 'infrastructureOnboarding'];++export function stripInternalAnalyticsDiagnosticsFields(payload) {+ for (const field of INTERNAL_ANALYTICS_DIAGNOSTICS_FIELDS) {+ delete payload[field];+ }+ return payload;+}+`,+ }));++ expect(collectUserDiagnosticsInternalAnalyticsFindings({ root, repoRoot })).toEqual([]);+ });+});diff --git a/frontend-modern/scripts/canonical-platform-audit.mjs b/frontend-modern/scripts/canonical-platform-audit.mjsindex 4306765ce1..3498b61702 100644--- a/frontend-modern/scripts/canonical-platform-audit.mjs+++ b/frontend-modern/scripts/canonical-platform-audit.mjs@@ -3,6 +3,8 @@ import crypto from 'node:crypto';import fs from 'node:fs';import path from 'node:path';+import { collectUserDiagnosticsInternalAnalyticsFindings } from './settings-diagnostics-boundary-audit.mjs';+const ROOT = process.cwd();const TARGET_DIRS = [path.join(ROOT, 'src')];const IGNORE_DIRS = new Set(['__tests__']);@@ -1706,6 +1708,12 @@ const MAP_RULES = [];requireGeneratedPlatformSupportProjectionSync();+findings.push(+ ...collectUserDiagnosticsInternalAnalyticsFindings({+ root: ROOT,+ repoRoot: path.resolve(ROOT, '..'),+ }),+);for (const dir of TARGET_DIRS) {for (const filePath of collectFiles(dir)) {diff --git a/frontend-modern/scripts/settings-diagnostics-boundary-audit.mjs b/frontend-modern/scripts/settings-diagnostics-boundary-audit.mjsnew file mode 100644index 0000000000..95cbd3208e--- /dev/null+++ b/frontend-modern/scripts/settings-diagnostics-boundary-audit.mjs@@ -0,0 +1,106 @@+#!/usr/bin/env node+import fs from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++const SCRIPT_PATH = fileURLToPath(import.meta.url);+const SCRIPT_DIR = path.dirname(SCRIPT_PATH);+const DEFAULT_FRONTEND_ROOT = path.resolve(SCRIPT_DIR, '..');+const DEFAULT_REPO_ROOT = path.resolve(DEFAULT_FRONTEND_ROOT, '..');++const INTERNAL_ANALYTICS_RULES = [+ {+ getFilePath: ({ repoRoot }) => path.join(repoRoot, 'internal', 'api', 'diagnostics.go'),+ rules: [+ {+ rule: 'canonical-settings/no-internal-analytics-in-diagnostics-api',+ regex:+ /CommercialFunnel|commercialFunnel|Commercial Funnel|Sales Funnel|InfrastructureOnboarding|infrastructureOnboarding|Infrastructure Onboarding|pricing_viewed|checkout_clicked|credentials_opened/g,+ message:+ 'Do not expose maintainer/admin analytics from /api/diagnostics. Keep commercial and onboarding analytics on admin-owned metrics routes.',+ },+ ],+ },+ {+ getFilePath: ({ root }) =>+ path.join(root, 'src', 'components', 'Settings', 'DiagnosticsResultsPanel.tsx'),+ rules: [+ {+ rule: 'canonical-settings/no-internal-analytics-in-diagnostics-ui',+ regex:+ /CommercialFunnel|commercialFunnel|Commercial Funnel|Sales Funnel|InfrastructureOnboarding|infrastructureOnboarding|Infrastructure Onboarding|Pricing Views|Checkout Clicks|Credentials Opened|pricing_viewed|checkout_clicked|credentials_opened/g,+ message:+ 'Do not render maintainer/admin analytics in the user-facing Settings diagnostics panel.',+ },+ ],+ },+ {+ getFilePath: ({ root }) =>+ path.join(root, 'src', 'components', 'Settings', 'diagnosticsModel.ts'),+ rules: [+ {+ rule: 'canonical-settings/no-internal-analytics-diagnostics-types',+ regex:+ /\bexport interface (?:CommercialFunnel|InfrastructureOnboarding)\w*\b|\b(?:commercialFunnel|infrastructureOnboarding)\?:|\b(?:CommercialFunnel|InfrastructureOnboarding)(?:Diagnostic|Summary|StageCounts|DayBreakdown|DimensionBreakdown|PathBreakdown|PlatformBreakdown)\b/g,+ message:+ 'Do not add commercial funnel or infrastructure onboarding fields to the customer diagnostics payload model.',+ },+ ],+ },+];++function lineForIndex(content, index) {+ let line = 1;+ for (let i = 0; i < index; i += 1) {+ if (content[i] === '\n') line += 1;+ }+ return line;+}++function relativeToRoot(root, absPath) {+ return path.relative(root, absPath).replaceAll(path.sep, '/');+}++export function collectUserDiagnosticsInternalAnalyticsFindings({+ root = DEFAULT_FRONTEND_ROOT,+ repoRoot = DEFAULT_REPO_ROOT,+} = {}) {+ const findings = [];++ for (const { getFilePath, rules } of INTERNAL_ANALYTICS_RULES) {+ const filePath = getFilePath({ root, repoRoot });+ const content = fs.readFileSync(filePath, 'utf8');+ const relativePath = relativeToRoot(root, filePath);++ for (const { rule, regex, message } of rules) {+ for (const match of content.matchAll(regex)) {+ findings.push({+ file: relativePath,+ line: lineForIndex(content, match.index ?? 0),+ rule,+ message,+ });+ }+ }+ }++ return findings;+}++function runStandalone() {+ const findings = collectUserDiagnosticsInternalAnalyticsFindings();+ if (findings.length === 0) {+ console.log('Settings diagnostics boundary audit passed with no findings.');+ return 0;+ }++ console.error('Settings diagnostics boundary audit findings:');+ for (const finding of findings) {+ console.error(`- ${finding.file}:${finding.line} [${finding.rule}] ${finding.message}`);+ }+ return 1;+}++if (process.argv[1] && path.resolve(process.argv[1]) === SCRIPT_PATH) {+ process.exit(runStandalone());+}diff --git a/scripts/release_control/canonical_completion_guard_test.py b/scripts/release_control/canonical_completion_guard_test.pyindex 47fd643062..e61dcf5cfb 100644--- a/scripts/release_control/canonical_completion_guard_test.py+++ b/scripts/release_control/canonical_completion_guard_test.py@@ -3273,6 +3273,33 @@ index 1111111..2222222 100644],)+ def test_frontend_primitive_settings_diagnostics_boundary_audit_uses_specific_guardrails(self):+ rule = next(rule for rule in load_subsystem_rules() if rule["id"] == "frontend-primitives")+ requirements = build_verification_requirements(+ rule,+ ["frontend-modern/scripts/settings-diagnostics-boundary-audit.mjs"],+ )+ self.assertEqual(+ requirements,+ [+ {+ "id": "settings-diagnostics-boundary-audit",+ "label": "settings diagnostics internal analytics boundary proof",+ "touched_runtime_files": [+ "frontend-modern/scripts/settings-diagnostics-boundary-audit.mjs"+ ],+ "allow_same_subsystem_tests": False,+ "test_prefixes": [],+ "exact_files": [+ "frontend-modern/scripts/__tests__/settings-diagnostics-boundary-audit.test.mjs",+ "frontend-modern/src/components/Settings/__tests__/DiagnosticsResultsPanel.test.tsx",+ "frontend-modern/src/components/Settings/__tests__/diagnosticsModel.test.ts",+ "frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts",+ ],+ }+ ],+ )+def _assert_environment_lock_boundary_requires_frontend_primitives(self, touched_path: str, requirement_id: str, exact_files: list[str]) -> None:diff --git a/scripts/release_control/subsystem_lookup_test.py b/scripts/release_control/subsystem_lookup_test.pyindex ccdf8dbef2..763c0b59b7 100644--- a/scripts/release_control/subsystem_lookup_test.py+++ b/scripts/release_control/subsystem_lookup_test.py@@ -2833,6 +2833,33 @@ class SubsystemLookupTest(unittest.TestCase):],)+ def test_lookup_paths_assigns_settings_diagnostics_boundary_audit_to_frontend_primitives(+ self,+ ) -> None:+ result = lookup_paths(["frontend-modern/scripts/settings-diagnostics-boundary-audit.mjs"])+ self.assertEqual(result["unowned_runtime_files"], [])+ self.assertEqual(+ {item["subsystem"] for item in result["impacted_subsystems"]},+ {"frontend-primitives"},+ )++ file_entry = result["files"][0]+ self.assertEqual(file_entry["classification"], "runtime")+ self.assertEqual(+ {match["subsystem"] for match in file_entry["matches"]},+ {"frontend-primitives"},+ )+ match = file_entry["matches"][0]+ self.assertEqual(+ match["contract"],+ "docs/release-control/v6/internal/subsystems/frontend-primitives.md",+ )+ self.assertEqual(match["lane_context"]["lane_id"], "L8")+ self.assertEqual(+ match["verification_requirement"]["id"],+ "settings-diagnostics-boundary-audit",+ )+def test_lookup_paths_assigns_settings_dialogs_to_frontend_primitives(self) -> None:result = lookup_paths(["frontend-modern/src/components/Settings/SettingsDialogs.tsx"])self.assertEqual(result["unowned_runtime_files"], [])