subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
existing_path = env.get("PYTHONPATH", "") env["PYTHONPATH"] = f"{target_dir}{os.pathsep}{existing_path}" if existing_path else str(target_dir) result = subprocess.run( [sys.executable, "-m", "pytest", str(test_dir), "-v", "--tb=short"], capture_output=True, text=True,- Confidence
- 94% confidence
- Finding
- This code executes pytest in a subprocess against a target directory that appears to contain generated or otherwise untrusted project content. Running tests is equivalent to executing arbitrary Python code, and the only isolation used is a temporary working directory plus inherited environment variables, which does not sandbox filesystem, network, or process access.
