feat: add resumable and cancellable downloads - #68
Open
guoshulin1992-prog wants to merge 21 commits into
Open
guoshulin1992-prog wants to merge 21 commits into
guoshulin1992-prog wants to merge 21 commits into
Conversation
The url field from POST /api/download, /api/info, and /api/playlist was passed straight into the yt-dlp argv list. Since these endpoints are unauthenticated, a caller could pass a value like "--exec=<cmd>" instead of a real URL; yt-dlp parses any argv item starting with "-" as an option rather than a positional URL, so this allowed arbitrary command execution on the host after a (fake) download. Fixes: - Add is_safe_url() to require an http(s) scheme + host, rejecting anything that could be interpreted as a CLI flag. - Insert a "--" argv separator before the URL in every yt-dlp invocation so option parsing stops regardless of URL content (defense in depth alongside the scheme check). - Apply the check on all three endpoints that accept a URL.
The url field from POST /api/download, /api/info, and /api/playlist was passed straight into the yt-dlp argv list. Since these endpoints are unauthenticated, a caller could pass a value like "--exec=<cmd>" instead of a real URL; yt-dlp parses any argv item starting with "-" as an option rather than a positional URL, so this allowed arbitrary command execution on the host after a (fake) download. Fixes: - Add is_safe_url() to require an http(s) scheme + host, rejecting anything that could be interpreted as a CLI flag. - Insert a "--" argv separator before the URL in every yt-dlp invocation so option parsing stops regardless of URL content (defense in depth alongside the scheme check). - Apply the check on all three endpoints that accept a URL.
# Conflicts: # app.py # docker-compose.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cancellingthencancelledstates.Relationship to #66
This is a stacked PR based on the work in #66, which is still open. The branch contains the progress feature as its base plus resumable-download and cancellation implementations. Please merge #66 first, or rebase/split this branch if an independent diff is preferred.
User-visible behavior
127.0.0.1:8899by default.Verification
py_compile,node --check,git diff --check, and Docker image build passed.8898: homepage returned 200 and/api/jobsreturned an empty task list.Security and data scope
--URL separator.(job_id, attempt_no), so cancelling an old attempt cannot cancel a later retry.Known limitations