-
Notifications
You must be signed in to change notification settings - Fork 28.2k
/
test-policy-manifest.js
83 lines (69 loc) · 2.62 KB
/
test-policy-manifest.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
common.requireNoPackageJSONAbove();
const assert = require('assert');
const { spawnSync } = require('child_process');
const fixtures = require('../common/fixtures.js');
{
const policyFilepath = fixtures.path('policy-manifest', 'invalid.json');
const result = spawnSync(process.execPath, [
'--experimental-policy',
policyFilepath,
'./fhqwhgads.js',
]);
assert.notStrictEqual(result.status, 0);
const stderr = result.stderr.toString();
assert.match(stderr, /ERR_MANIFEST_INVALID_SPECIFIER/);
assert.match(stderr, /pattern needs to have a single trailing "\*"/);
}
{
const policyFilepath = fixtures.path('policy-manifest', 'onerror-exit.json');
const result = spawnSync(process.execPath, [
'--experimental-policy',
policyFilepath,
'-e',
'require("os").cpus()',
]);
assert.notStrictEqual(result.status, 0);
const stderr = result.stderr.toString();
assert.match(stderr, /ERR_MANIFEST_DEPENDENCY_MISSING/);
assert.match(stderr, /does not list module as a dependency specifier for conditions: require, node, node-addons/);
}
{
const policyFilepath = fixtures.path('policy-manifest', 'onerror-exit.json');
const mainModuleBypass = fixtures.path('policy-manifest', 'main-module-bypass.js');
const result = spawnSync(process.execPath, [
'--experimental-policy',
policyFilepath,
mainModuleBypass,
]);
assert.notStrictEqual(result.status, 0);
const stderr = result.stderr.toString();
assert.match(stderr, /ERR_MANIFEST_DEPENDENCY_MISSING/);
assert.match(stderr, /does not list os as a dependency specifier for conditions: require, node, node-addons/);
}
{
const policyFilepath = fixtures.path('policy-manifest', 'onerror-resource-exit.json');
const objectDefinePropertyBypass = fixtures.path('policy-manifest', 'object-define-property-bypass.js');
const result = spawnSync(process.execPath, [
'--experimental-policy',
policyFilepath,
objectDefinePropertyBypass,
]);
assert.strictEqual(result.status, 0);
}
{
const policyFilepath = fixtures.path('policy-manifest', 'onerror-exit.json');
const mainModuleBypass = fixtures.path('policy-manifest', 'main-module-proto-bypass.js');
const result = spawnSync(process.execPath, [
'--experimental-policy',
policyFilepath,
mainModuleBypass,
]);
assert.notStrictEqual(result.status, 0);
const stderr = result.stderr.toString();
assert.match(stderr, /ERR_MANIFEST_DEPENDENCY_MISSING/);
assert.match(stderr, /does not list os as a dependency specifier for conditions: require, node, node-addons/);
}