Harden subprocess argv against option injection (#2)
- download.py: insert `--` before URL in yt-dlp argv so a `-`-prefixed string can never be parsed as a flag (e.g. --exec, --config-location). Tighten is_url to reject `-`-prefixed sources and require non-empty netloc. - frames.py, whisper.py: resolve video/audio paths to absolute via Path.resolve() before passing to ffmpeg/ffprobe (which don't honor `--` as end-of-options), so a relative path starting with `-` can never be misinterpreted as a flag. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -93,13 +93,13 @@ def extract_audio(video_path: str, out_path: Path) -> Path:
|
||||
"-hide_banner",
|
||||
"-loglevel", "error",
|
||||
"-y",
|
||||
"-i", video_path,
|
||||
"-i", str(Path(video_path).resolve()),
|
||||
"-vn",
|
||||
"-acodec", "libmp3lame",
|
||||
"-ar", "16000",
|
||||
"-ac", "1",
|
||||
"-b:a", "64k",
|
||||
str(out_path),
|
||||
str(out_path.resolve()),
|
||||
]
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
|
||||
Reference in New Issue
Block a user