1+ import { promiseError } from '@kwsites/promise-result' ;
12import { SimpleGit , TaskOptions } from 'typings' ;
2- import { assertExecutedCommands , closeWithSuccess , newSimpleGit } from './__fixtures__' ;
3+ import { assertExecutedCommands , assertGitError , closeWithSuccess , newSimpleGit } from './__fixtures__' ;
34
45describe ( 'clone' , ( ) => {
56 let git : SimpleGit ;
@@ -15,7 +16,7 @@ describe('clone', () => {
1516
1617 beforeEach ( ( ) => git = newSimpleGit ( ) ) ;
1718
18- it . each ( cloneTests ) ( 'callbacks - %s %s' , async ( api , name , cloneArgs , executedCommands ) => {
19+ it . each ( cloneTests ) ( 'callbacks - %s %s' , async ( api , name , cloneArgs , executedCommands ) => {
1920 const callback = jest . fn ( ) ;
2021 const queue = ( git [ api ] as any ) ( ...cloneArgs , callback ) ;
2122 await closeWithSuccess ( name ) ;
@@ -32,5 +33,30 @@ describe('clone', () => {
3233 expect ( await queue ) . toBe ( name ) ;
3334 assertExecutedCommands ( ...executedCommands ) ;
3435 } ) ;
36+
37+ describe ( 'failures' , ( ) => {
38+
39+ it ( 'disallows upload-pack as remote/branch' , async ( ) => {
40+ const error = await promiseError ( git . clone ( 'origin' , '--upload-pack=touch ./foo' ) ) ;
41+
42+ assertGitError ( error , 'potential exploit argument blocked' ) ;
43+ } ) ;
44+
45+ it ( 'disallows upload-pack as varargs' , async ( ) => {
46+ const error = await promiseError ( git . clone ( 'origin' , 'main' , {
47+ '--upload-pack' : 'touch ./foo'
48+ } ) ) ;
49+
50+ assertGitError ( error , 'potential exploit argument blocked' ) ;
51+ } ) ;
52+
53+ it ( 'disallows upload-pack as varargs' , async ( ) => {
54+ const error = await promiseError ( git . clone ( 'origin' , 'main' , [
55+ '--upload-pack' , 'touch ./foo'
56+ ] ) ) ;
57+
58+ assertGitError ( error , 'potential exploit argument blocked' ) ;
59+ } ) ;
60+ } ) ;
3561} ) ;
3662
0 commit comments