|
11 | 11 | context "with configured credentials" do |
12 | 12 | it "adds username and password to URI" do |
13 | 13 | Bundler.settings.temporary(uri => "u:p") do |
14 | | - expect(subject).to receive(:git_retry).with("clone", "https://u:[email protected]/rubygems/rubygems.git", any_args) |
| 14 | + expect(subject).to receive(:git_retry).with("clone", "--bare", "--no-hardlinks", "--quiet", "--", "https://u:[email protected]/rubygems/rubygems.git", path.to_s) |
15 | 15 | subject.checkout |
16 | 16 | end |
17 | 17 | end |
18 | 18 |
|
19 | 19 | it "adds username and password to URI for host" do |
20 | 20 | Bundler.settings.temporary("github.com" => "u:p") do |
21 | | - expect(subject).to receive(:git_retry).with("clone", "https://u:[email protected]/rubygems/rubygems.git", any_args) |
| 21 | + expect(subject).to receive(:git_retry).with("clone", "--bare", "--no-hardlinks", "--quiet", "--", "https://u:[email protected]/rubygems/rubygems.git", path.to_s) |
22 | 22 | subject.checkout |
23 | 23 | end |
24 | 24 | end |
25 | 25 |
|
26 | 26 | it "does not add username and password to mismatched URI" do |
27 | 27 | Bundler.settings.temporary("https://u:[email protected]/rubygems/rubygems-mismatch.git" => "u:p") do |
28 | | - expect(subject).to receive(:git_retry).with("clone", uri, any_args) |
| 28 | + expect(subject).to receive(:git_retry).with("clone", "--bare", "--no-hardlinks", "--quiet", "--", uri, path.to_s) |
29 | 29 | subject.checkout |
30 | 30 | end |
31 | 31 | end |
|
34 | 34 | Bundler.settings.temporary("github.com" => "u:p") do |
35 | 35 | original = "https://orig:[email protected]/rubygems/rubygems.git" |
36 | 36 | subject = described_class.new(Pathname("path"), original, "HEAD") |
37 | | - expect(subject).to receive(:git_retry).with("clone", original, any_args) |
| 37 | + expect(subject).to receive(:git_retry).with("clone", "--bare", "--no-hardlinks", "--quiet", "--", original, path.to_s) |
38 | 38 | subject.checkout |
39 | 39 | end |
40 | 40 | end |
|
148 | 148 | end |
149 | 149 | end |
150 | 150 | end |
| 151 | + |
| 152 | + it "doesn't allow arbitrary code execution through Gemfile uris with a leading dash" do |
| 153 | + gemfile <<~G |
| 154 | + gem "poc", git: "-u./pay:load.sh" |
| 155 | + G |
| 156 | + |
| 157 | + file = bundled_app("pay:load.sh") |
| 158 | + |
| 159 | + create_file file, <<~RUBY |
| 160 | + #!/bin/sh |
| 161 | +
|
| 162 | + touch #{bundled_app("canary")} |
| 163 | + RUBY |
| 164 | + |
| 165 | + FileUtils.chmod("+x", file) |
| 166 | + |
| 167 | + bundle :lock, :raise_on_error => false |
| 168 | + |
| 169 | + expect(Pathname.new(bundled_app("canary"))).not_to exist |
| 170 | + end |
151 | 171 | end |
0 commit comments