Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

fix(macho): recognize arm64_32 binaries

morlutoabbb1d7135fb
diff --git a/src/native/metadata/MachoImage.ts b/src/native/metadata/MachoImage.ts
index 3e3c41d07..7dd185862 100644
--- a/src/native/metadata/MachoImage.ts
+++ b/src/native/metadata/MachoImage.ts
@@ -156,6 +156,7 @@ export const readMachoImage = (bytes: Buffer): BinaryContainer => {
[0x01000007, "amd64"],
[12, "arm"],
[0x0100000c, "arm64"],
+ [0x0200000c, "arm64_32"],
[18, "ppc"],
[0x01000012, "ppc64"],
]);
diff --git a/tests/acceptance/rustBinaryCli.test.ts b/tests/acceptance/rustBinaryCli.test.ts
index b568065ac..eb8e1c07d 100644
--- a/tests/acceptance/rustBinaryCli.test.ts
+++ b/tests/acceptance/rustBinaryCli.test.ts
@@ -119,6 +119,39 @@ cliTest("returns null metadata when .dep-v0 is absent", async ({ cli }) => {
);
});
+cliTest(
+ "keeps arm64_32 in Rust CLI Evidence when dependency metadata is absent",
+ async ({ cli }) => {
+ const root = await createTestTempDirectory("rea-rust-arm64-32-");
+ const path = join(root, "watchos-object");
+ const bytes = createRustImage({
+ format: "macho",
+ omitSection: true,
+ includeRustc: false,
+ });
+ bytes.writeUInt32LE(0x0200000c, 4);
+ await writeFile(path, bytes);
+
+ const result = await cli.run({
+ arguments: ["inspect-rust-binary", path, "--json"],
+ });
+
+ expect(result.exitCode, result.stderr).toBe(0);
+ const evidence = toolContract("inspect_rust_binary").outputSchema.parse(
+ result.json,
+ );
+ expect(evidence.subject).toMatchObject({
+ format: "mach-o",
+ architecture: "arm64_32",
+ });
+ expect(rustBinarySchema.parse(evidence.normalized_result)).toMatchObject({
+ architecture: "arm64_32",
+ bits: 64,
+ auditable_metadata: null,
+ });
+ },
+);
+
cliTest(
"preserves an unknown cargo-auditable revision and reports its fallback",
async ({ cli }) => {
diff --git a/tests/boundary/rust/rustBinaryImage.test.ts b/tests/boundary/rust/rustBinaryImage.test.ts
index 4f94a4cbd..354ab2f72 100644
--- a/tests/boundary/rust/rustBinaryImage.test.ts
+++ b/tests/boundary/rust/rustBinaryImage.test.ts
@@ -70,6 +70,23 @@ it("reads a Mach-O __DATA,.dep-v0 section", () => {
});
});
+it("preserves the arm64_32 Mach-O CPU family when dependency metadata is absent", () => {
+ const bytes = createRustImage({
+ format: "macho",
+ omitSection: true,
+ includeRustc: false,
+ });
+ bytes.writeUInt32LE(0x0200000c, 4);
+
+ expect(readRustBinaryImage(bytes)).toMatchObject({
+ format: "macho",
+ architecture: "arm64_32",
+ bits: 64,
+ auditable_metadata: null,
+ rustc_commit: null,
+ });
+});
+
it("ignores PE file-alignment padding after the dependency content", () => {
const bytes = createRustImage({ format: "pe", includeRustc: false });
const payloadBytes = rustDependencyPayload().length;