mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
* feat(evtx): page event records with offset and report page facts
inspect_evtx_archive stopped walking at max_records, so records past the first 20,000 (the newest events of a default-size Application log) could not be listed. The walk now covers every record. max_records stays a 20,000-record page bound, which limits retained Evidence. A new zero-based offset selects the first record listed. The result reports page { offset, limit, returned, total, next_offset }, and the record-limit-reached diagnostic names offset=next_offset. Coverage now describes parse loss only, so a page that leaves records out by selection is no longer partial, and chunk ending facts and endpoint checks cover records past the page.
Fixes #15612
* feat(evtx)!: qualify the file-tail offset for small and wrapped logs
The suggested tail offset is now the larger of 0 and page.total minus max_records, so a log smaller than one page gets a valid offset. File order is oldest first only in a log that has not wrapped; the guide and descriptions now say how chunks[] locates the newest records in a wrapped log.
BREAKING CHANGE: inspect_evtx_archive results now require page. Evidence saved before this change has no page, and inspect_analysis_view refuses to summarise it. Re-run inspect_evtx_archive on the log to produce current Evidence.
97 lines
3.4 KiB
TypeScript
97 lines
3.4 KiB
TypeScript
import { writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { expect } from "vitest";
|
|
import { readEvidenceBundle } from "../../src/application/EvidenceBundleFiles.js";
|
|
import { artifactInspectionResultSchema } from "../../src/domain/artifactInspection.js";
|
|
import { parseEvidence } from "../../src/domain/evidence.js";
|
|
import { analysisViewResultSchema } from "../../src/domain/analysisView/analysisViewResult.js";
|
|
import { evtxArchiveSchema } from "../../src/domain/evtxArchive/evtxArchive.js";
|
|
import { evtxLog } from "../fixtures/evtxLog.js";
|
|
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../support/cli/cliFixture.js";
|
|
|
|
cliTest(
|
|
"publishes a selected EVTX page as a summary with its page facts and full parent Evidence",
|
|
async ({ cli }) => {
|
|
const root = await createTestTempDirectory("rea-evtx-summary-");
|
|
const bytes = evtxLog(3);
|
|
const path = join(root, "input.evtx");
|
|
const output = join(root, "evidence.json");
|
|
await writeFile(path, bytes);
|
|
const initial = await cli.run({
|
|
arguments: ["inspect-artifact", path, "--json"],
|
|
});
|
|
expect(initial.exitCode, initial.stderr).toBe(0);
|
|
const inspection = artifactInspectionResultSchema.parse(
|
|
parseEvidence(initial.json).normalized_result,
|
|
);
|
|
expect(inspection.subject.root_format).toBe("evtx");
|
|
expect(inspection.next_probes).toContainEqual(
|
|
expect.objectContaining({
|
|
operation: "inspect_evtx_archive",
|
|
authority: "artifact-bytes",
|
|
}),
|
|
);
|
|
const result = await cli.run({
|
|
arguments: [
|
|
"inspect-evtx-archive",
|
|
"./input.evtx",
|
|
"--offset",
|
|
"1",
|
|
"--max-records",
|
|
"1",
|
|
"--detail",
|
|
"summary",
|
|
"--evidence_output",
|
|
output,
|
|
"--json",
|
|
],
|
|
cwd: root,
|
|
});
|
|
expect(result.exitCode, result.stderr).toBe(0);
|
|
const summaryEvidence = parseEvidence(
|
|
(result.json as { summary: unknown }).summary,
|
|
);
|
|
const summary = analysisViewResultSchema.parse(
|
|
summaryEvidence.normalized_result,
|
|
);
|
|
const saved = await readEvidenceBundle(output);
|
|
if (!saved.ok) throw saved.error;
|
|
const parent = saved.value.records.find(
|
|
(record) => record.operation === "inspect_evtx_archive",
|
|
);
|
|
expect(parent).toBeDefined();
|
|
if (parent === undefined)
|
|
throw new Error("Missing complete parent Evidence");
|
|
const report = evtxArchiveSchema.parse(parent.normalized_result);
|
|
expect(parent.caller_input_path).toBe("./input.evtx");
|
|
expect(
|
|
report.events.map((event) => [event.ordinal, event.event_record_id]),
|
|
).toEqual([[1, "2"]]);
|
|
expect(report.page).toEqual({
|
|
offset: 1,
|
|
limit: 1,
|
|
returned: 1,
|
|
total: 3,
|
|
next_offset: 2,
|
|
});
|
|
// The page omits records by selection, not by parse loss.
|
|
expect(report.source_coverage.status).toBe("complete-within-scope");
|
|
expect(summary).toMatchObject({
|
|
kind: "summary",
|
|
parent_evidence_id: parent.evidence_id,
|
|
parent_digest: parent.evidence_id.slice(3),
|
|
parent_operation: "inspect_evtx_archive",
|
|
summary: {
|
|
artifact: report.artifact,
|
|
page: report.page,
|
|
summary: report.summary,
|
|
source_coverage: report.source_coverage,
|
|
},
|
|
});
|
|
expect(summary.kind).toBe("summary");
|
|
if (summary.kind === "summary")
|
|
expect(summary.summary).not.toHaveProperty("events");
|
|
},
|
|
);
|