mirror of
https://github.com/morluto/rea.git
synced 2026-11-18 04:34:13 +00:00
feat(analysis): make resource budgets recoverable across CLI and MCP (#9706)
* refactor(analysis): centralize resource budgets and recovery facts * feat(analysis): expose ASAR and Ghidra runtime admission controls * feat(artifacts): expose reader admission and preserve limited recognition * feat(javascript): expose recoverable semantic precision budgets * feat(web): add recoverable source-map budgets and compact retained views * feat(web): make historical capture decoding budgets recoverable * fix(desktop): enforce selected view policies across capture and export * feat(runtime): make Frida and LLDB retention budgets selectable * feat(native): expose diagnostic budgets and preserve exhaustion causes * feat(managed): expose recoverable snapshot and representation budgets * feat(metadata): make Go and Rust inspection budgets recoverable * feat(wasm): expose representation and producer admissions * feat(evm): expose per-call worker resource budgets * feat(android): make resource and string-pool omissions recoverable * feat(producers): expose command and recorded-capture budgets * docs(analysis): record recovery contracts and integrated validation * fix(docs): link calibration oracle from published verification pages * fix(docs): restore desktop task anchors and receipt links * test(analysis): align fixtures with selectable budget contracts * fix(analysis): remove source-location projector dependency cycle * test(analysis): refresh budget recovery and verifier regressions * test(analysis): preserve format and publication recovery expectations * test(windows): align conformance with owned runtime admission * fix(desktop): preserve selected alias kinds in exported state * test(analysis): align provider fixtures with recoverable budgets * test(desktop): validate emitted alias metadata structurally * fix(ghidra): classify bounded Windows endpoint refusals * test(cli): assert selectable artifact admission recovery * fix(cli): preserve capture provenance in environment builds
This commit is contained in:
1 parent
55b6d2ca20
commit
cb4e5cfbff
515 files changed
+21066
-3637
No files matched your search
@@ -171,32 +171,24 @@ it("keeps earlier .modinfo entries when the last span is unterminated", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("reports a missing separator, an empty key, and an over-long field per entry", () => {
|
||||
it("reports a missing separator and an empty key as malformed entries", () => {
|
||||
const report = parse(
|
||||
kernelModuleFixture({
|
||||
modinfo: Buffer.concat([
|
||||
Buffer.from("license\0=GPL\0", "latin1"),
|
||||
Buffer.from(`${"k".repeat(257)}=x\0`, "latin1"),
|
||||
Buffer.from(`name=${"v".repeat(4097)}\0`, "latin1"),
|
||||
]),
|
||||
modinfo: Buffer.from("license\0=GPL\0", "latin1"),
|
||||
}),
|
||||
);
|
||||
expect(report.modinfo?.entries.map((entry) => entry.reason)).toEqual([
|
||||
"modinfo_missing_separator",
|
||||
"modinfo_empty_key",
|
||||
"modinfo_field_exceeds_limit",
|
||||
"modinfo_field_exceeds_limit",
|
||||
]);
|
||||
expect(report.coverage.status).toBe("partial");
|
||||
expect(report.modinfo?.entries[1]).toMatchObject({
|
||||
key: null,
|
||||
value: "GPL",
|
||||
});
|
||||
expect(report.modinfo?.entries[2]).toMatchObject({ key: null, value: "x" });
|
||||
expect(report.modinfo?.entries[3]).toMatchObject({
|
||||
key: "name",
|
||||
value: null,
|
||||
});
|
||||
expect(
|
||||
report.modinfo?.entries.every((entry) => entry.status === "malformed"),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("closes __versions when the section size is not a multiple of 64", () => {
|
||||
|
||||
@@ -4,10 +4,11 @@ import { ArtifactReaderFailure } from "../../artifacts/ArtifactReader.js";
|
||||
import { elfObjectTypeName } from "../../domain/native/elfNotes.js";
|
||||
import {
|
||||
KERNEL_MODULE_VERSION_ENTRY_BYTES,
|
||||
MAX_KERNEL_MODULE_KEY_BYTES,
|
||||
DEFAULT_KERNEL_MODULE_KEY_BYTES,
|
||||
MAX_KERNEL_MODULE_RAW_BYTES,
|
||||
MAX_KERNEL_MODULE_SECTION_NAME_BYTES,
|
||||
MAX_KERNEL_MODULE_VALUE_BYTES,
|
||||
DEFAULT_KERNEL_MODULE_VALUE_BYTES,
|
||||
MAX_INSPECT_KERNEL_MODULE_FILE_BYTES,
|
||||
MODULE_SIGNATURE_INFO_BYTES,
|
||||
MODULE_SIGNATURE_MAGIC,
|
||||
MODULE_SIGNATURE_PKCS7_ID_TYPE,
|
||||
@@ -164,7 +165,7 @@ const parseModinfo = (
|
||||
section: ElfSection | undefined,
|
||||
use: SectionUse,
|
||||
examined: { count: number },
|
||||
maxEntries: number,
|
||||
input: InspectKernelModuleInput,
|
||||
): NonNullable<Report["modinfo"]> => {
|
||||
if (section === undefined)
|
||||
return {
|
||||
@@ -196,6 +197,8 @@ const parseModinfo = (
|
||||
reason: "modinfo_section_compressed",
|
||||
};
|
||||
const entries: NonNullable<Report["modinfo"]>["entries"] = [];
|
||||
let largestKeyBytes = 0;
|
||||
let largestValueBytes = 0;
|
||||
let at = 0;
|
||||
while (at < stored.length) {
|
||||
if (stored[at] === 0) {
|
||||
@@ -208,25 +211,27 @@ const parseModinfo = (
|
||||
const record = stored.subarray(at, stop);
|
||||
const raw = stored.subarray(at, terminated ? end + 1 : stored.length);
|
||||
examined.count += 1;
|
||||
exceeds(examined.count, maxEntries);
|
||||
exceeds(examined.count, input.max_entries);
|
||||
const separator = record.indexOf(0x3d);
|
||||
let key: string | null = null;
|
||||
let value: string | null = null;
|
||||
const omittedFields: Array<"key" | "value"> = [];
|
||||
let reason: NonNullable<Report["modinfo"]>["entries"][number]["reason"] =
|
||||
terminated ? null : "unterminated_modinfo_entry";
|
||||
if (separator < 0) reason ??= "modinfo_missing_separator";
|
||||
else {
|
||||
const keyBytes = record.subarray(0, separator);
|
||||
const valueBytes = record.subarray(separator + 1);
|
||||
largestKeyBytes = Math.max(largestKeyBytes, keyBytes.length);
|
||||
largestValueBytes = Math.max(largestValueBytes, valueBytes.length);
|
||||
if (keyBytes.length === 0) reason ??= "modinfo_empty_key";
|
||||
if (
|
||||
keyBytes.length > MAX_KERNEL_MODULE_KEY_BYTES ||
|
||||
valueBytes.length > MAX_KERNEL_MODULE_VALUE_BYTES
|
||||
)
|
||||
reason ??= "modinfo_field_exceeds_limit";
|
||||
if (keyBytes.length > 0 && keyBytes.length <= MAX_KERNEL_MODULE_KEY_BYTES)
|
||||
if (keyBytes.length > input.max_modinfo_key_bytes)
|
||||
omittedFields.push("key");
|
||||
if (valueBytes.length > input.max_modinfo_value_bytes)
|
||||
omittedFields.push("value");
|
||||
if (keyBytes.length > 0 && keyBytes.length <= input.max_modinfo_key_bytes)
|
||||
key = keyBytes.toString("latin1");
|
||||
if (valueBytes.length <= MAX_KERNEL_MODULE_VALUE_BYTES)
|
||||
if (valueBytes.length <= input.max_modinfo_value_bytes)
|
||||
value = valueBytes.toString("latin1");
|
||||
}
|
||||
entries.push({
|
||||
@@ -241,10 +246,30 @@ const parseModinfo = (
|
||||
raw_hex: rawHex(raw),
|
||||
status: reason === null ? "observed" : "malformed",
|
||||
reason,
|
||||
omitted_fields: omittedFields,
|
||||
});
|
||||
if (!terminated) break;
|
||||
at = end + 1;
|
||||
}
|
||||
for (const [field, selected, required, defaultBytes] of [
|
||||
[
|
||||
"key",
|
||||
input.max_modinfo_key_bytes,
|
||||
largestKeyBytes,
|
||||
DEFAULT_KERNEL_MODULE_KEY_BYTES,
|
||||
],
|
||||
[
|
||||
"value",
|
||||
input.max_modinfo_value_bytes,
|
||||
largestValueBytes,
|
||||
DEFAULT_KERNEL_MODULE_VALUE_BYTES,
|
||||
],
|
||||
] as const) {
|
||||
if (required > selected)
|
||||
use.limitations.push(
|
||||
`.modinfo ${field} text exceeds max_modinfo_${field}_bytes=${String(selected)} bytes (request budget; default ${String(defaultBytes)}, minimum 1, maximum ${String(MAX_INSPECT_KERNEL_MODULE_FILE_BYTES)}). Omitted fields keep their source range and digest; omission does not establish malformed syntax. Retry inspect_kernel_module with max_modinfo_${field}_bytes at least ${String(required)}, or --max-modinfo-${field}-bytes on the CLI. Applies on the next call without a REA restart; input, entry and raw-hex budgets do not change.`,
|
||||
);
|
||||
}
|
||||
return {
|
||||
status: "present",
|
||||
location,
|
||||
@@ -532,7 +557,7 @@ export const parseKernelModule = (
|
||||
firstNamedSection(".modinfo"),
|
||||
use,
|
||||
examined,
|
||||
input.max_entries,
|
||||
input,
|
||||
);
|
||||
const versions = parseVersions(
|
||||
bytes,
|
||||
@@ -611,6 +636,7 @@ export const parseKernelModule = (
|
||||
unbacked > 0 ||
|
||||
ksymtab.some((section) => section.reason !== null) ||
|
||||
sectionIncomplete(modinfo) ||
|
||||
modinfo.entries.some((entry) => entry.omitted_fields.length > 0) ||
|
||||
sectionIncomplete(versions) ||
|
||||
modulePresence.status === "unsupported" ||
|
||||
(modulePresence.status === "present" && modulePresence.location === null) ||
|
||||
|
||||
Reference in new issue
Block a user