fix(audio): abort YouTube downloads at the canonical 100 MiB ceiling - #871
Closed
cursor[bot] wants to merge 43 commits into
Closed
fix(audio): abort YouTube downloads at the canonical 100 MiB ceiling#871cursor[bot] wants to merge 43 commits into
cursor[bot] wants to merge 43 commits into
Conversation
A 60 MiB import must be accepted, exact 100 MiB must pass, and announced/in-flight/post-download oversize must fail before cache fill. Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
…ling Drive yt-dlp max_filesize and a progress hook from AudioResourcePolicy, reject announced oversize before download=True, and delete artifacts that still exceed 100 MiB after write. Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Update residual-risk text so Rust intake is no longer described as missing, and cite yt-dlp max_filesize/progress_hooks in APA 7th. Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Collaborator
|
Superseded by the canonical existing #781 owner #866 after exact-head reconciliation. #866 now has merge head |
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
Continues #866 / #781. Native local-file and post-success YouTube bootstrap already used the 100 MiB policy, but
download_youtube_audiostill downloaded with no yt-dlpmax_filesizeand then rejected> 50MB. That rejected 60–100 MiB imports the new policy would accept and let a large transfer fill the cache root before the native check ran.This branch keeps #866's policy stack and adds download-time admission:
max_filesizeand a progress hook abort in-flight once encoded bytes exceedDEFAULT_MAX_ENCODED_FILE_BYTES.filesize/filesize_approxover the ceiling rejects beforedownload=True.AudioResourcePolicy.validate_encoded_file_bytesdeletes leftovers.A 60 MiB YouTube import is now accepted; a file one byte over 100 MiB is not.
Verification
PYTHONPATH=src python3 -m pytest tests/test_youtube.py tests/test_audio_resource_policy.py— 47 passed (26 YouTube + policy).ruff check/ruff format --checkon the YouTube module and tests.mypy --strict --follow-imports=skiponyoutube.py../scripts/harness/quickcheck.sh(full harness not run in this environment; exact-head CI must pass before Ready).Security Notes
Attack surface
YouTube URL intake, yt-dlp subprocess/download, cache-root writes, announced filesize metadata, progress-hook byte counters, post-download file deletion.
Trust boundary
Renderer JSON is not authoritative. URL allowlist stays first. Encoded-byte admission is the canonical Python policy. Native bootstrap still re-checks filesystem-observed length before storing project state.
Mitigations
max_filesize+ progress-hook abort so unknown-size transfers cannot fill the cache root.Test points
max-filesizeerrors map tosize_exceededwithout leaking raw messages.Dependency and Supply Chain
i18n impact
The YouTube oversize engine message now matches the existing local-file 100 MiB copy already used by the desktop bridge. Locale files do not own this string.
Reviewer checklist
developStacked on #866 / #865. Do not merge until those ancestors are in protected
developor this head is reconstructed onto the resulting base. Refs #781.