/
common.js
53 lines (49 loc) · 1.23 KB
/
common.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
// @ts-check
const path = require("path");
const { default: Allowlist } = require("../dist/allowlist");
const { mapVulnerabilityLevelInput } = require("../dist/map-vulnerability");
function summaryWithDefault(additions = {}) {
const summary = {
allowlistedModulesFound: [],
allowlistedAdvisoriesFound: [],
allowlistedAdvisoriesNotFound: [],
allowlistedPathsFound: [],
allowlistedModulesNotFound: [],
allowlistedPathsNotFound: [],
failedLevelsFound: [],
advisoriesFound: [],
advisoryPathsFound: [],
};
return { ...summary, ...additions };
}
function config(additions) {
const defaultConfig = {
levels: {
low: false,
moderate: false,
high: false,
critical: false,
},
"report-type": "important",
allowlist: new Allowlist(),
"show-not-found": false,
"retry-count": 5,
directory: "./",
registry: undefined,
"pass-enoaudit": false,
};
const levels = mapVulnerabilityLevelInput(additions.levels || {});
return {
...defaultConfig,
...additions,
levels: { ...defaultConfig.levels, ...levels },
};
}
function testDirectory(s) {
return path.resolve(__dirname, s);
}
module.exports = {
summaryWithDefault,
config,
testDirectory,
};