fix(il2cpp): reject module image references outside retained inventory (#8956)

This commit is contained in:
Jiabin Yin authored and GitHub committed 2026-11-05 18:33:36 +08:00
1 parent 4362a0848e
commit da79ea0baa
3 files changed
+103

No files matched your search

@@ -482,6 +482,34 @@ const linkedReport = (): Il2cppMetadata => ({
parameter_types: [{ type: 0, name: "int" }],
});
it.each([-1, 1, 99])(
"rejects imported code-generation module image reference %i",
(image) => {
const value = linkedReport();
value.binary!.code_gen_modules[0]!.image = image;
const parsed = il2cppMetadataParentSchema.safeParse(value);
expect(parsed.success).toBe(false);
if (!parsed.success)
expect(parsed.error.issues).toEqual(
expect.arrayContaining([
expect.objectContaining({
path: ["binary", "code_gen_modules", 0, "image"],
}),
]),
);
for (const selection of [{}, { image_indices: [image] }]) {
const view = projectIl2cppMetadataView(parent(value, false), {
kind: "il2cpp-metadata",
collection: "code_gen_modules",
...selection,
offset: 0,
limit: 64,
});
expect(view.ok).toBe(false);
}
},
);
it("selects every folded method by numeric address with stable indices and both source identities", () => {
const source = parent(freezeJsonSnapshot(linkedReport()), true);
const view = projectIl2cppMetadataView(source, {