Skip to content

armgit / rea

Public Imported from GitHub
0

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

fix(managed): validate CLI type selections with the member contract (#2125)

Kaoru082260259a91d9a5
diff --git a/src/cli/managedCommands.ts b/src/cli/managedCommands.ts
index f922b9532..eee4eae5a 100644
--- a/src/cli/managedCommands.ts
+++ b/src/cli/managedCommands.ts
@@ -16,6 +16,7 @@ import { logCliCommand } from "../cliLogging.js";
import type { Logger } from "pino";
import type { CliInstance } from "./types.js";
import { registerProjectManagedApplicationGraph } from "./managedProjectGraphCommand.js";
+import { managedMembersInputSchema } from "../contracts/managed/managedToolContracts.js";
export const registerManagedCommands = (
cli: CliInstance,
@@ -60,12 +61,9 @@ const registerInspectManagedMembers = (
path: z.string().describe("Managed PE executable or assembly path"),
}),
options: z.object({
- type: z
- .array(z.string())
- .optional()
- .describe(
- "Inspect only members declared by this exact type full name, such as System.Threading.Monitor; a nested type is named by its bare name, which selects every nested type of that name (repeatable)",
- ),
+ type: managedMembersInputSchema.shape.type_names.describe(
+ "Inspect only members declared by this exact type full name, such as System.Threading.Monitor; a nested type is named by its bare name, which selects every nested type of that name (repeatable)",
+ ),
}),
run: ({ args, options }) =>
logCliCommand(logger, "inspect-managed-members", () =>
diff --git a/tests/acceptance/managedCliOutput.test.ts b/tests/acceptance/managedCliOutput.test.ts
index d8a4bb998..a24020d60 100644
--- a/tests/acceptance/managedCliOutput.test.ts
+++ b/tests/acceptance/managedCliOutput.test.ts
@@ -177,6 +177,38 @@ cliTest(
},
);
+cliTest(
+ "managed CLI rejects repeated or empty type selections as invalid input",
+ async ({ cli }) => {
+ const root = await createTestTempDirectory("rea-managed-cli-types-");
+ const path = join(root, "fixture.dll");
+ await writeFile(path, buildManagedPeFixture());
+ for (const [types, message] of [
+ [["Fixture.Empty0", "Fixture.Empty0"], "must not repeat a name"],
+ [[""], ">=1 characters"],
+ ] as const) {
+ const result = await cli.run({
+ arguments: [
+ "inspect-managed-members",
+ path,
+ ...types.flatMap((type) => ["--type", type]),
+ "--json",
+ ],
+ });
+ expect(result.exitCode).toBe(1);
+ expect(result.json).toMatchObject({
+ code: "VALIDATION_ERROR",
+ fieldErrors: [
+ expect.objectContaining({
+ path: expect.stringMatching(/^type/u),
+ message: expect.stringContaining(message),
+ }),
+ ],
+ });
+ }
+ },
+);
+
cliTest(
"managed CLI bounds CIL claims by section virtual ranges",
async ({ cli }) => {