@mongodb-js/sbom-tools 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +219 -0
- package/bin/mongodb-sbom-tools.js +2 -1
- package/dist/bin.d.ts +1 -1
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +7 -38
- package/dist/bin.js.map +1 -1
- package/dist/commands/generate-third-party-notices.d.ts +4 -1
- package/dist/commands/generate-third-party-notices.d.ts.map +1 -1
- package/dist/commands/generate-third-party-notices.js +40 -67
- package/dist/commands/generate-third-party-notices.js.map +1 -1
- package/dist/commands/generate-vulnerability-report.d.ts +6 -18
- package/dist/commands/generate-vulnerability-report.d.ts.map +1 -1
- package/dist/commands/generate-vulnerability-report.js +67 -25
- package/dist/commands/generate-vulnerability-report.js.map +1 -1
- package/dist/commands/scan-node-js.d.ts +5 -2
- package/dist/commands/scan-node-js.d.ts.map +1 -1
- package/dist/commands/scan-node-js.js +33 -64
- package/dist/commands/scan-node-js.js.map +1 -1
- package/dist/production-deps.d.ts +2 -2
- package/dist/production-deps.d.ts.map +1 -1
- package/dist/production-deps.js +8 -8
- package/dist/production-deps.js.map +1 -1
- package/dist/snyk-vulnerability.d.ts +69 -0
- package/dist/snyk-vulnerability.d.ts.map +1 -0
- package/dist/snyk-vulnerability.js +87 -0
- package/dist/snyk-vulnerability.js.map +1 -0
- package/dist/webpack-dependencies-plugin.d.ts +5 -6
- package/dist/webpack-dependencies-plugin.d.ts.map +1 -1
- package/dist/webpack-dependencies-plugin.js +21 -16
- package/dist/webpack-dependencies-plugin.js.map +1 -1
- package/package.json +7 -9
- package/dist/commands/severity.d.ts +0 -7
- package/dist/commands/severity.d.ts.map +0 -1
- package/dist/commands/severity.js +0 -31
- package/dist/commands/severity.js.map +0 -1
|
@@ -7,54 +7,59 @@ exports.WebpackDependenciesPlugin = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
-
const minimatch_1 = require("minimatch");
|
|
11
10
|
const production_deps_1 = require("./production-deps");
|
|
12
11
|
const get_package_info_1 = require("./get-package-info");
|
|
13
12
|
const PLUGIN_NAME = 'WebpackDependenciesPlugin';
|
|
14
13
|
class WebpackDependenciesPlugin {
|
|
15
14
|
constructor(options = {}) {
|
|
15
|
+
var _a, _b;
|
|
16
16
|
this.options = options;
|
|
17
17
|
this.pluginName = PLUGIN_NAME;
|
|
18
|
-
this.includePackages = [];
|
|
19
18
|
this.resolvedModules = new Set();
|
|
19
|
+
this.includePackages = [];
|
|
20
20
|
this.handleTap = (compilation) => {
|
|
21
21
|
for (const module of compilation.modules) {
|
|
22
22
|
const resource = module.resource;
|
|
23
23
|
if (resource) {
|
|
24
24
|
const modulePath = resource;
|
|
25
|
-
if (typeof modulePath === 'string' &&
|
|
25
|
+
if (typeof modulePath === 'string' &&
|
|
26
|
+
this.isThirdPartyModule(modulePath)) {
|
|
26
27
|
this.resolvedModules.add(modulePath);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
const includePackages = [
|
|
32
|
+
...(this.includeExternalProductionDependencies
|
|
33
|
+
? (0, production_deps_1.findAllProdDepsTreeLocations)(compilation.compiler.context)
|
|
34
|
+
: []),
|
|
35
|
+
...(this.includePackages || []).map((packageName) => (0, production_deps_1.findPackageLocation)(packageName, compilation.compiler.context)),
|
|
36
|
+
];
|
|
37
|
+
for (const includedPackagePath of includePackages) {
|
|
31
38
|
const packageJsonPath = path_1.default.join(includedPackagePath, 'package.json');
|
|
32
39
|
if (packageJsonPath) {
|
|
33
40
|
this.resolvedModules.add(packageJsonPath);
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
};
|
|
37
|
-
this.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
...(options.includePackages || []).map(production_deps_1.findPackageLocation),
|
|
42
|
-
];
|
|
43
|
-
this.excludedModules = options.excludeModules || [];
|
|
44
|
-
this.outputPath = options.outputFilename || 'dependencies.json';
|
|
44
|
+
this.includeExternalProductionDependencies =
|
|
45
|
+
(_a = options.includeExternalProductionDependencies) !== null && _a !== void 0 ? _a : false;
|
|
46
|
+
this.includePackages = (_b = options.includePackages) !== null && _b !== void 0 ? _b : [];
|
|
47
|
+
this.outputPath = options.outputFilename;
|
|
45
48
|
}
|
|
46
|
-
|
|
47
|
-
return
|
|
49
|
+
isThirdPartyModule(modulePath) {
|
|
50
|
+
return modulePath.split(path_1.default.sep).includes('node_modules');
|
|
48
51
|
}
|
|
49
52
|
apply(compiler) {
|
|
50
53
|
compiler.hooks.shutdown.tapPromise(PLUGIN_NAME, async () => {
|
|
54
|
+
var _a;
|
|
51
55
|
const dependencyList = await Promise.all(Array.from(this.resolvedModules).map(get_package_info_1.getPackageInfo));
|
|
52
56
|
const uniqueList = lodash_1.default.uniqBy(dependencyList, ({ name, version }) => `${name}@${version}`);
|
|
53
57
|
const sortedList = lodash_1.default.sortBy(uniqueList, ({ name, version }) => `${name}@${version}`);
|
|
54
|
-
|
|
58
|
+
const outputPath = (_a = this.outputPath) !== null && _a !== void 0 ? _a : path_1.default.join(compiler.context, 'dependencies.json');
|
|
59
|
+
await fs_1.promises.mkdir(path_1.default.dirname(path_1.default.resolve(outputPath)), {
|
|
55
60
|
recursive: true,
|
|
56
61
|
});
|
|
57
|
-
await fs_1.promises.writeFile(
|
|
62
|
+
await fs_1.promises.writeFile(outputPath, JSON.stringify(sortedList, null, 2));
|
|
58
63
|
});
|
|
59
64
|
compiler.hooks.emit.tap(PLUGIN_NAME, this.handleTap);
|
|
60
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack-dependencies-plugin.js","sourceRoot":"","sources":["../src/webpack-dependencies-plugin.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,2BAAoC;AAEpC,oDAAuB;AAEv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AEtE,MAAM,aAAE,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE;gBACrD,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YAEH,MAAM,aAAE,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AA9ED,8DA8EC;AAED,kBAAe,yBAAyB,CAAC"}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"email": "compass@mongodb.com"
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/mongodb-js/devtools-shared",
|
|
19
|
-
"version": "0.2.
|
|
19
|
+
"version": "0.2.3",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
22
|
"url": "https://github.com/mongodb-js/devtools-shared.git"
|
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
"@mongodb-js/prettier-config-compass": "^0.5.0",
|
|
55
55
|
"@mongodb-js/tsconfig-compass": "^0.6.0",
|
|
56
56
|
"@types/chai": "^4.2.21",
|
|
57
|
-
"@types/cross-spawn": "^6.0.2",
|
|
58
57
|
"@types/lodash": "^4.14.194",
|
|
59
58
|
"@types/mocha": "^9.0.0",
|
|
60
59
|
"@types/node": "^17.0.35",
|
|
@@ -66,24 +65,23 @@
|
|
|
66
65
|
"eslint": "^7.25.0",
|
|
67
66
|
"gen-esm-wrapper": "^1.1.0",
|
|
68
67
|
"mocha": "^8.4.0",
|
|
68
|
+
"nock": "^13.3.1",
|
|
69
69
|
"nyc": "^15.1.0",
|
|
70
70
|
"prettier": "2.3.2",
|
|
71
|
+
"rimraf": "^5.0.1",
|
|
71
72
|
"sinon": "^9.2.3",
|
|
72
|
-
"typescript": "^4.3.5"
|
|
73
|
+
"typescript": "^4.3.5",
|
|
74
|
+
"webpack": "^5.82.0"
|
|
73
75
|
},
|
|
74
76
|
"dependencies": {
|
|
75
77
|
"@pkgjs/nv": "^0.2.1",
|
|
76
|
-
"chalk": "^4.1.2",
|
|
77
78
|
"commander": "^10.0.1",
|
|
78
|
-
"cross-spawn": "^7.0.3",
|
|
79
79
|
"find-up": "^4.1.0",
|
|
80
80
|
"lodash": "^4.17.21",
|
|
81
|
-
"minimatch": "^9.0.0",
|
|
82
81
|
"node-fetch": "^2.6.7",
|
|
83
82
|
"semver": "^7.5.0",
|
|
84
83
|
"snyk-policy": "^2.0.4",
|
|
85
|
-
"spdx-satisfies": "^5.0.1"
|
|
86
|
-
"webpack": "^5.82.0"
|
|
84
|
+
"spdx-satisfies": "^5.0.1"
|
|
87
85
|
},
|
|
88
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "e669a44163ed26c5fad950b7a38301ad04b015ae"
|
|
89
87
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare type KnownSeverity = 'low' | 'medium' | 'high' | 'critical';
|
|
2
|
-
export declare type Severity = KnownSeverity | 'unknown';
|
|
3
|
-
declare type Score = number | undefined;
|
|
4
|
-
export declare function severityToScore(severity: Severity): Score;
|
|
5
|
-
export declare function scoreToSeverity(score: number | undefined): Severity;
|
|
6
|
-
export {};
|
|
7
|
-
//# sourceMappingURL=severity.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"severity.d.ts","sourceRoot":"","sources":["../../src/commands/severity.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AACnE,oBAAY,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAC;AAEjD,aAAK,KAAK,GAAG,MAAM,GAAG,SAAS,CAAC;AAUhC,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAEzD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,QAAQ,CAenE"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.scoreToSeverity = exports.severityToScore = void 0;
|
|
4
|
-
const SEVERITY_TO_SCORE = {
|
|
5
|
-
low: 0,
|
|
6
|
-
medium: 4,
|
|
7
|
-
high: 7,
|
|
8
|
-
critical: 9,
|
|
9
|
-
unknown: undefined,
|
|
10
|
-
};
|
|
11
|
-
function severityToScore(severity) {
|
|
12
|
-
return SEVERITY_TO_SCORE[severity];
|
|
13
|
-
}
|
|
14
|
-
exports.severityToScore = severityToScore;
|
|
15
|
-
function scoreToSeverity(score) {
|
|
16
|
-
if (score === undefined) {
|
|
17
|
-
return 'unknown';
|
|
18
|
-
}
|
|
19
|
-
if (score >= 9) {
|
|
20
|
-
return 'critical';
|
|
21
|
-
}
|
|
22
|
-
if (score >= 7) {
|
|
23
|
-
return 'high';
|
|
24
|
-
}
|
|
25
|
-
if (score >= 4) {
|
|
26
|
-
return 'medium';
|
|
27
|
-
}
|
|
28
|
-
return 'low';
|
|
29
|
-
}
|
|
30
|
-
exports.scoreToSeverity = scoreToSeverity;
|
|
31
|
-
//# sourceMappingURL=severity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"severity.js","sourceRoot":"","sources":["../../src/commands/severity.ts"],"names":[],"mappings":";;;AAKA,MAAM,iBAAiB,GAA4B;IACjD,GAAG,EAAE,CAAC;IACN,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,SAAgB,eAAe,CAAC,QAAkB;IAChD,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe,CAAC,KAAyB;IACvD,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,OAAO,UAAU,CAAC;KACnB;IACD,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,OAAO,MAAM,CAAC;KACf;IACD,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,OAAO,QAAQ,CAAC;KACjB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAfD,0CAeC"}
|