Find the security failures in this generated tool executor.
Python
from pathlib import Path
import subprocess
WORKSPACE = Path("/srv/project")
def read_file(raw_path: str) -> str:
resolved = Path(raw_path).resolve()
if not str(resolved).startswith(str(WORKSPACE.resolve())):
raise PermissionError(raw_path)
return resolved.read_text()
def run(command: str) -> str:
result = subprocess.run(
command, shell=True, capture_output=True, text=True
)
return result.stdout