Warn if 'git://' protocol is used as the source of a pod

parent a72ce8bc
...@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements ##### Enhancements
* Warn if 'git://' protocol is used as the source of a pod
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7705](https://github.com/CocoaPods/CocoaPods/issues/7705)
* Remove all PBX state from targets, improve project generation performance * Remove all PBX state from targets, improve project generation performance
[Dimitris Koutsogiorgas](https://github.com/dnkoutso) [Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7610](https://github.com/CocoaPods/CocoaPods/pull/7610) [#7610](https://github.com/CocoaPods/CocoaPods/pull/7610)
......
...@@ -8,6 +8,8 @@ module Pod ...@@ -8,6 +8,8 @@ module Pod
# @note This class needs to consider all the activated specs of a Pod. # @note This class needs to consider all the activated specs of a Pod.
# #
class PodSourceInstaller class PodSourceInstaller
UNENCRYPTED_PROTOCOLS = %w(http git).freeze
# @return [Sandbox] The installation target. # @return [Sandbox] The installation target.
# #
attr_reader :sandbox attr_reader :sandbox
...@@ -110,18 +112,24 @@ module Pod ...@@ -110,18 +112,24 @@ module Pod
end end
end end
# Verify the source of the spec is secure, which is used to # Verify the source of the spec is secure, which is used to show a warning to the user if that isn't the case
# show a warning to the user if that isn't the case # This method doesn't verify all protocols, but currently only prohibits unencrypted 'http://' and 'git://''
# This method doesn't verify all protocols, but currently # connections.
# only prohibits unencrypted http:// connections #
# @return [void]
# #
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? && root_spec.source[:git].nil?)
http_source = URI(root_spec.source[:http]) source = if !root_spec.source[:http].nil?
return if http_source.scheme == 'https' || http_source.scheme == 'file' URI(root_spec.source[:http].to_s)
UI.warn "'#{root_spec.name}' uses the unencrypted http protocol to transfer the Pod. " \ elsif !root_spec.source[:git].nil?
'Please be sure you\'re in a safe network with only trusted hosts in there. ' \ URI(root_spec.source[:git].to_s)
'Please reach out to the library author to notify them of this security issue.' end
if UNENCRYPTED_PROTOCOLS.include?(source.scheme)
UI.warn "'#{root_spec.name}' uses the unencrypted '#{source.scheme}' protocol to transfer the Pod. " \
'Please be sure you\'re in a safe network with only trusted hosts. ' \
'Otherwise, please reach out to the library author to notify them of this security issue.'
end
end end
def download_request def download_request
......
...@@ -46,12 +46,20 @@ module Pod ...@@ -46,12 +46,20 @@ module Pod
UI.warnings.length.should.equal(0) UI.warnings.length.should.equal(0)
end end
it 'shows a warning if the source is unencrypted (e.g. http)' do it 'shows a warning if the source is unencrypted with 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
Downloader.stubs(:download).returns(dummy_response) Downloader.stubs(:download).returns(dummy_response)
@installer.install! @installer.install!
UI.warnings.should.include 'Please reach out to the library author to notify them of this security issue' UI.warnings.should.include 'uses the unencrypted \'http\' protocol'
end
it 'shows a warning if the source is unencrypted with git://' do
@spec.source = { :git => 'git://git.orta.io/orta.git' }
dummy_response = Pod::Downloader::Response.new
Downloader.stubs(:download).returns(dummy_response)
@installer.install!
UI.warnings.should.include 'uses the unencrypted \'git\' protocol'
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