summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremiah Snapp <jeremiah@getchef.com>2014-01-08 14:08:18 -0500
committerBryan McLellan <btm@getchef.com>2014-04-10 04:54:53 -0700
commit8aa63d3093d1b3def084a864cdb316223475a46d (patch)
treeb97a3477b622b97a38478a80e5738b79ae218843
parentf2bec9586e1d0c43a223908794fd68aaf39732f8 (diff)
downloadchef-8aa63d3093d1b3def084a864cdb316223475a46d.tar.gz
quote git rev_pattern to prevent pathname expansion
-rw-r--r--lib/chef/provider/git.rb2
-rw-r--r--spec/unit/provider/git_spec.rb8
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/chef/provider/git.rb b/lib/chef/provider/git.rb
index e77948d367..46c8965c7d 100644
--- a/lib/chef/provider/git.rb
+++ b/lib/chef/provider/git.rb
@@ -247,7 +247,7 @@ class Chef
else
@new_resource.revision + '*'
end
- command = git("ls-remote \"#{@new_resource.repository}\"", rev_pattern)
+ command = git("ls-remote \"#{@new_resource.repository}\" \"#{rev_pattern}\"")
@resolved_reference = shell_out!(command, run_options).stdout
ref_lines = @resolved_reference.split("\n")
refs = ref_lines.map { |line| line.split("\t") }
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb
index b18a2a8996..3986c39ed2 100644
--- a/spec/unit/provider/git_spec.rb
+++ b/spec/unit/provider/git_spec.rb
@@ -93,7 +93,7 @@ describe Chef::Provider::Git do
@resource.revision "v1.0"
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n")
- @provider.should_receive(:shell_out!).with(@git_ls_remote + "v1.0*", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
@provider.target_revision.should eql("503c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -102,7 +102,7 @@ describe Chef::Provider::Git do
@stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" +
"503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n" +
"663c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0^{}\n")
- @provider.should_receive(:shell_out!).with(@git_ls_remote + "v1.0*", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
@provider.target_revision.should eql("663c22a5e41f5ae3193460cca044ed1435029f53")
end
@@ -131,7 +131,7 @@ describe Chef::Provider::Git do
it "does not raise an error when the revision is valid and assertions are run." do
@resource.revision "0.8-alpha"
@stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n"
- @provider.should_receive(:shell_out!).with(@git_ls_remote + "0.8-alpha*", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
@provider.action = :checkout
::File.stub(:directory?).with("/my/deploy").and_return(true)
@provider.define_resource_requirements
@@ -156,7 +156,7 @@ b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{}
ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package
SHAS
@resource.revision ''
- @provider.should_receive(:shell_out!).with(@git_ls_remote + "HEAD", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
+ @provider.should_receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout))
@provider.target_revision.should eql("28af684d8460ba4793eda3e7ac238c864a5d029a")
end
end