Merge pull request #17366 from Aaron-212/disable-osdn-url
Audit: disable OSDN urls
This commit is contained in:
commit
91affd113e
@ -324,13 +324,18 @@ module Cask
|
|||||||
return if block_url_offline?
|
return if block_url_offline?
|
||||||
|
|
||||||
odebug "Auditing URL format"
|
odebug "Auditing URL format"
|
||||||
if bad_sourceforge_url?
|
return unless bad_sourceforge_url?
|
||||||
|
|
||||||
add_error "SourceForge URL format incorrect. See #{Formatter.url(SOURCEFORGE_OSDN_REFERENCE_URL)}",
|
add_error "SourceForge URL format incorrect. See #{Formatter.url(SOURCEFORGE_OSDN_REFERENCE_URL)}",
|
||||||
location: cask.url.location
|
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
|
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
|
end
|
||||||
|
|
||||||
VERIFIED_URL_REFERENCE_URL = "https://docs.brew.sh/Cask-Cookbook#when-url-and-homepage-domains-differ-add-verified"
|
VERIFIED_URL_REFERENCE_URL = "https://docs.brew.sh/Cask-Cookbook#when-url-and-homepage-domains-differ-add-verified"
|
||||||
@ -895,7 +900,7 @@ module Cask
|
|||||||
|
|
||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
def bad_osdn_url?
|
def bad_osdn_url?
|
||||||
bad_url_format?(/osd/, [%r{\Ahttps?://([^/]+.)?dl\.osdn\.jp/}])
|
domain.match?(%r{^(?:\w+\.)*osdn\.jp(?=/|$)})
|
||||||
end
|
end
|
||||||
|
|
||||||
# sig { returns(String) }
|
# sig { returns(String) }
|
||||||
|
|||||||
@ -932,18 +932,22 @@ RSpec.describe Cask::Audit, :cask do
|
|||||||
|
|
||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with incorrect OSDN URL format" do
|
|
||||||
let(:cask_token) { "osdn-incorrect-url-format" }
|
|
||||||
|
|
||||||
it { is_expected.to error_with(message) }
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with correct OSDN URL format" do
|
describe "disable OSDN download url" do
|
||||||
let(:cask_token) { "osdn-correct-url-format" }
|
let(:only) { ["download_url_is_osdn"] }
|
||||||
|
let(:message) { /OSDN download urls are disabled./ }
|
||||||
|
let(:cask_token) { "osdn-urls" }
|
||||||
|
|
||||||
|
context "when --strict is not passed" do
|
||||||
it { is_expected.not_to error_with(message) }
|
it { is_expected.not_to error_with(message) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when --strict is passed" do
|
||||||
|
let(:strict) { true }
|
||||||
|
|
||||||
|
it { is_expected.to error_with(message) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "generic artifact checks" do
|
describe "generic artifact checks" do
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
cask "osdn-incorrect-url-format" do
|
|
||||||
version "1.2.3"
|
|
||||||
|
|
||||||
url "https://osdn.jp/projects/something/files/Something-1.2.3.dmg/download"
|
|
||||||
homepage "https://osdn.jp/projects/something/"
|
|
||||||
end
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
cask "osdn-correct-url-format" do
|
cask "osdn-urls" do
|
||||||
version "1.2.3"
|
version "1.2.3"
|
||||||
|
|
||||||
url "https://user.dl.osdn.jp/something/id/Something-1.2.3.dmg"
|
url "https://user.dl.osdn.jp/something/id/Something-1.2.3.dmg"
|
||||||
Loading…
x
Reference in New Issue
Block a user