mirror of
https://github.com/storytold/artcraft-services.git
synced 2026-11-23 19:00:58 +01:00
## What was wrong `GoogleDriveDownloadCommand::download_file` and `download_file_with_file_name` put the download URL into a shell string (`--url "<url>"`) and ran it with `sh -c`. Double quotes do not stop `$(...)` or backticks, so a URL submitted to the generic download enqueue routes or the GPT-SoVITS model download route could run commands on the download/inference worker. The Docker variant nested the same string inside `bash -c "..."`, which had the same problem. ## What changed - The URL and output filename are no longer part of the shell source. The script is now `<download_script> --url "$1" --output_filename "$2"` and the values are passed as positional parameters to `sh -c`, so the shell expands them as plain data. The configured script, venv activation and working directory (operator config) keep working as before. - With Docker, the command is built as an argument vector with a new `DockerOptions::to_command_args`. The URL and filename go to the container shell as `$1`/`$2`, and no host shell is involved. - The two methods now share one `run_downloader`/`build_command` helper instead of duplicating the logic. ## Blast radius Deprecated download_job, tts_download_job and inference_job upload paths (GPT-SoVITS, SD/LoRA, workflow uploads). The public method signatures are unchanged. `DockerOptions::to_command_string` is unchanged, and its other callers are not affected. ## Checks run - `cargo test -p google_drive_downloader -p subprocess_common` passed. New tests: a hostile URL containing `$(...)`, backticks and quotes reaches the downloader as one literal argument (run through a real `sh`), the generated shell source never contains the URL, and the Docker argument vector keeps positional arguments separate. ## Checks not run - No end-to-end run of the download workers (they need the Python downloader script, Docker, and a job queue). - `cargo check` was not run on the dependent job binaries (`download_job`, `tts_download_job`, `inference_job`). The public API they use is unchanged. Addresses CodeRabbit security findings (CWE-78). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Downloads now pass the URL and output filename separately, so characters in these values are preserved rather than interpreted as part of a command. * Docker-based downloads retain support for configured environment variables, bind mounts, and GPU options. * Failed downloads continue to report error details when available, with a fallback message when the error output cannot be read. <!-- end of auto-generated comment: release notes by coderabbit.ai -->