mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 11:43:20 +00:00
* feat(snapshots)!: persist the target identity as the snapshot target
The snapshot target is now `{ kind, identity }`, where `identity` is the
FileTargetIdentity that `binaryTargetIdentity` produces and `kind` is the
binary kind query IDs commit to. The per-format target projection and
`snapshotTargetIdentity` are deleted; the schema checks the format's
selection, architecture and kind instead of keeping one union arm per format.
Entry execution subjects use the Evidence subject shape (file or explicit
unknown), so a snapshot entry commits to the same identity, including the
selection, as its Evidence record. Workflow entries take the subject of the
workflow's own Evidence. Replay no longer re-derives the selection from the
open target.
`FileTargetSelection` gains `universal-slice` (`offset`, `size`, and the FAT
`cpu_type`/`cpu_subtype` when target admission supplied the FAT table, else
null). `binaryTargetIdentity` produces it for `mach-o-universal` targets, so
Evidence and snapshots for different slices of one container no longer share
an identity.
Refs #11417
BREAKING CHANGE: analysis snapshot files change shape: `target` is
`{ kind, identity: { kind: "file", sha256, format, architecture, selection } }`
and entry `execution.subject` is the Evidence subject
(`{ identity, name, local_path }`, never null). Snapshot binding mismatch
details report `target.snapshot`/`target.selected` in the same shape. Evidence
IDs of universal Mach-O targets change because their subject identity now
carries the selected slice. Recreate saved snapshots and Evidence bundles of
universal Mach-O targets.
* docs(evidence): name the universal Mach-O slice selection in the subject contract
* fix(snapshots): read the snapshot target identity in the Ghidra verification scripts
The real Ghidra snapshot checks (lifecycle, RISC-V, MIPS, PowerPC) read
snapshot.target.sha256 and .architecture, which moved under
snapshot.target.identity, so they would fail after saving a valid snapshot.
* feat(evidence)!: name live browser page Evidence by its page URL (#11559)
Browser page observations (inspect_web_page, analyze_web_bundle,
observe_web_session, discover_webmcp_tools, capture_web_screenshot,
observe_web_execution, inspect_web_event_listeners) named an unknown
(`not-observed`) subject although the provider reports the page URL.
`TargetIdentity` gains a `url` kind: the reported URL with userinfo removed
and its origin (`null` for an opaque origin). The schema refuses a URL that
carries userinfo or an origin the URL does not have.
`browserUrlTargetIdentity` in the browser URL owner builds it from the
provider's reported URL; a withheld or unparseable URL stays unknown
(`not-observed`). Target lists and comparisons still name no single
document. Analysis views keep their parent's URL subject, as they already
keep a file subject.
BREAKING CHANGE: Evidence IDs of live browser page observations and their
analysis views change, and their subject is
`{ "kind": "url", "url", "origin" }` with `name` and `local_path` null.
Recreate stored Evidence for these tools. This lands inside Evidence format
revision 2 under the release hold (#11417); no `evidence_format` bump.
148 lines
4.1 KiB
TypeScript
148 lines
4.1 KiB
TypeScript
import { fileIdentity } from "../../fixtures/evidenceSubject.js";
|
|
import { expect, it } from "vitest";
|
|
import type { BinaryTarget } from "../../../src/domain/binaryTargetTypes.js";
|
|
import { createAnalysisProfile } from "../../../src/domain/analysisProfile.js";
|
|
import { createEvidence, parseEvidence } from "../../../src/domain/evidence.js";
|
|
import { createEvidenceBundle } from "../../../src/domain/evidenceBundle.js";
|
|
import {
|
|
createAnalysisSnapshotEntry,
|
|
parseAnalysisSnapshot,
|
|
serializeAnalysisSnapshot,
|
|
snapshotBinding,
|
|
snapshotTarget,
|
|
snapshotMatchesProfile,
|
|
} from "../../../src/domain/analysisSnapshot.js";
|
|
import { sessionOutputSchemas } from "../../../src/contracts/toolOutputSchemaGroups.js";
|
|
|
|
const provider = { id: "ghidra", name: "Ghidra", version: "12.1.4" };
|
|
const commonTarget = {
|
|
path: "/source-owned.elf",
|
|
sha256: "a".repeat(64),
|
|
kind: "executable",
|
|
format: "elf",
|
|
} as const;
|
|
const cases = [
|
|
{
|
|
architecture: "mips",
|
|
target: {
|
|
...commonTarget,
|
|
architecture: "mips",
|
|
availableArchitectures: ["mips"],
|
|
mips: { elfClass: 32, byteOrder: "little", type: 2, flags: 0x70001001 },
|
|
},
|
|
profile: {
|
|
mips_elf: {
|
|
elf_class: 32,
|
|
byte_order: "little",
|
|
type: 2,
|
|
flags: 0x70001001,
|
|
},
|
|
},
|
|
changed: {
|
|
mips_elf: {
|
|
elf_class: 32,
|
|
byte_order: "big",
|
|
type: 2,
|
|
flags: 0x70001001,
|
|
},
|
|
},
|
|
observation: { address: "0x20150", value: "rea_mips_entry" },
|
|
},
|
|
{
|
|
architecture: "powerpc",
|
|
target: {
|
|
...commonTarget,
|
|
architecture: "powerpc",
|
|
availableArchitectures: ["powerpc"],
|
|
powerpc: { elfClass: 32, byteOrder: "big", type: 2, flags: 0 },
|
|
},
|
|
profile: {
|
|
powerpc_elf: { elf_class: 32, byte_order: "big", type: 2, flags: 0 },
|
|
},
|
|
changed: {
|
|
powerpc_elf: {
|
|
elf_class: 32,
|
|
byte_order: "big",
|
|
type: 2,
|
|
flags: 0x00010000,
|
|
},
|
|
},
|
|
observation: { address: "0x100101b0", value: "rea_ppc_entry" },
|
|
},
|
|
] as const satisfies readonly {
|
|
architecture: string;
|
|
target: BinaryTarget;
|
|
profile: object;
|
|
changed: object;
|
|
observation: { address: string; value: string };
|
|
}[];
|
|
|
|
it.each(cases)(
|
|
"round-trips $architecture identity through Evidence and snapshots",
|
|
({
|
|
architecture,
|
|
target,
|
|
observation,
|
|
profile: facts,
|
|
changed: changedFacts,
|
|
}) => {
|
|
const result = [observation];
|
|
const profile = createAnalysisProfile(provider, facts);
|
|
const parameters = {};
|
|
const evidence = createEvidence(target, provider, {
|
|
operation: "list_procedures",
|
|
parameters,
|
|
result,
|
|
analysisProfile: profile,
|
|
});
|
|
const binding = snapshotBinding(profile);
|
|
const entry = createAnalysisSnapshotEntry({
|
|
target: snapshotTarget(target),
|
|
binding,
|
|
operation: "list_procedures",
|
|
parameters,
|
|
execution: {
|
|
result,
|
|
rawResult: null,
|
|
provider,
|
|
analysisProfile: profile,
|
|
limitations: [],
|
|
locations: [],
|
|
subject: evidence.subject,
|
|
},
|
|
});
|
|
const snapshot = {
|
|
target: snapshotTarget(target),
|
|
binding,
|
|
entries: [entry],
|
|
workflow_entries: [],
|
|
evidence_bundle: createEvidenceBundle([evidence]),
|
|
};
|
|
const restored = parseAnalysisSnapshot(
|
|
JSON.parse(serializeAnalysisSnapshot(snapshot)),
|
|
);
|
|
expect(restored.target.identity.architecture).toBe(architecture);
|
|
expect(
|
|
fileIdentity(restored.evidence_bundle.records[0]?.subject).architecture,
|
|
).toBe(architecture);
|
|
expect(
|
|
fileIdentity(restored.entries[0]?.execution.subject).architecture,
|
|
).toBe(architecture);
|
|
expect(
|
|
sessionOutputSchemas.open_binary.parse({ result: target }).result
|
|
.architecture,
|
|
).toBe(architecture);
|
|
expect(() =>
|
|
parseEvidence({
|
|
...evidence,
|
|
subject: {
|
|
...evidence.subject,
|
|
identity: { ...evidence.subject.identity, architecture: "x86" },
|
|
},
|
|
}),
|
|
).toThrow("semantic identifier");
|
|
const changed = createAnalysisProfile(provider, changedFacts);
|
|
expect(snapshotMatchesProfile(binding, changed)).toBe(false);
|
|
},
|
|
);
|