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
Tighten reporting catalog validation
rcourtman388e86fd963e
diff --git a/frontend-modern/src/components/Settings/__tests__/reportingCatalogModel.test.ts b/frontend-modern/src/components/Settings/__tests__/reportingCatalogModel.test.tsindex f93ed3dda4..b9ddfaff28 100644--- a/frontend-modern/src/components/Settings/__tests__/reportingCatalogModel.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/reportingCatalogModel.test.ts@@ -4,6 +4,53 @@ import {parseReportingCatalog,} from '../reportingCatalogModel';+const baseCatalogPayload = {+ id: 'advanced_reporting',+ title: 'Detailed Reporting',+ description: 'Canonical reporting surfaces',+ performanceReport: {+ id: 'performance_reports',+ title: 'Performance Reports',+ description: 'Historical performance reporting',+ singleResourceEndpoint: '/api/admin/reports/generate',+ multiResourceEndpoint: '/api/admin/reports/generate-multi',+ singleFilenamePrefix: 'report',+ multiFilenamePrefix: 'fleet-report',+ formats: [+ { value: 'pdf', label: 'PDF Report' },+ { value: 'csv', label: 'CSV Data' },+ ],+ defaultFormat: 'pdf',+ ranges: [+ {+ key: '24h',+ label: 'Last 24 Hours',+ description: 'Daily review',+ windowHours: 24,+ },+ ],+ defaultRange: '24h',+ multiResourceMax: 50,+ supportsMetricFilter: true,+ supportsCustomTitle: true,+ },+ vmInventoryExport: {+ id: 'vm_inventory',+ title: 'VM Inventory Export',+ description: 'Current-state inventory',+ format: 'csv',+ exportEndpoint: '/api/admin/reports/inventory/vms/export',+ filenamePrefix: 'vm-inventory',+ columns: [+ {+ key: 'pool',+ label: 'Pool',+ description: 'Canonical Proxmox pool membership.',+ },+ ],+ },+} as const;+describe('reporting catalog model', () => {it('builds the canonical reporting catalog request', () => {expect(buildReportingCatalogRequest()).toEqual({@@ -12,52 +59,7 @@ describe('reporting catalog model', () => {});it('parses the canonical reporting catalog payload', () => {- const catalog = parseReportingCatalog({- id: 'advanced_reporting',- title: 'Detailed Reporting',- description: 'Canonical reporting surfaces',- performanceReport: {- id: 'performance_reports',- title: 'Performance Reports',- description: 'Historical performance reporting',- singleResourceEndpoint: '/api/admin/reports/generate',- multiResourceEndpoint: '/api/admin/reports/generate-multi',- singleFilenamePrefix: 'report',- multiFilenamePrefix: 'fleet-report',- formats: [- { value: 'pdf', label: 'PDF Report' },- { value: 'csv', label: 'CSV Data' },- ],- defaultFormat: 'pdf',- ranges: [- {- key: '24h',- label: 'Last 24 Hours',- description: 'Daily review',- windowHours: 24,- },- ],- defaultRange: '24h',- multiResourceMax: 50,- supportsMetricFilter: true,- supportsCustomTitle: true,- },- vmInventoryExport: {- id: 'vm_inventory',- title: 'VM Inventory Export',- description: 'Current-state inventory',- format: 'csv',- exportEndpoint: '/api/admin/reports/inventory/vms/export',- filenamePrefix: 'vm-inventory',- columns: [- {- key: 'pool',- label: 'Pool',- description: 'Canonical Proxmox pool membership.',- },- ],- },- });+ const catalog = parseReportingCatalog(baseCatalogPayload);expect(catalog.performanceReport.defaultFormat).toBe('pdf');expect(catalog.performanceReport.ranges[0].windowHours).toBe(24);@@ -65,4 +67,37 @@ describe('reporting catalog model', () => {'/api/admin/reports/inventory/vms/export',);});++ it('rejects a catalog whose default format is not in the supported formats', () => {+ expect(() =>+ parseReportingCatalog({+ ...baseCatalogPayload,+ performanceReport: {+ ...baseCatalogPayload.performanceReport,+ defaultFormat: 'pdf',+ formats: [{ value: 'csv', label: 'CSV Data' }],+ },+ }),+ ).toThrow('Invalid reporting catalog payload');+ });++ it('rejects a catalog whose default range is not in the supported ranges', () => {+ expect(() =>+ parseReportingCatalog({+ ...baseCatalogPayload,+ performanceReport: {+ ...baseCatalogPayload.performanceReport,+ defaultRange: '7d',+ ranges: [+ {+ key: '24h',+ label: 'Last 24 Hours',+ description: 'Daily review',+ windowHours: 24,+ },+ ],+ },+ }),+ ).toThrow('Invalid reporting catalog payload');+ });});diff --git a/frontend-modern/src/components/Settings/reportingCatalogModel.ts b/frontend-modern/src/components/Settings/reportingCatalogModel.tsindex 46ae491303..7a126a775f 100644--- a/frontend-modern/src/components/Settings/reportingCatalogModel.ts+++ b/frontend-modern/src/components/Settings/reportingCatalogModel.ts@@ -116,6 +116,18 @@ function parseReportingPerformanceReportDefinition(throw new Error('Invalid reporting catalog payload');}+ const formats = candidate.formats.map(parseReportingFormatDefinition);+ const ranges = candidate.ranges.map(parseReportingRangeDefinition);+ if (formats.length === 0 || ranges.length === 0) {+ throw new Error('Invalid reporting catalog payload');+ }+ if (!formats.some((format) => format.value === candidate.defaultFormat)) {+ throw new Error('Invalid reporting catalog payload');+ }+ if (!ranges.some((range) => range.key === candidate.defaultRange)) {+ throw new Error('Invalid reporting catalog payload');+ }+return {id: candidate.id,title: candidate.title,@@ -124,9 +136,9 @@ function parseReportingPerformanceReportDefinition(multiResourceEndpoint: candidate.multiResourceEndpoint,singleFilenamePrefix: candidate.singleFilenamePrefix,multiFilenamePrefix: candidate.multiFilenamePrefix,- formats: candidate.formats.map(parseReportingFormatDefinition),+ formats,defaultFormat: candidate.defaultFormat,- ranges: candidate.ranges.map(parseReportingRangeDefinition),+ ranges,defaultRange: candidate.defaultRange,multiResourceMax: candidate.multiResourceMax,supportsMetricFilter: candidate.supportsMetricFilter,