Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit: disable OSDN urls #17366

Merged
merged 9 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Library/Homebrew/cask/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,18 @@ def audit_download_url_format
return if block_url_offline?

odebug "Auditing URL format"
if bad_sourceforge_url?
add_error "SourceForge URL format incorrect. See #{Formatter.url(SOURCEFORGE_OSDN_REFERENCE_URL)}",
location: cask.url.location
elsif bad_osdn_url?
add_error "OSDN URL format incorrect. See #{Formatter.url(SOURCEFORGE_OSDN_REFERENCE_URL)}",
location: cask.url.location
end
return unless bad_sourceforge_url?

add_error "SourceForge URL format incorrect. See #{Formatter.url(SOURCEFORGE_OSDN_REFERENCE_URL)}",
location: cask.url.location
end

def audit_download_url_is_osdn
return unless cask.url
return if block_url_offline?
return unless bad_osdn_url?

add_error "OSDN download urls are disabled.", location: cask.url.location, strict_only: true
end

VERIFIED_URL_REFERENCE_URL = "https://docs.brew.sh/Cask-Cookbook#when-url-and-homepage-domains-differ-add-verified"
Expand Down Expand Up @@ -895,7 +900,7 @@ def bad_sourceforge_url?

sig { returns(T::Boolean) }
def bad_osdn_url?
bad_url_format?(/osd/, [%r{\Ahttps?://([^/]+.)?dl\.osdn\.jp/}])
domain.match?(%r{^(?:\w+\.)*osdn\.jp(?=/|$)})
end

# sig { returns(String) }
Expand Down
16 changes: 10 additions & 6 deletions Library/Homebrew/test/cask/audit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -932,17 +932,21 @@ def tmp_cask(name, text)

it { is_expected.not_to error_with(message) }
end
end

context "with incorrect OSDN URL format" do
let(:cask_token) { "osdn-incorrect-url-format" }
describe "disable OSDN download url" do
let(:only) { ["download_url_is_osdn"] }
let(:message) { /OSDN download urls are disabled./ }
let(:cask_token) { "osdn-urls" }

it { is_expected.to error_with(message) }
context "when --strict is not passed" do
it { is_expected.not_to error_with(message) }
end

context "with correct OSDN URL format" do
let(:cask_token) { "osdn-correct-url-format" }
context "when --strict is passed" do
let(:strict) { true }

it { is_expected.not_to error_with(message) }
it { is_expected.to error_with(message) }
end
end

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cask "osdn-correct-url-format" do
cask "osdn-urls" do
version "1.2.3"

url "https://user.dl.osdn.jp/something/id/Something-1.2.3.dmg"
Expand Down