Commit d27c983 1 parent 99fec61 commit d27c983 Copy full SHA for d27c983
File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,15 @@ def checkout_options
23
23
def self . preprocess_options ( options )
24
24
return options unless options [ :branch ]
25
25
26
+ input = [ options [ :git ] , options [ :commit ] ] . map ( &:to_s )
27
+ invalid = input . compact . any? { |value | value . start_with? ( '--' ) || value . include? ( ' --' ) }
28
+ raise DownloaderError , "Provided unsafe input for git #{ options } ." if invalid
29
+
26
30
command = [ 'ls-remote' ,
31
+ '--' ,
27
32
options [ :git ] ,
28
33
options [ :branch ] ]
34
+
29
35
output = Git . execute_command ( 'git' , command )
30
36
match = commit_from_ls_remote output , options [ :branch ]
31
37
Original file line number Diff line number Diff line change @@ -289,6 +289,12 @@ def ensure_only_one_ref(folder)
289
289
new_options = Downloader . preprocess_options ( options )
290
290
new_options [ :branch ] . should == 'aaaa'
291
291
end
292
+
293
+ it 'throws when proving an invalid input' do
294
+ options = { :git => '--upload-pack=touch ./HELLO1;' , :branch => 'foo' }
295
+ e = lambda { Downloader . preprocess_options ( options ) } . should . raise DownloaderError
296
+ e . message . should . match /Provided unsafe input/
297
+ end
292
298
end
293
299
294
300
describe ':bad input' do
You can’t perform that action at this time.
0 commit comments