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.

Admit the current audit grid row without accepting stale copies

pulse-triage[bot]74e397e286f0
diff --git a/frontend-modern/src/components/Settings/__tests__/AuditLogReaderLifetime.test.tsx b/frontend-modern/src/components/Settings/__tests__/AuditLogReaderLifetime.test.tsx
index 38cba6714c..267041ac9e 100644
--- a/frontend-modern/src/components/Settings/__tests__/AuditLogReaderLifetime.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/AuditLogReaderLifetime.test.tsx
@@ -1,4 +1,5 @@
import { createSignal } from 'solid-js';
+import { createStore } from 'solid-js/store';
import { renderHook, waitFor } from '@solidjs/testing-library';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { apiFetch, setOrgID } from '@/utils/apiClient';
@@ -448,4 +449,20 @@ describe('Audit log reader lifetime', () => {
expect(showSuccess).not.toHaveBeenCalled();
expect(showWarning).not.toHaveBeenCalled();
});
+ it('accepts the current data-grid row proxy without admitting a copied row', async () => {
+ vi.mocked(apiFetch)
+ .mockResolvedValueOnce(list(['a']))
+ .mockImplementation(async () => verified());
+ const { result, cleanup } = mount();
+ try {
+ await waitFor(() => expect(result.events()).toHaveLength(1));
+ const [row] = createStore(result.events()[0]);
+ await result.verifyEvent(row);
+ expect(result.verification().a?.status).toBe('verified');
+ await result.verifyEvent({ ...row });
+ expect(apiFetch).toHaveBeenCalledTimes(2);
+ } finally {
+ cleanup();
+ }
+ });
});
diff --git a/frontend-modern/src/components/Settings/useAuditLogPanelState.ts b/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
index a4708498e7..a3ce827dbf 100644
--- a/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
+++ b/frontend-modern/src/components/Settings/useAuditLogPanelState.ts
@@ -9,6 +9,7 @@ import {
untrack,
} from 'solid-js';
import type { Accessor } from 'solid-js';
+import { unwrap } from 'solid-js/store';
import { useLocation, useNavigate } from '@solidjs/router';
import {
createLocalStorageBooleanSignal,
@@ -385,13 +386,16 @@ export const useAuditLogPanelState = (props: AuditLogPanelProps = {}) => {
}
};
+ const isCurrentEvent = (event: AuditEvent) =>
+ events().some((current) => unwrap(current) === unwrap(event));
+
const verifyEvent = async (event: AuditEvent) => {
if (
!ensureCurrentReader() ||
!accessAllowed() ||
loading() ||
error() ||
- !events().includes(event) ||
+ !isCurrentEvent(event) ||
!event.signature ||
verifyControllers()[event.id]
)
@@ -404,7 +408,7 @@ export const useAuditLogPanelState = (props: AuditLogPanelProps = {}) => {
acceptedReader === reader() &&
generation === verificationGeneration &&
verifyControllers()[event.id] === controller &&
- events().includes(event);
+ isCurrentEvent(event);
batch(() => {
setVerifying((prev) => ({ ...prev, [event.id]: true }));
setVerifyControllers((prev) => ({ ...prev, [event.id]: controller }));