MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / is_command_allowed

Function is_command_allowed

security.py:840–860  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

838
839
840def 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
863async def bash_security_hook(input_data, tool_use_id=None, context=None):

Callers 2

validate_dev_commandFunction · 0.90
bash_security_hookFunction · 0.85

Calls 1

matches_patternFunction · 0.85

Tested by

no test coverage detected