Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

add edge case

Thiago Araujo da Silva0c5a047e9739
diff --git a/backend/src/ee/services/audit-log-stream/splunk/splunk-provider-factory.test.ts b/backend/src/ee/services/audit-log-stream/splunk/splunk-provider-factory.test.ts
index 125d81f3aa..b70d2981b3 100644
--- a/backend/src/ee/services/audit-log-stream/splunk/splunk-provider-factory.test.ts
+++ b/backend/src/ee/services/audit-log-stream/splunk/splunk-provider-factory.test.ts
@@ -126,17 +126,40 @@ describe("SplunkProviderFactory batchStreamLog", () => {
});
});
- test("stamps HEC time from the event's createdAt, not the time of delivery", async () => {
- const auditLogs = [buildLog(0), buildLog(1)];
+ // HEC only reads the event timestamp from `time`, and wants UNIX `<sec>.<ms>` (its own
+ // example is 1433188255.500). 1781215650.732 is 2026-06-11T22:07:30.732Z, buildLog(0)'s
+ // createdAt. Both input shapes are covered because production produces both: a Date on the
+ // live path, an ISO string once the payload has been through the outbox's jsonb column.
+ test.each([
+ ["an ISO string", (idx: number) => buildLog(idx)],
+ [
+ "a Date",
+ (idx: number) =>
+ ({
+ ...buildLog(idx),
+ createdAt: new Date(buildLog(idx).createdAt as unknown as string)
+ }) as unknown as TAuditLogs
+ ]
+ ])("stamps HEC time from the event's createdAt (%s), not the time of delivery", async (_label, build) => {
+ const auditLogs = [build(0), build(1)];
await SplunkProviderFactory().batchStreamLog({ credentials: CREDENTIALS, auditLogs });
const events = readConcatenatedJson(sentRequests[0].body);
- // Epoch seconds carrying the millisecond fraction, which HEC accepts to 3 decimals.
- // 1781215650.732 is 2026-06-11T22:07:30.732Z, the createdAt of buildLog(0).
expect(events.map((entry) => entry.time)).toEqual([1781215650.732, 1781215651.732]);
});
+ test("ignores an unparseable createdAt rather than emitting a null timestamp", async () => {
+ const before = Date.now() / 1000;
+ const auditLog = { id: "log-x", event: {}, createdAt: "not-a-date" } as unknown as TAuditLogs;
+
+ await SplunkProviderFactory().batchStreamLog({ credentials: CREDENTIALS, auditLogs: [auditLog] });
+
+ const [entry] = readConcatenatedJson(sentRequests[0].body);
+ expect(typeof entry.time).toBe("number");
+ expect(entry.time as number).toBeGreaterThanOrEqual(before);
+ });
+
test("falls back to the current time when the log carries no createdAt", async () => {
const before = Date.now() / 1000;
const auditLog = { id: "log-x", event: { type: "get-secrets" } } as unknown as TAuditLogs;