mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 19:53:50 +00:00
* feat(evidence)!: give Evidence bundles a format revision owned by one module `src/domain/evidenceFormat.ts` owns Evidence format evolution. Bundles now carry `evidence_format: 1`; every bundle reader admits only the current revision and refuses an unmarked or other-revision bundle once, with the single recreate-observations guidance, instead of admitting earlier shapes one optional field at a time. The 6.7-era artifact inventory summary identities are no longer rebuilt: compare_artifacts checks the current projection only and reports a mismatch with the owner's guidance. The pre-6.6 identity diagnosis uses the same guidance. SQLite `worker_timeout_ms` and Dart AOT `string_pool.policy`, optional only for historical Evidence, are now required. BREAKING CHANGE: Evidence bundles written by REA 6.x (no `evidence_format`) are refused by import, comparison, reconstruction and analysis-snapshot readers as an integrity mismatch telling the caller to recreate the observations; re-exporting an earlier bundle does not update its format or identities. Bundles constructed by hand must include `"evidence_format": 1`. 6.7-era artifact summaries are refused by compare_artifacts, and SQLite and Dart AOT Evidence without the newly required fields fails validation. * fix(evidence): let the ledger application admit its bundle's format build_reconstruction_obligation_ledger registered the full bundle schema with the SDK, so an unmarked or other-revision bundle was refused as invalid_request before the format owner ran. Register it like coverage: the application parses the request envelope and admits the bundle. * feat(pcap)!: read capture Evidence through the current result schema only (#10879) Delete the pcap read-compatibility schema that defaulted executable identity for historical capture Evidence, and require query_labels_hex (null when unknown) now that every producer writes it. Evidence from an earlier format is refused at the bundle format owner; a record that omits these fields is reported as malformed instead of defaulted. BREAKING CHANGE: inspect_pcap_capture results always carry query_labels_hex, and analysis views no longer default missing tshark/capinfos identity fields. * feat(desktop)!: require the effective view policy in desktop state Evidence (#10886) inspect_desktop_application_state always records the complete policy it used, including sqlite_view_bytes. Drop the optional historical shape and the task draft's absent-policy branch. BREAKING CHANGE: desktop application state results without effective_view_policy, or with a policy missing sqlite_view_bytes, are refused as malformed. * feat(android)!: require component declaration facets and reference aggregates in Android Evidence (#10904) * feat(android)!: require component declaration facets and reference aggregates in Android Evidence The JADX producers always write the manifest component projection with every declaration facet, target_definition and direct_invokes_coverage. Require them, delete the duplicate observed component schema, drop the unknown declaration coverage that only described historical omission, and give manifest view results their explicit facet. BREAKING CHANGE: Android package, component and reference results missing these fields are refused as malformed; component declaration_coverage and its summary counts no longer include unknown; manifest view results always carry facet manifest. * refactor(android): parse package results with the domain schema directly * feat(browser)!: require the DOM length unit and redirect-scoped prior-hop facts (#10897) * feat(browser)!: require the DOM length unit and redirect-scoped prior-hop facts Both CDP producers always declare node_value_length_unit, and the observation session writes redirect_response on every redirect event and no other. Require the unit, drop the diff's absent-unit branch, and admit redirect_response exactly on redirect rows. BREAKING CHANGE: DOM snapshots without node_value_length_unit and redirect timeline rows without redirect_response are refused as malformed, including inline inspections passed to compare_web_captures. * docs(browser): drop the historical redirect_response omission note * feat(native)!: require native Evidence fields that were optional only for historical Evidence (#10946) Mach-O encryption, slice malformed cause, symbol runtime names and import facts; ELF export encoding facts and visibility; value-flow limits; load-image permissions and relocation symbols; Swift type-reference kind and GPU AMD target metadata are required. Legacy enum values (unrecorded, unknown visibility, undecodable, modinfo_field_exceeds_limit) and the retained schemas, view defaults and reinterpretations that served historical Evidence are deleted. BREAKING CHANGE: native records missing these fields are refused as malformed; recreate the observation.
223 lines
6.5 KiB
TypeScript
223 lines
6.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
analyzeJadxRequest,
|
|
type JadxToolPort,
|
|
} from "../../../src/android/JadxAnalysis.js";
|
|
import { androidResultSchemas } from "../../../src/domain/android/androidAnalysis.js";
|
|
|
|
const engine = {
|
|
name: "jadx",
|
|
version: "0.7.1",
|
|
artifact_sha256: "a".repeat(64),
|
|
source_revision: null,
|
|
worker_count: 1,
|
|
heap_limit_mib: null,
|
|
};
|
|
const selector = {
|
|
class_name: "fixture.Caller",
|
|
method_name: "notify0",
|
|
overload_index: 0,
|
|
};
|
|
const summary = {
|
|
class_name: "android.app.NotificationManager",
|
|
reference_target: "external",
|
|
observed_method_count: 1,
|
|
prototypes: [
|
|
{
|
|
name: "notify",
|
|
raw_name: "notify",
|
|
signature: "notify(int, android.app.Notification): void",
|
|
dex_descriptor: "(ILandroid/app/Notification;)V",
|
|
is_constructor: false,
|
|
def_pos: 0,
|
|
},
|
|
],
|
|
};
|
|
const xrefs = {
|
|
target: "android.app.NotificationManager.notify",
|
|
reference_target: "external",
|
|
reference_scope: "direct_dex_invokes",
|
|
overload_index: 0,
|
|
reported_signature: summary.prototypes[0]!.signature,
|
|
dex_descriptor: summary.prototypes[0]!.dex_descriptor,
|
|
total: 1,
|
|
count: 1,
|
|
resolve_line: false,
|
|
items: [
|
|
{
|
|
kind: "method",
|
|
name: selector.method_name,
|
|
full_name: "fixture.Caller.notify0",
|
|
containing_class: selector.class_name,
|
|
top_class: selector.class_name,
|
|
def_pos: 0,
|
|
source_selector: selector,
|
|
direct_invokes_exhaustive: true,
|
|
direct_invokes: [0, 3].map((offset) => ({
|
|
dex_entry: "classes2.dex",
|
|
source_raw_method_id:
|
|
"fixture.Caller.notify0(Landroid/app/NotificationManager;Landroid/app/Notification;)V",
|
|
dex_code_unit_offset: offset,
|
|
dex_method_index: 5,
|
|
opcode: "INVOKE_VIRTUAL",
|
|
})),
|
|
},
|
|
],
|
|
};
|
|
|
|
const analyze = (
|
|
target = summary,
|
|
references = xrefs,
|
|
operation:
|
|
| "trace_android_references"
|
|
| "inspect_android_class" = "trace_android_references",
|
|
) => {
|
|
const tools: JadxToolPort = {
|
|
listClasses: () => Promise.reject(new Error("unexpected class inventory")),
|
|
text: () => Promise.reject(new Error("unexpected source generation")),
|
|
json: (name) =>
|
|
Promise.resolve(name === "get_class_summary" ? target : references),
|
|
};
|
|
return analyzeJadxRequest(
|
|
tools,
|
|
{
|
|
operation,
|
|
input: {
|
|
path: "/fixture.apk",
|
|
class_name: summary.class_name,
|
|
...(operation === "trace_android_references"
|
|
? { method_name: "notify" }
|
|
: {}),
|
|
},
|
|
},
|
|
{ loaded: {} as never, engine },
|
|
);
|
|
};
|
|
|
|
describe("external DEX method-reference projection", () => {
|
|
it("separates partial instruction positions from complete caller coverage", async () => {
|
|
const bounded = structuredClone(xrefs);
|
|
bounded.items[0]!.direct_invokes_exhaustive = false;
|
|
bounded.items[0]!.direct_invokes = bounded.items[0]!.direct_invokes.slice(
|
|
0,
|
|
1,
|
|
);
|
|
expect(await analyze(summary, bounded)).toMatchObject({
|
|
total: 1,
|
|
coverage: "complete",
|
|
reference_unit: "using_node",
|
|
direct_invokes_coverage: {
|
|
complete_using_nodes: 0,
|
|
partial_using_nodes: 1,
|
|
unknown_using_nodes: 0,
|
|
recorded_sites: 1,
|
|
},
|
|
});
|
|
});
|
|
|
|
it("counts complete positions and refuses results without the aggregate or target definition", async () => {
|
|
const result = androidResultSchemas.trace_android_references.parse(
|
|
await analyze(),
|
|
);
|
|
expect(result.direct_invokes_coverage).toEqual({
|
|
complete_using_nodes: 1,
|
|
partial_using_nodes: 0,
|
|
unknown_using_nodes: 0,
|
|
recorded_sites: 2,
|
|
});
|
|
for (const field of [
|
|
"direct_invokes_coverage",
|
|
"target_definition",
|
|
] as const) {
|
|
const { [field]: _omitted, ...unrecorded } = result;
|
|
expect(
|
|
androidResultSchemas.trace_android_references.safeParse(unrecorded)
|
|
.error?.issues,
|
|
).toEqual([expect.objectContaining({ path: [field] })]);
|
|
}
|
|
});
|
|
|
|
it("lists exact observed DEX descriptors when an external overload is ambiguous", async () => {
|
|
const descriptors = [
|
|
"(ILandroid/app/Notification;)V",
|
|
"(Ljava/lang/String;ILandroid/app/Notification;)V",
|
|
];
|
|
const ambiguous = {
|
|
...summary,
|
|
observed_method_count: 2,
|
|
prototypes: descriptors.map((dex_descriptor) => ({
|
|
...summary.prototypes[0]!,
|
|
dex_descriptor,
|
|
})),
|
|
};
|
|
const failure = analyze(ambiguous);
|
|
await expect(failure).rejects.toMatchObject({
|
|
_tag: "AnalysisInputError",
|
|
issues: [
|
|
{
|
|
path: ["overload_index"],
|
|
reason: "invalid_value",
|
|
},
|
|
],
|
|
});
|
|
for (const descriptor of descriptors)
|
|
await expect(failure).rejects.toMatchObject({
|
|
issues: [{ message: expect.stringContaining(descriptor) }],
|
|
});
|
|
for (const index of descriptors.keys())
|
|
await expect(failure).rejects.toMatchObject({
|
|
issues: [
|
|
{ message: expect.stringMatching(new RegExp(`\\b${index}\\b`, "u")) },
|
|
],
|
|
});
|
|
await expect(failure).rejects.toMatchObject({
|
|
issues: [
|
|
{ message: expect.stringContaining(summary.prototypes[0]!.signature) },
|
|
],
|
|
});
|
|
});
|
|
|
|
it("retains an external target, direct-only scope and an inspectable caller", async () => {
|
|
const result = androidResultSchemas.trace_android_references.parse(
|
|
await analyze(),
|
|
);
|
|
expect(result).toMatchObject({
|
|
target_definition: "external",
|
|
reference_scope: "direct_dex_invokes",
|
|
class_name: summary.class_name,
|
|
dex_descriptor: summary.prototypes[0]!.dex_descriptor,
|
|
total: 1,
|
|
reference_unit: "using_node",
|
|
references: [{ source_selector: selector }],
|
|
});
|
|
expect(
|
|
result.references[0]!.direct_invokes?.map(
|
|
(site) => site.dex_code_unit_offset,
|
|
),
|
|
).toEqual([0, 3]);
|
|
});
|
|
|
|
it.each([
|
|
{ name: "prototype", changed: { dex_descriptor: "()V" } },
|
|
{ name: "definition", changed: { reference_target: undefined } },
|
|
{ name: "scope", changed: { reference_scope: undefined } },
|
|
{
|
|
name: "caller selector",
|
|
changed: { items: [{ ...xrefs.items[0]!, source_selector: undefined }] },
|
|
},
|
|
])(
|
|
"refuses a changed external $name instead of reporting coverage",
|
|
async ({ changed }) => {
|
|
await expect(
|
|
analyze(summary, { ...xrefs, ...changed } as typeof xrefs),
|
|
).rejects.toThrow();
|
|
},
|
|
);
|
|
|
|
it("does not accept reference-only metadata as an APK class definition", async () => {
|
|
await expect(
|
|
analyze(summary, xrefs, "inspect_android_class"),
|
|
).rejects.toThrow();
|
|
});
|
|
});
|