T09 · Insecure Skill Coding Practices
- Location
scripts/setup_envs.py:105- Finding
Shell Command Injection in Generated Startup Scripts
- Content
View full analysis
str: """Generate startup shell script for a specific environment.""" env_label = {"dev": "Development", "test": "Testing", "prod": "Production"}[env] port = config[f"{env}_port"] app_module = config["app_module"] name = config["name"] user_line = "" if env == "dev" and config.get("dev_user"): user_line = f'\necho "👩💻 Happy coding, {config["dev_user"]}!"' elif env == "test" and config.get("test_user"): user_line = f'\necho "🧪 Happy testing, {config["test_user"]}!"' reload_flag = "\n --reload \\" if env == "dev" else "" workers = "$(nproc)" if env == "prod" else "1" workers_line = "" if env == "dev" else f"\n --workers {workers} \\" log_level = {"dev": "debug", "test": "info", "prod": "warning"}[env] return f"""#!/bin/bash # {'=' * 50} # {name} - {env_label} Environment # {'=' * 50} set -e SCRIPT_DIR="$(cd "$(dirname "${{BASH_SOURCE[0]}}")" && pwd)" PROJECT_DIR="$(dirname "$SCRIPT_DIR")" export ENV_FILE="$PROJECT_DIR/.env.{env}" echo "🚀 Starting {name} {env_label} Environment..." echo "📍 Port: {port}" echo "📍 Environment: $ENV_FILE" echo "📍 Database: ./data/{env}/"{user_line} echo "" cd "$PROJECT_DIR" [ -d "venv" ] && source venv/bin/activate uvicorn {app_module} \\ --host 127.0.0.1 \\ --port {port} \\{reload_flag}{workers_line} --log-level {log_level} """ ``` From `scripts/setup_envs_v2.py`: ```python def generate_frontend_script(env: str, config: dict) -> str: """Generate frontend startup shell script for a specific environment.""" env_label = {"dev": "Development", "test": "Testing", "prod": "Production"}[e ...[truncated 3202 chars]- Remediation
View remediation
