Initial curated EventLens source from 0d80d3b38dfb817285481665b9e71e4b8a0656a0

This commit is contained in:
Public Source Publisher committed 2026-10-01 01:30:24 +02:00
commit 663ea8c829
85 files changed
+12395

No files matched your search

+95
View File
@@ -0,0 +1,95 @@
import { describe, expect, it } from "vitest";
import { redactAnalysis } from "./redact";
import type { Analysis } from "./types";
const source: Analysis = {
source: "Security.evtx",
incidents: [{ id:"i1", rule_id:"windows.auth.failed-logon", start:"2026-09-09T10:00:00Z", end:"2026-09-09T10:00:01Z", title:"Failed login", category:"authentication", severity:"warning", reasons:["Connection from 192.168.1.15"], evidence_event_ids:["1"], original_count:1, compressed_count:1 }],
events: [{ id:"1", timestamp:"2026-09-09T10:00:00Z", provider:"Security", event_id:4625, level:"warning", category:"authentication", summary:"C:\\Users\\jens\\tool.exe contacted admin@example.com at 192.168.1.15", computer:"DEMO-PC", fields:{"EventData.TargetUserName":"jens","EventData.IpAddress":"10.0.0.5","EventData.ProcessName":"C:\\Windows\\System32\\cmd.exe"} }],
};
describe("redaction", () => {
it("redacts sensitive event values without mutating the source", () => {
const result = redactAnalysis(source);
const event = result.analysis.events[0];
expect(event.computer).toBe("[REDACTED_HOST]");
expect(event.fields?.["EventData.TargetUserName"]).toBe("[REDACTED_IDENTITY]");
expect(event.fields?.["EventData.IpAddress"]).toBe("[REDACTED_IP]");
expect(event.fields?.["EventData.ProcessName"]).toBe("[REDACTED_PATH]");
expect(event.summary).toContain("[REDACTED_EMAIL]");
expect(event.summary).toContain("[REDACTED_IP]");
expect(source.events[0].computer).toBe("DEMO-PC");
expect(result.summary.total).toBeGreaterThanOrEqual(6);
});
it("propagates identities and redacts Windows/UNC paths and IPv6 in free-form text", () => {
const sensitive: Analysis = {
source: "private.evtx",
incidents: [{
id: "incident-1",
rule_id: "windows.auth.failed-logon",
start: "2026-09-09T10:00:00Z",
end: "2026-09-09T10:00:01Z",
title: "Failed sign-in for jens",
category: "authentication",
severity: "warning",
reasons: ["jens used C:\\Program Files\\SecretTool\\agent.exe from 2001:db8::42"],
evidence_event_ids: ["1"],
original_count: 1,
compressed_count: 1,
}],
events: [{
id: "1",
timestamp: "2026-09-09T10:00:00Z",
provider: "Security",
event_id: 4625,
level: "warning",
category: "authentication",
summary: "Failed sign-in for DOMAIN\\jens at C:\\Program Files\\SecretTool\\agent.exe from 2001:db8::42, fe80::1 and ::ffff:192.0.2.1; SID S-1-5-21-123-456-789-1001; machine BUILD01$; UNC \\\\server\\Share With Space\\agent.exe",
computer: "DEMO-PC",
fields: {
"EventData.TargetUserName": "jens",
"EventData.SubjectUserName": "DOMAIN\\jens",
"EventData.ProcessName": "C:\\Program Files\\SecretTool\\agent.exe",
"EventData.UncPath": "\\\\server\\Share With Space\\agent.exe",
"EventData.MachineAccount": "DOMAIN\\BUILD01$",
"EventData.Sid": "S-1-5-21-123-456-789-1001",
},
}],
};
const result = redactAnalysis(sensitive);
const serialized = JSON.stringify(result.analysis);
expect(serialized).not.toContain("jens");
expect(serialized).not.toContain("Program Files\\SecretTool");
expect(serialized).not.toContain("Share With Space");
expect(serialized).not.toContain("2001:db8::42");
expect(serialized).not.toContain("fe80::1");
expect(serialized).not.toContain("192.0.2.1");
expect(serialized).not.toContain("BUILD01$");
expect(serialized).not.toContain("S-1-5-21");
expect(result.analysis.incidents[0].title).toContain("[REDACTED_IDENTITY]");
expect(result.summary.paths).toBeGreaterThan(0);
expect(result.summary.ips).toBeGreaterThanOrEqual(3);
});
it("propagates source-field values into free-form redaction", () => {
const sourceField: Analysis = {
source: "private.evtx",
incidents: [],
events: [{
id: "1",
timestamp: null,
provider: "Security",
event_id: 1,
level: "information",
category: "other",
summary: "Observed source Collector-A",
computer: "",
fields: { "EventData.SourceName": "Collector-A" },
}],
};
const result = redactAnalysis(sourceField);
expect(result.analysis.events[0].summary).toContain("[REDACTED_SOURCE]");
expect(result.summary.sources).toBeGreaterThan(1);
});
});