Check if a command is allowed (supports patterns). Args: command: The command to check allowed_commands: Set of allowed commands (may include patterns) Returns: True if command is allowed
(command: str, allowed_commands: set[str])
| 838 | |
| 839 | |
| 840 | def is_command_allowed(command: str, allowed_commands: set[str]) -> bool: |
| 841 | """ |
| 842 | Check if a command is allowed (supports patterns). |
| 843 | |
| 844 | Args: |
| 845 | command: The command to check |
| 846 | allowed_commands: Set of allowed commands (may include patterns) |
| 847 | |
| 848 | Returns: |
| 849 | True if command is allowed |
| 850 | """ |
| 851 | # Check exact match first |
| 852 | if command in allowed_commands: |
| 853 | return True |
| 854 | |
| 855 | # Check pattern matches |
| 856 | for pattern in allowed_commands: |
| 857 | if matches_pattern(command, pattern): |
| 858 | return True |
| 859 | |
| 860 | return False |
| 861 | |
| 862 | |
| 863 | async def bash_security_hook(input_data, tool_use_id=None, context=None): |
no test coverage detected