Skip to content

armgit / rea

Public Imported from GitHub
0

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

1.2 KB
Raw Blame
import { expect, it } from "vitest";

import { NativeMacOSProvider } from "../../../../src/native/NativeMacOSProvider.js";
import {
  NativeFixtureRunner,
  nativeFixture,
  nativeMachoTarget,
  withOtoolMachHeader,
} from "../../../fixtures/nativeCommands.js";

it("retains native re-export dependencies alongside ordinary and identity commands", async () => {
  const runner = new NativeFixtureRunner({
    otool: withOtoolMachHeader(
      await nativeFixture("native-reexport/otool-load.txt"),
    ),
  });
  const client = new NativeMacOSProvider({}, runner, "darwin").createClient(
    nativeMachoTarget("/owned/libOuter.dylib"),
  );
  const result = await client.execute("inspect_macho", {});
  if (!result.ok) throw result.error;
  expect(result.value.result).toMatchObject({
    dependencies: {
      exhaustive: true,
      total: 2,
      items: [
        expect.objectContaining({
          kind: "LC_REEXPORT_DYLIB",
          path: "@rpath/libLeaf.dylib",
        }),
        expect.objectContaining({
          kind: "LC_LOAD_DYLIB",
          path: "/usr/lib/libSystem.B.dylib",
        }),
      ],
    },
    load_commands: {
      items: expect.arrayContaining([
        expect.objectContaining({ kind: "LC_ID_DYLIB" }),
      ]),
    },
  });
});