MCPcopy Index your code
hub / github.com/google/adk-python / _validate_command

Function _validate_command

src/google/adk/tools/bash_tool.py:57–75  ·  view source on GitHub ↗

Validates a bash command against the permitted prefixes.

(command: str, policy: BashToolPolicy)

Source from the content-addressed store, hash-verified

55
56
57def _validate_command(command: str, policy: BashToolPolicy) -> Optional[str]:
58 """Validates a bash command against the permitted prefixes."""
59 stripped = command.strip()
60 if not stripped:
61 return "Command is required."
62
63 for op in policy.blocked_operators:
64 if op in command:
65 return f"Command contains blocked operator: {op}"
66
67 if "*" in policy.allowed_command_prefixes:
68 return None
69
70 for prefix in policy.allowed_command_prefixes:
71 if stripped.startswith(prefix):
72 return None
73
74 allowed = ", ".join(policy.allowed_command_prefixes)
75 return f"Command blocked. Permitted prefixes are: {allowed}"
76
77
78def _set_resource_limits(policy: BashToolPolicy) -> None:

Callers 1

run_asyncMethod · 0.85

Calls 2

stripMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected