Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Reject ambiguous dates in backup protection assessments

pulse-triage[bot]7770552b4615
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 7d1909e3e4..7bf6d05f17 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -21,6 +21,30 @@
## Purpose
+### Protection assessments require explicit, valid instants
+
+The browser admits assessment and provider timestamps only as calendar-valid,
+explicitly zoned RFC3339 instants, using the same parser as restore evidence.
+Date-only, timezone-free, impossible and browser-repaired dates cannot validate
+an otherwise Protected response. One invalid timestamp rejects the entire
+joined assessment through the existing unavailable/retry path: retained
+verdicts, provider quality and policy are withdrawn, not replaced by a partial
+batch or a client-computed protection decision. Independent restore evidence,
+workload identity and open details remain usable. Valid leap days, offsets,
+nanosecond fractions, epoch/future instants and optional absent/null fields keep
+their existing meaning and server-authored verdict. No endpoint, producer,
+policy, store or guest operation changes.
+
+Normal-suite `protectionPostureResponse.test.ts` covers every assessment and
+provider timestamp field and valid controls. `useProtectionPostures.test.ts`
+checks whole-read withdrawal/recovery when the last of two fleet batches has an
+invalid instant. `ProxmoxBackupsTable.test.tsx` drives malformed calendar,
+zone-free and date-only assessments through the real Coverage consumer and
+isolated retry. Desktop/narrow browser proof must exercise that changed HTTP
+producer through health counts, open details and recovery/recurrence. This is
+malformed-response safety, not original stale-protection causality or native
+backup/guest recovery.
+
### Coverage previews retain the evidence behind uncertainty
The existing Coverage restore-evidence preview retains the newest observed and
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
index 65ba4638d6..cd6e18e38b 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
@@ -1623,7 +1623,7 @@ describe('Coverage qualifies missing restore evidence through the consuming API
});
describe('Coverage withdraws failed protection assessments', () => {
- it.each(['duplicate', 'provider', 'policy'])(
+ it.each(['duplicate', 'provider', 'policy', 'calendar', 'timezone', 'date-only'])(
'treats HTTP200 malformed %s evidence as unavailable and preserves independent restore points',
async (invalid) => {
vi.useFakeTimers({ toFake: ['setInterval', 'clearInterval'] });
@@ -1641,8 +1641,22 @@ describe('Coverage withdraws failed protection assessments', () => {
const accepted = (await apiFetchJSONMock.mock.results[0]
.value) as ProtectionPosturesResponse;
const privateValue = { private: 'SYNTHETIC_PRIVATE_VALUE' };
- const malformed =
- invalid === 'duplicate'
+ const malformed = ['calendar', 'timezone', 'date-only'].includes(invalid)
+ ? {
+ ...accepted,
+ data: [
+ {
+ ...accepted.data[0],
+ evaluatedAt:
+ invalid === 'calendar'
+ ? '2026-09-31T10:00:00Z'
+ : invalid === 'timezone'
+ ? '2026-10-26T10:00:00'
+ : '2026-10-26',
+ },
+ ],
+ }
+ : invalid === 'duplicate'
? {
...accepted,
data: [{ ...accepted.data[0], state: 'unprotected' }, accepted.data[0]],
diff --git a/frontend-modern/src/hooks/__tests__/useProtectionPostures.test.ts b/frontend-modern/src/hooks/__tests__/useProtectionPostures.test.ts
index b5d1e57da9..3854187077 100644
--- a/frontend-modern/src/hooks/__tests__/useProtectionPostures.test.ts
+++ b/frontend-modern/src/hooks/__tests__/useProtectionPostures.test.ts
@@ -208,7 +208,7 @@ describe('useProtectionPostures transport', () => {
}
});
- it.each(['row', 'policy', 'duplicate', 'mixed policies'])(
+ it.each(['row', 'policy', 'duplicate', 'mixed policies', 'timestamp'])(
'withdraws the whole 201-subject read after a malformed %s in the last batch',
async (invalid) => {
const ids = Array.from({ length: 201 }, (_, index) => `vm:${index}`);
@@ -230,6 +230,11 @@ describe('useProtectionPostures transport', () => {
const response = validResponse(url);
if (response.data.length > 1) return response;
if (invalid === 'row') return { ...response, data: [null] };
+ if (invalid === 'timestamp')
+ return {
+ ...response,
+ data: [{ ...response.data[0], evaluatedAt: '2026-09-31T10:00:00Z' }],
+ };
if (invalid === 'policy')
return { ...response, policy: { requireVerification: 'false' } };
if (invalid === 'duplicate') return { ...response, data: [protectionPosture('vm:0')] };
diff --git a/frontend-modern/src/utils/__tests__/protectionPostureResponse.test.ts b/frontend-modern/src/utils/__tests__/protectionPostureResponse.test.ts
index d106e1e975..9667be4f40 100644
--- a/frontend-modern/src/utils/__tests__/protectionPostureResponse.test.ts
+++ b/frontend-modern/src/utils/__tests__/protectionPostureResponse.test.ts
@@ -58,6 +58,66 @@ describe('protection posture response boundary', () => {
expect(parseProtectionPostureBatches([response(row)]).data).toEqual([row]);
});
+ const timestampFields = [
+ 'evaluatedAt',
+ 'lastAttemptAt',
+ 'lastSuccessfulPointAt',
+ 'lastVerifiedAt',
+ 'provider.lastAttemptAt',
+ 'provider.lastSuccessAt',
+ 'provider.lastVerifiedAt',
+ ];
+ const withTimestamp = (field: string, value: string) => {
+ const row = protectionPosture();
+ if (field.startsWith('provider.')) {
+ return {
+ ...row,
+ providerStates: [{ ...row.providerStates[0], [field.slice('provider.'.length)]: value }],
+ };
+ }
+ return { ...row, [field]: value };
+ };
+
+ it.each(
+ timestampFields.flatMap((field) =>
+ [
+ '2026-09-31T10:00:00Z',
+ '2026-02-29T10:00:00Z',
+ '2026-10-26T10:00:00',
+ '2026-10-26',
+ '2026-10-26T24:00:00Z',
+ 'Mon, 26 Oct 2026 10:00:00 GMT',
+ '2026-10-26T10:00:00.1234567890Z',
+ ].map((value) => ({ field, value })),
+ ),
+ )(
+ 'rejects ambiguous or repaired $field=$value for the entire joined read',
+ ({ field, value }) => {
+ expect(() =>
+ parseProtectionPostureBatches([
+ response(protectionPosture('vm:valid')),
+ response(withTimestamp(field, value)),
+ ]),
+ ).toThrow(ProtectionPostureFormatError);
+ },
+ );
+
+ it.each(
+ timestampFields.flatMap((field) =>
+ [
+ '2024-02-29T23:59:59Z',
+ '2026-10-26T10:00:00.123456789Z',
+ '2026-10-26T10:00:00+05:30',
+ '2026-10-26T10:00:00-07:00',
+ '1970-01-01T00:00:00Z',
+ '2099-01-01T00:00:00Z',
+ ].map((value) => ({ field, value })),
+ ),
+ )('preserves valid $field=$value without changing the server verdict', ({ field, value }) => {
+ const row = withTimestamp(field, value);
+ expect(parseProtectionPostureBatches([response(row)])).toEqual(response(row));
+ });
+
it.each([
['no batches', []],
['null envelope', [null]],
diff --git a/frontend-modern/src/utils/protectionPostureResponse.ts b/frontend-modern/src/utils/protectionPostureResponse.ts
index 7f18ddf314..375a9c947f 100644
--- a/frontend-modern/src/utils/protectionPostureResponse.ts
+++ b/frontend-modern/src/utils/protectionPostureResponse.ts
@@ -4,6 +4,7 @@ import type {
ProtectionPosturesResponse,
ProtectionProviderState,
} from '@/types/recovery';
+import { parseBackupTimestampMs } from '@/utils/backupTimestamp';
export class ProtectionPostureFormatError extends Error {
constructor() {
@@ -15,7 +16,10 @@ export class ProtectionPostureFormatError extends Error {
type Check = (value: unknown) => boolean;
const text: Check = (value) => typeof value === 'string' && value.trim().length > 0;
-const timestamp: Check = (value) => text(value) && Number.isFinite(Date.parse(value as string));
+// Assessments use the same explicit, calendar-valid instant rule as their
+// restore evidence. Browser date repair cannot validate a server assessment.
+const timestamp: Check = (value) =>
+ typeof value === 'string' && parseBackupTimestampMs(value) !== undefined;
const optionalTime: Check = (value) => value == null || timestamp(value);
const boolean: Check = (value) => typeof value === 'boolean';
const positiveSeconds: Check = (value) =>