Repository navigation
Fix SSRF check bypass, rate-limit !lyrics, and clean up - #86
Merged
Merged
Conversation
…ork check !play ran media.is_public_url only when the query started with a lowercase "http", while _is_playlist_url lowercased first. HTTP://10.0.0.1/?list=x therefore reached yt-dlp unchecked. media.is_url is now the one definition every caller shares; it also stops a search like "httpster" from being refused as a link. Refs #85
A single lookup can make two LRCLIB and two Genius requests, and nothing limited how often one user could trigger it. Three per ten seconds, per user, matches the shape of the !play limit. Refs #85
!nowplaying passed ctx.author as the requester, so it credited whoever asked rather than whoever queued the track. !queue 0, a negative page or one past the end rendered wrong positions or an empty page; it now shows the nearest real page. Refs #85
Every caller passed bot.loop, which is the running loop, and the default fell back to the deprecated get_event_loop(). _run now takes the running loop itself, as services.lyrics_api already does. Refs #85
Each of the three callers unpacked filter, label and rate by hand; reset now uses a named no-effect Effect, so every path reads the same. Refs #85
What reaches the end of errors.handle is a bug or an outage, not a user mistake. The player loop and the lyrics follower already log theirs at ERROR; commands logged the same class of failure as a warning. Refs #85
- _prefetch_delay guarded a Track that is never None. - set_volume tested vc.source before an isinstance that already rejects None. - The alone-in-channel test was written out twice; it is now one helper. - Fix a misaligned continuation line in NowPlayingControls. Refs #85
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.
Closes #85.
Context
A repository-wide review of code quality and security found two security gaps, two user-visible bugs and some cleanup. Each change is its own commit.
Changes
Security
efb8bac).!playranmedia.is_public_urlonly when the query started with a lowercasehttp, while_is_playlist_urllowercased the query first.!play HTTP://10.0.0.1/?list=xreached yt-dlp unchecked; under systemdIPAddressDenystill blocked it, outside systemd nothing did.media.is_urlis now the single, case-insensitive definition used by the play check, the playlist detection, the yt-dlp target and the suggestions. It also stops a search such ashttpster livefrom being refused as a link.!lyricsrate limit (2efdb96). One lookup can make two LRCLIB and two Genius requests. It is now limited to 3 per 10 s per user, and the README's security section says so.Bugs
!nowplayingcredited whoever ran it instead of whoever queued the track (c9ce4af).!queue 0, negative pages and pages past the end rendered wrong positions or an empty page; they now show the nearest real page (c9ce4af).Cleanup
loop=parameter frommedia.search/search_many/get_playlist/related. Every caller passed the running loop, and the fallback used the deprecatedget_event_loop()(944efe6).Effects._switch_totakes anEffect(3ab94cd).d37c53a).ebe75be).How to test
Automated:
ruff check .,mypyandpytest -rapass locally (628 passed, 1 POSIX-only skip). New regression tests:test_play_refuses_links_into_private_networks: uppercase-scheme and playlist-path cases.test_play_does_not_mistake_a_search_for_a_linktest_url_detection_ignores_the_case_of_the_schemetest_a_word_starting_with_http_is_a_search_not_a_linktest_lyrics_is_limited_per_usertest_nowplaying_credits_whoever_queued_the_tracktest_queue_pages_out_of_range_show_the_nearest_real_oneManual, in a test server:
!play HTTP://192.168.1.1/?list=xreplies "I can only play links to public websites."!play httpster livesearches YouTube instead of being refused.!play <song>, then user B runs!np. The embed credits A.!queue 0and!queue 5both show page 1.!lyrics bohemian rhapsodyfour times within 10 s: the fourth gets "Slow down".