1
+ import { promiseError } from '@kwsites/promise-result' ;
1
2
import { SimpleGit , TaskOptions } from 'typings' ;
2
- import { assertExecutedCommands , closeWithSuccess , newSimpleGit } from './__fixtures__' ;
3
+ import { assertExecutedCommands , assertGitError , closeWithSuccess , newSimpleGit } from './__fixtures__' ;
3
4
4
5
describe ( 'clone' , ( ) => {
5
6
let git : SimpleGit ;
@@ -15,7 +16,7 @@ describe('clone', () => {
15
16
16
17
beforeEach ( ( ) => git = newSimpleGit ( ) ) ;
17
18
18
- it . each ( cloneTests ) ( 'callbacks - %s %s' , async ( api , name , cloneArgs , executedCommands ) => {
19
+ it . each ( cloneTests ) ( 'callbacks - %s %s' , async ( api , name , cloneArgs , executedCommands ) => {
19
20
const callback = jest . fn ( ) ;
20
21
const queue = ( git [ api ] as any ) ( ...cloneArgs , callback ) ;
21
22
await closeWithSuccess ( name ) ;
@@ -32,5 +33,30 @@ describe('clone', () => {
32
33
expect ( await queue ) . toBe ( name ) ;
33
34
assertExecutedCommands ( ...executedCommands ) ;
34
35
} ) ;
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
+ } ) ;
35
61
} ) ;
36
62
0 commit comments