Unverified Commit d60ff0ec authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7462 from dnkoutso/file_uri_scheme_fix

Do not warn when http source uses `file:///` URI scheme
parents 34a88f71 2246d7cb
...@@ -89,6 +89,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -89,6 +89,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
* Stop adding header search paths that do not contain any headers. * Stop adding header search paths that do not contain any headers.
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
* Do not warn when http source uses `file:///` URI scheme
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7460](https://github.com/CocoaPods/CocoaPods/issues/7460)
## 1.4.0 (2018-01-18) ## 1.4.0 (2018-01-18)
##### Enhancements ##### Enhancements
......
...@@ -132,9 +132,8 @@ module Pod ...@@ -132,9 +132,8 @@ module Pod
# #
def verify_source_is_secure(root_spec) def verify_source_is_secure(root_spec)
return if root_spec.source.nil? || root_spec.source[:http].nil? return if root_spec.source.nil? || root_spec.source[:http].nil?
http_source = root_spec.source[:http] http_source = URI(root_spec.source[:http])
return if http_source.downcase.start_with?('https://') return if http_source.scheme == 'https' || http_source.scheme == 'file'
UI.warn "'#{root_spec.name}' uses the unencrypted http protocol to transfer the Pod. " \ UI.warn "'#{root_spec.name}' uses the unencrypted http protocol to transfer the Pod. " \
'Please be sure you\'re in a safe network with only trusted hosts in there. ' \ 'Please be sure you\'re in a safe network with only trusted hosts in there. ' \
'Please reach out to the library author to notify them of this security issue.' 'Please reach out to the library author to notify them of this security issue.'
......
...@@ -398,8 +398,8 @@ module Pod ...@@ -398,8 +398,8 @@ module Pod
# #
def validate_source_url(spec) def validate_source_url(spec)
return if spec.source.nil? || spec.source[:http].nil? return if spec.source.nil? || spec.source[:http].nil?
url = spec.source[:http] url = URI(spec.source[:http])
return if url.downcase.start_with?('https://') return if url.scheme == 'https' || url.scheme == 'file'
warning('http', "The URL (`#{url}`) doesn't use the encrypted HTTPs protocol. " \ warning('http', "The URL (`#{url}`) doesn't use the encrypted HTTPs protocol. " \
'It is crucial for Pods to be transferred over a secure protocol to protect your users from man-in-the-middle attacks. '\ 'It is crucial for Pods to be transferred over a secure protocol to protect your users from man-in-the-middle attacks. '\
'This will be an error in future releases. Please update the URL to use https.') 'This will be an error in future releases. Please update the URL to use https.')
......
...@@ -40,6 +40,14 @@ module Pod ...@@ -40,6 +40,14 @@ module Pod
UI.warnings.length.should.equal(0) UI.warnings.length.should.equal(0)
end end
it 'does not show warning if the source uses file:///' do
@spec.source = { :http => 'file:///orta.io/sdk.zip' }
dummy_response = Pod::Downloader::Response.new
Downloader.stubs(:download).returns(dummy_response)
@installer.install!
UI.warnings.length.should.equal(0)
end
it 'shows a warning if the source is unencrypted (e.g. http)' do it 'shows a warning if the source is unencrypted (e.g. http)' do
@spec.source = { :http => 'http://orta.io/sdk.zip' } @spec.source = { :http => 'http://orta.io/sdk.zip' }
dummy_response = Pod::Downloader::Response.new dummy_response = Pod::Downloader::Response.new
......
...@@ -259,7 +259,7 @@ module Pod ...@@ -259,7 +259,7 @@ module Pod
end end
end end
describe 'documentation URL validation' do describe 'source URL validation' do
before do before do
@validator.unstub(:validate_source_url) @validator.unstub(:validate_source_url)
end end
...@@ -275,9 +275,15 @@ module Pod ...@@ -275,9 +275,15 @@ module Pod
@validator.validate @validator.validate
@validator.results.map(&:to_s).first.should.match /use the encrypted HTTPs protocol./ @validator.results.map(&:to_s).first.should.match /use the encrypted HTTPs protocol./
end end
it 'should not fail validation if the source URL is using file:///' do
Specification.any_instance.stubs(:source).returns(:http => 'file:///orta.io/package.zip')
@validator.validate
@validator.results.should.be.empty?
end
end end
describe 'source URL validation' do describe 'documentation URL validation' do
before do before do
@validator.unstub(:validate_documentation_url) @validator.unstub(:validate_documentation_url)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment