Skip to content

Commit 463b0b6

Browse files
committed
fix: allow curl/wget with stderr redirects in plan mode bash allowlist
The `>` redirect detection in isSafeCommand() was falsely blocking common curl patterns like `curl ... 2>/dev/null` and `curl ... 2>&1 | head`. This prevented agents from fetching web content (e.g. via jina.ai or markdown.new) during planning mode. Fix: strip safe fd redirects (2>/dev/null, 2>&1, &>/dev/null) from the command before checking against destructive patterns, while still blocking actual file redirects like `> output.txt`. https://claude.ai/code/session_01Jk1P5aZPERSzrmA9urfb4B
1 parent c7ae789 commit 463b0b6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

apps/pi-extension/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@ const SAFE_PATTERNS = [
4646
];
4747

4848
export function isSafeCommand(command: string): boolean {
49-
const isDestructive = DESTRUCTIVE_PATTERNS.some((p) => p.test(command));
49+
// Strip safe fd redirects before checking destructive patterns.
50+
// This prevents common patterns like `curl ... 2>/dev/null` or
51+
// `curl ... 2>&1 | head` from being falsely blocked by the `>` rule.
52+
const normalized = command
53+
.replace(/\s*\d*>\s*\/dev\/null/g, "") // N>/dev/null (any fd to /dev/null)
54+
.replace(/\s*\d*>&\d+/g, "") // N>&M (fd merges, e.g. 2>&1)
55+
.replace(/\s*&>\s*\/dev\/null/g, ""); // &>/dev/null (bash shorthand)
56+
57+
const isDestructive = DESTRUCTIVE_PATTERNS.some((p) => p.test(normalized));
5058
const isSafe = SAFE_PATTERNS.some((p) => p.test(command));
5159
return !isDestructive && isSafe;
5260
}

0 commit comments

Comments
 (0)