1
- import { promiseError } from "@kwsites/promise-result" ;
2
- import { assertExecutedCommands , assertGitError , closeWithSuccess , newSimpleGit } from "./__fixtures__" ;
3
-
4
- describe ( "blockUnsafeOperationsPlugin" , ( ) => {
5
-
1
+ import { promiseError } from '@kwsites/promise-result' ;
2
+ import {
3
+ assertExecutedCommands ,
4
+ assertGitError ,
5
+ closeWithSuccess ,
6
+ newSimpleGit ,
7
+ } from './__fixtures__' ;
8
+
9
+ describe ( 'blockUnsafeOperationsPlugin' , ( ) => {
6
10
it . each ( [
7
- [ " cmd" , " --upload-pack=touch /tmp/pwn0" ] ,
8
- [ " cmd" , " --receive-pack=touch /tmp/pwn1" ] ,
9
- [ " clone" , " -u touch /tmp/pwn" ]
10
- ] ) ( " allows %s %s only when using override" , async ( cmd , option ) => {
11
+ [ ' cmd' , ' --upload-pack=touch /tmp/pwn0' ] ,
12
+ [ ' cmd' , ' --receive-pack=touch /tmp/pwn1' ] ,
13
+ [ ' clone' , ' -u touch /tmp/pwn' ] ,
14
+ ] ) ( ' allows %s %s only when using override' , async ( cmd , option ) => {
11
15
assertGitError (
12
16
await promiseError ( newSimpleGit ( { unsafe : { } } ) . raw ( cmd , option ) ) ,
13
- " allowUnsafePack"
17
+ ' allowUnsafePack'
14
18
) ;
15
19
16
20
const err = promiseError (
@@ -22,76 +26,63 @@ describe("blockUnsafeOperationsPlugin", () => {
22
26
assertExecutedCommands ( cmd , option ) ;
23
27
} ) ;
24
28
25
- it ( " allows -u for non-clone commands" , async ( ) => {
29
+ it ( ' allows -u for non-clone commands' , async ( ) => {
26
30
const git = newSimpleGit ( { unsafe : { } } ) ;
27
- const err = promiseError (
28
- git . raw ( "push" , "-u" , "origin/main" )
29
- ) ;
31
+ const err = promiseError ( git . raw ( 'push' , '-u' , 'origin/main' ) ) ;
30
32
31
33
await closeWithSuccess ( ) ;
32
34
expect ( await err ) . toBeUndefined ( ) ;
33
- assertExecutedCommands ( " push" , "-u" , " origin/main" ) ;
35
+ assertExecutedCommands ( ' push' , '-u' , ' origin/main' ) ;
34
36
} ) ;
35
37
36
- it ( " blocks -u for clone command" , async ( ) => {
38
+ it ( ' blocks -u for clone command' , async ( ) => {
37
39
const git = newSimpleGit ( { unsafe : { } } ) ;
38
- const err = promiseError (
39
- git . clone ( "-u touch /tmp/pwn" , "file:///tmp/zero12" )
40
- ) ;
40
+ const err = promiseError ( git . clone ( '-u touch /tmp/pwn' , 'file:///tmp/zero12' ) ) ;
41
41
42
- assertGitError ( await err , " allowUnsafePack" ) ;
42
+ assertGitError ( await err , ' allowUnsafePack' ) ;
43
43
} ) ;
44
44
45
- it ( " allows -u for clone command with override" , async ( ) => {
45
+ it ( ' allows -u for clone command with override' , async ( ) => {
46
46
const git = newSimpleGit ( { unsafe : { allowUnsafePack : true } } ) ;
47
- const err = promiseError (
48
- git . clone ( "-u touch /tmp/pwn" , "file:///tmp/zero12" )
49
- ) ;
47
+ const err = promiseError ( git . clone ( '-u touch /tmp/pwn' , 'file:///tmp/zero12' ) ) ;
50
48
51
49
await closeWithSuccess ( ) ;
52
50
expect ( await err ) . toBeUndefined ( ) ;
53
- assertExecutedCommands ( " clone" , " -u touch /tmp/pwn" , " file:///tmp/zero12" ) ;
51
+ assertExecutedCommands ( ' clone' , ' -u touch /tmp/pwn' , ' file:///tmp/zero12' ) ;
54
52
} ) ;
55
53
56
- it ( " blocks pull --upload-pack" , async ( ) => {
54
+ it ( ' blocks pull --upload-pack' , async ( ) => {
57
55
const git = newSimpleGit ( { unsafe : { } } ) ;
58
- const err = await promiseError (
59
- git . pull ( "--upload-pack=touch /tmp/pwn0" , "master" )
60
- ) ;
56
+ const err = await promiseError ( git . pull ( '--upload-pack=touch /tmp/pwn0' , 'master' ) ) ;
61
57
62
- assertGitError ( err , " allowUnsafePack" ) ;
58
+ assertGitError ( err , ' allowUnsafePack' ) ;
63
59
} ) ;
64
60
65
- it ( " blocks push --receive-pack" , async ( ) => {
61
+ it ( ' blocks push --receive-pack' , async ( ) => {
66
62
const git = newSimpleGit ( { unsafe : { } } ) ;
67
- const err = await promiseError (
68
- git . push ( "--receive-pack=touch /tmp/pwn1" , "master" )
69
- ) ;
63
+ const err = await promiseError ( git . push ( '--receive-pack=touch /tmp/pwn1' , 'master' ) ) ;
70
64
71
- assertGitError ( err , " allowUnsafePack" ) ;
65
+ assertGitError ( err , ' allowUnsafePack' ) ;
72
66
} ) ;
73
67
74
- it ( " blocks raw --upload-pack" , async ( ) => {
68
+ it ( ' blocks raw --upload-pack' , async ( ) => {
75
69
const git = newSimpleGit ( { unsafe : { } } ) ;
76
- const err = await promiseError ( git . raw ( " pull" , `--upload-pack=touch /tmp/pwn0` ) ) ;
70
+ const err = await promiseError ( git . raw ( ' pull' , `--upload-pack=touch /tmp/pwn0` ) ) ;
77
71
78
- assertGitError ( err , " allowUnsafePack" ) ;
72
+ assertGitError ( err , ' allowUnsafePack' ) ;
79
73
} ) ;
80
74
81
- it ( " blocks raw --receive-pack" , async ( ) => {
75
+ it ( ' blocks raw --receive-pack' , async ( ) => {
82
76
const git = newSimpleGit ( { unsafe : { } } ) ;
83
- const err = await promiseError ( git . raw ( " push" , `--receive-pack=touch /tmp/pwn1` ) ) ;
77
+ const err = await promiseError ( git . raw ( ' push' , `--receive-pack=touch /tmp/pwn1` ) ) ;
84
78
85
- assertGitError ( err , " allowUnsafePack" ) ;
79
+ assertGitError ( err , ' allowUnsafePack' ) ;
86
80
} ) ;
87
81
88
- it ( " blocks listRemote --upload-pack" , async ( ) => {
82
+ it ( ' blocks listRemote --upload-pack' , async ( ) => {
89
83
const git = newSimpleGit ( { unsafe : { } } ) ;
90
- const err = await promiseError (
91
- git . listRemote ( [ "--upload-pack=touch /tmp/pwn2" , "main" ] )
92
- ) ;
84
+ const err = await promiseError ( git . listRemote ( [ '--upload-pack=touch /tmp/pwn2' , 'main' ] ) ) ;
93
85
94
- assertGitError ( err , " allowUnsafePack" ) ;
86
+ assertGitError ( err , ' allowUnsafePack' ) ;
95
87
} ) ;
96
-
97
88
} ) ;
0 commit comments