Files
Open_Ultra_SAST/benchmarks/pairs/agent-vfc/tools-cli-tools-a96bc0/vuln.py
T
Marius CiepluchandClaude Fable 5.1 8ab4207618 feat(pair-corpus-honesty): add vibe-py, vfc-js and agent-vfc slices with mechanism vocabulary
Tasks 1.1, 5.1, 5.2, 5.4 and the data half of 5.3.

- mechanisms.toml: closed vocabulary v1 (20 ids) every expected row cites.
- vibe-py: 35 Real-Vuln-Benchmark pairs (Apache-2.0), human provenance only
  because the LLM-generated repositories carry no license (escalated).
- vfc-js: 17 Node fix-commit pairs harvested upstream (MIT/Apache-2.0),
  SecBench.js itself is not vendored (no license); sinks derived on 13/17.
- agent-vfc: 29 agent-trailer fixes as catalog-candidates.toml plus
  REVIEW.md; the loaded catalog stays empty until a human reviews them.
- datasets.toml and README document every slice and its review status.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
2026-09-05 10:45:42 +02:00

49 lines
1.6 KiB
Python

# Provenance: D-sorganization/Tools (vuln).
# repo: D-sorganization/Tools
# commit: e735d28b82dd1fbc42c0ae01157b38d1b4c7c864
# parent: e735d28b82dd1fbc42c0ae01157b38d1b4c7c864
# commit_url: https://github.com/D-sorganization/Tools/commit/a96bc0502a3dcdac303e4f0152508886e5c35c0a
# cve:
# license: MIT
# function: _is_command_allowed
# relpath: src/shared/python/ai/tools/cli_tools.py
# provenance: agent
# mechanism: source_reaches_sink
def _is_command_allowed(self, command: str) -> bool:
"""Check if a command is allowed.
Args:
command: Command to check.
Returns:
True if allowed, False otherwise.
"""
# Dangerous commands are never allowed
dangerous = ["rm", "sudo", "chmod", "chown", "curl", "wget", "ssh"]
# Prevent shell injection by blocking command separators/operators
shell_operators = ["&&", "||", ";", "|", ">", "<", "$", "`", "\n", "&"]
if any(op in command for op in shell_operators):
return False
try:
tokens = shlex.split(command)
if not tokens:
return False
# Verify the first token is in the allowlist
base_cmd = tokens[0]
if base_cmd not in self._allowed_commands:
return False
# Verify no token is a dangerous command
for token in tokens:
if token in dangerous:
return False
return True
except ValueError:
# e.g., missing closing quote
return False