@@ -617,6 +617,23 @@ describe("Coding Agent Tools", () => {
|
||||
// Ensure second match is not present
|
||||
expect(output).not.toContain("match two");
|
||||
});
|
||||
|
||||
it("should treat flag-like patterns as search text", async () => {
|
||||
const marker = join(testDir, "grep-injection-marker");
|
||||
const payload = join(testDir, "payload.sh");
|
||||
const testFile = join(testDir, "target.txt");
|
||||
writeFileSync(payload, `#!/bin/sh\necho executed > ${marker}\ncat "$1"\n`);
|
||||
chmodSync(payload, 0o755);
|
||||
writeFileSync(testFile, "target\n");
|
||||
|
||||
const result = await grepTool.execute("test-call-grep-injection", {
|
||||
pattern: `--pre=${payload}`,
|
||||
path: testDir,
|
||||
});
|
||||
|
||||
expect(getTextOutput(result)).toContain("No matches found");
|
||||
expect(existsSync(marker)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("find tool", () => {
|
||||
@@ -663,6 +680,15 @@ describe("Coding Agent Tools", () => {
|
||||
}),
|
||||
).rejects.toThrow(/error parsing glob|fd exited with code 1|fd error/i);
|
||||
});
|
||||
|
||||
it("should treat flag-like patterns as search text", async () => {
|
||||
const result = await findTool.execute("test-call-find-flag-pattern", {
|
||||
pattern: "--help",
|
||||
path: testDir,
|
||||
});
|
||||
|
||||
expect(getTextOutput(result)).toContain("No files found matching pattern");
|
||||
});
|
||||
});
|
||||
|
||||
describe("ls tool", () => {
|
||||
|
||||
Reference in New Issue
Block a user