-
-
Notifications
You must be signed in to change notification settings - Fork 319
/
Copy pathplugin.unsafe.spec.ts
56 lines (48 loc) · 1.7 KB
/
plugin.unsafe.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { promiseError, promiseResult } from '@kwsites/promise-result';
import {
assertGitError,
createTestContext,
newSimpleGit,
SimpleGitTestContext,
} from '@simple-git/test-utils';
import { GitPluginError } from '../..';
describe('add', () => {
let context: SimpleGitTestContext;
beforeEach(async () => (context = await createTestContext()));
it('allows overriding protocol when opting in to unsafe practices', async () => {
const { threw } = await promiseResult(
newSimpleGit(context.root, { unsafe: { allowUnsafeProtocolOverride: true } }).raw(
'-c',
'protocol.ext.allow=always',
'init'
)
);
expect(threw).toBe(false);
});
it('prevents overriding protocol.ext.allow before the method of a command', async () => {
assertGitError(
await promiseError(context.git.raw('-c', 'protocol.ext.allow=always', 'init')),
'Configuring protocol.allow is not permitted',
GitPluginError
);
});
it('prevents overriding protocol.ext.allow after the method of a command', async () => {
assertGitError(
await promiseError(context.git.raw('init', '-c', 'protocol.ext.allow=always')),
'Configuring protocol.allow is not permitted',
GitPluginError
);
});
it('prevents adding a remote with vulnerable ext transport', async () => {
assertGitError(
await promiseError(
context.git.clone(`ext::sh -c touch% /tmp/pwn% >&2`, '/tmp/example-new-repo', [
'-c',
'protocol.ext.allow=always',
])
),
'Configuring protocol.allow is not permitted',
GitPluginError
);
});
});