rubocops/urls: Ignore GitHub username and repo in binary URL check - #23236
Conversation
|
Okay clearly I was not ready for dealing with rubocop. Consider this a bug report for now and I'll keep working. |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Thanks for the PR!
I think this change as-is is too broad. You're handling the scriptingosx case: instead please omit the GitHub username and, maybe, the repository name.
This change as-is seems likely to miss cases that this cop exists to check.
MikeMcQuaid
left a comment
There was a problem hiding this comment.
just marking as "reviewed" for now
|
TBH I don't think this class of false positives is common enough to do something about. If they're filling up the allowlist we can adjust this then. |
|
I think I might agree with @carlocab . Parsing URLs for GitHub references isn't difficult but it does seem like overkill for less than 10 offenses. The |
|
@timhillgit I'm happy to have this PR be dropped or take a more specific approach. It's not about the number of current offences but the cases this ends up catching to save maintainers work over the years which has (and will) be many more than 10. |
|
The GitHub check ended up being much easier than I feared. Adding it means I believe we'll be able to remove the following formulae from
|
This is a requested change from Homebrew/homebrew-core#293667 (comment) . We want to prevent binary files from being linked to but the current check is broad. It checks for suspicious strings anywhere in the URL when really, all we care about is the filename. Specifically from that PR, the current audit flags
https://github.com/scriptingosx/utiluti/archive/refs/tags/v1.5.tar.gzas being a binary file because the username containsosx.This PR fixes this issue by parsing the URL and only running the regex check against the filename part. Potentially, we could also possibly allow extensions like
.gzand.zipas those are usually not used for binaries, but I don't think it's necessary.Reproducing the bug
If you remove
utilutifromnot_a_binary_url_prefix_allowlist.jsonand runbrew audit --strict utilutiyou'll see the following error:Testing
I haven't written a test yet. If we like the approach it looks like the correct location would be Library/Homebrew/test/rubocops/urls/http_spec.rb ?
brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?