Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tools/approval.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""

import contextvars
import fnmatch
import logging
import os
import re
Expand Down Expand Up @@ -607,6 +608,12 @@ def check_dangerous_command(command: str, env_type: str,
if not is_dangerous:
return {"approved": True, "message": None}

# Check glob-based allowlist BEFORE pattern-key lookup.
# command_allowlist entries like "python3 << *" are glob patterns, not pattern keys.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fnmatch here runs against the whole shell string, so * can span newlines and shell operators. This would let a glob such as python3 << * approve appended/chained content; use a constrained matcher that rejects compound shell syntax before granting the shortcut.

with _lock:
if any(fnmatch.fnmatch(command, p) for p in _permanent_approved):
return {"approved": True, "message": None}

session_key = get_current_session_key()
if is_approved(session_key, pattern_key):
return {"approved": True, "message": None}
Expand Down