Skip to content

armgit / rea

Public Imported from GitHub
0

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

fix(hopper): report invalid regex patterns as pattern input errors (#6372)

Abel Yagubyan4f8465d8db86
diff --git a/src/hopper/HopperRegexSearch.ts b/src/hopper/HopperRegexSearch.ts
index 397c61f78..0238d59bf 100644
--- a/src/hopper/HopperRegexSearch.ts
+++ b/src/hopper/HopperRegexSearch.ts
@@ -143,11 +143,6 @@ export class HopperRegexSearch {
signal: options.signal,
deadline: this.deadline,
heapRequest: this.heapRequest,
- invalidPattern: (reason) =>
- new HopperRemoteError(-32000, `Invalid regex pattern: ${reason}`, {
- diagnosticType: "invalid_request",
- operation,
- }),
});
if (!matched.ok) return matched;
if (options.signal?.aborted)
diff --git a/tests/boundary/process/regexMatcher.test.ts b/tests/boundary/process/regexMatcher.test.ts
index dc2177c79..066c17468 100644
--- a/tests/boundary/process/regexMatcher.test.ts
+++ b/tests/boundary/process/regexMatcher.test.ts
@@ -617,15 +617,25 @@ it("keeps Hopper's result projection and invalid-pattern contract with the share
expect(
await search.execute("search_strings", { pattern: "^δ", mode: "regex" }),
).toEqual(ok([{ address: "0x10", value: "Δelta" }]));
- expect(
- await search.execute("search_strings", { pattern: "[", mode: "regex" }),
- ).toMatchObject({
- ok: false,
- error: {
- _tag: "HopperRemoteError",
- code: -32000,
- diagnosticType: "invalid_request",
+ const invalid = await search.execute("search_strings", {
+ pattern: "[",
+ mode: "regex",
+ });
+ if (invalid.ok) throw new Error("Expected invalid-pattern refusal");
+ expect(projectAnalysisError(invalid.error)).toMatchObject({
+ code: "invalid_request",
+ category: "invalid_input",
+ message: expect.stringContaining("Invalid regex pattern"),
+ recovery: { kind: "inspect_input_contract", operation: "search_strings" },
+ details: {
operation: "search_strings",
+ issues: [
+ {
+ path: ["pattern"],
+ reason: "invalid_format",
+ message: "Supply a valid regular expression.",
+ },
+ ],
},
});
await search.close();