@mongodb-js/sbom-tools 0.2.1 → 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 CHANGED
@@ -1,3 +1,222 @@
1
1
  # @mongodb-js/sbom-tools
2
2
 
3
3
  Utilities to generate sbom reports for webpack bundles.
4
+
5
+ ## Reporting of 3rd party vulnerabilities and licenses
6
+
7
+ This package exports `WebpackDependenciesPlugin`, a shared webpack plugin that reports bundled dependencies and licenses as a json file for each bundle.
8
+
9
+ And exposes a `mongodb-sbom-tools` binary providing the following commands:
10
+
11
+ - `generate-vulnerability-report`: Generates a report of vulnerabilities from the output of snyk test and a dependencies json file containing all the dependencies.
12
+ - `generate-3rd-party-notices`: Generates a 3rd party notices file based on the licenses information collected by the WebpackDependenciesPlugin. Also validates the licenses.
13
+ - `scan-node-js`: A script to produce a list of vulnerabilities affecting a Node.js version in the same format as snyk test (useful as we are redistributing Node.js with mongosh).
14
+
15
+ ### `WebpackDependenciesPlugin`
16
+
17
+ This plugin taps in the webpack compilation, collects the modules from 3rd party dependencies as they are resolved and writes an output file containing metadata about dependencies and licenses included in the bundle. The plugin ignores dependencies that are removed from the bundle via resolve: `{alias: {<dependency>: false}}`.
18
+
19
+ Setting `includeExternalProductionDependencies` to true the plugin will also include recursively any production and optional dependencies listed in the `package.json`, regardless of their inclusion in the bundle.
20
+
21
+ #### Usage
22
+
23
+ ```js
24
+ // webpack.config.js
25
+
26
+ const webpackDependenciesPlugin = new WebpackDependenciesPlugin({
27
+ outputFilename: 'dependencies.json',
28
+ includePackages: ['electron'],
29
+ includeExternalProductionDependencies: true,
30
+ });
31
+
32
+
33
+ module.exports = { ..., plugins: [buildInfoPlugin] }
34
+ ```
35
+
36
+ **Example Output**
37
+
38
+ ```json
39
+ dependencies.json
40
+
41
+ [{
42
+ "name": "@aws-sdk/client-cognito-identity",
43
+ "version": "3.267.0",
44
+ "name": "@aws-sdk/client-cognito-identity",
45
+ "version": "3.321.1",
46
+ "license": "Apache-2.0",
47
+ "path": ".../node_modules/@aws-sdk/client-cognito-identity",
48
+ "licenseFiles": [
49
+ {
50
+ "filename": "LICENSE",
51
+ "content": "..."
52
+ }
53
+ ]
54
+ }, ...]
55
+ ```
56
+
57
+ ### `generate-vulnerability-report` command
58
+
59
+ Outputs a markdown report of vulnerabilities given one or more `dependencies.json` files and the output of one or more multiple `snyk test`.
60
+
61
+ #### Usage
62
+
63
+ ```
64
+ Usage: bin generate-vulnerability-report [options]
65
+
66
+ Generate vulnerabilities report
67
+
68
+ Options:
69
+ --dependencies <paths> Comma-separated list of dependency files (default: [])
70
+ --snyk-reports <paths> Comma-separated list of snyk
71
+ result files (default: [])
72
+ --fail-on [level] Fail on the specified severity
73
+ level
74
+
75
+ -h, --help display help for command
76
+ ```
77
+
78
+ **Example output:**
79
+
80
+ ```md
81
+ | dep@version | id | score | fixed in | origin | ignored |
82
+ | ------------ | --------------------- | ------------ | -------- | -------------------- | ------- |
83
+ | jquery@2.2.4 | SNYK-JS-JQUERY-567880 | 6.5 (Medium) | 3.5.0 | - |
84
+ | got@10.7.0 | SNYK-JS-GOT-2932019 | 5.4 (Medium) | 11.8.5 | Ignored. Reason: ... |
85
+ ```
86
+
87
+ #### Ignored vulnerabilities
88
+
89
+ The `generate-vulnerability-report` command must run from a directory containing a `.snyk` policy file. The Snyk’s policy rules are applied to determine if a vulnerability must be reported as ignored or not.
90
+
91
+ Ignored vulnerabilities won’t cause the report to fail with an error when `--fail-on` is specified.
92
+
93
+ #### Fail on
94
+
95
+ `--fail-on` configures the command to fail with an error if the report contains a vulnerability that:
96
+
97
+ - Does not have a known severity
98
+ - Has a score greater or equal to the specified severity
99
+ - Is not ignored
100
+ - Has a know remediation path (the “fixed in” column is not empty)
101
+
102
+ ### `generate-3rd-party-notices` command
103
+
104
+ Takes one or more dependencies.json files and generates a markdown report for 3rd party licenses. Validates that licenses are among the list of allowed licenses.
105
+
106
+ When the command encounters a package with a license that is not allowed, the generation breaks. False positives can be ignored by excluding or overriding the license for specific packages or organizations.
107
+
108
+ The following licenses are allowed:
109
+
110
+ - `MIT`
111
+ - `0BSD`
112
+ - `BSD-2-Clause`
113
+ - `BSD-3-Clause`
114
+ - `BSD-4-Clause`
115
+ - `Apache-2.0`
116
+ - `ISC`
117
+ - `CC-BY-4.0`
118
+ - `WTFPL`
119
+ - `OFL-1.1`
120
+ - `Unlicense`
121
+
122
+ The validation can be tweaked with a configuration file (by default `${cwd}/licenses.json`). The configuration allows ignoring certain orgs and packages, and overriding licenses for specific dependencies.
123
+
124
+ Overrides and excluded packages are checked for existence inside the `dependencies.json` in order to avoid forgetting exceptions on removed dependencies.
125
+
126
+ #### Usage
127
+
128
+ ```
129
+ Usage: bin generate-3rd-party-notices [options]
130
+
131
+ Generate third-party notices
132
+
133
+ Options:
134
+ --product <productName> Product name
135
+ --config [config] Path of the configuration file (default:
136
+ "licenses.json")
137
+ --dependencies <paths> Comma-separated list of dependency files
138
+ (default: [])
139
+ -h, --help display help for command
140
+ ```
141
+
142
+ **Example config:**
143
+
144
+ ```json
145
+ {
146
+ "ignoredOrgs": ["@mongodb-js", "@leafygreen-ui", "@mongosh"],
147
+ "ignoredPackages": [],
148
+ "licenseOverrides": {
149
+ "@segment/loosely-validate-event@2.0.0": "MIT",
150
+ "component-event@0.1.4": "MIT",
151
+ "delegate-events@1.1.1": "MIT",
152
+ "events-mixin@1.3.0": "MIT",
153
+ "sprintf@0.1.3": "BSD-3-Clause"
154
+ }
155
+ }
156
+ ```
157
+
158
+ **Example output:**
159
+
160
+ ```md
161
+ The following third-party software is used by and included in **Mongodb Compass**.
162
+ This document was automatically generated on Sun May 14 2023.
163
+
164
+ ## List of dependencies
165
+
166
+ | Package | Version | License |
167
+ | --------------------------------------------------------------------------------------------------------- | ------- | ---------- |
168
+ | **[@aws-sdk/client-cognito-identity](#5416a8cf83b6af5965b709a5538b4b4590f0a081e36cbd99a1af945d73034f1a)** | 3.321.1 | Apache-2.0 |
169
+
170
+ ...
171
+
172
+ ## Package details
173
+
174
+ <a id="5416a8cf83b6af5965b709a5538b4b4590f0a081e36cbd99a1af945d73034f1a"></a>
175
+
176
+ ### [@aws-sdk/client-cognito-identity](https://www.npmjs.com/package/@aws-sdk/client-cognito-identity) (version 3.321.1)
177
+
178
+ License tags: Apache-2.0
179
+
180
+ License files:
181
+
182
+ - LICENSE:
183
+
184
+ Apache License
185
+ Version 2.0, January 2004
186
+ http://www.apache.org/licenses/
187
+
188
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
189
+
190
+ ...
191
+ ```
192
+
193
+ ### Scan-node-js command
194
+
195
+ This command scans a Node.js version for known vulnerabilities and produces a report that is conforming to the snyk test output format and can be used with `generate-vulnerability-report`.
196
+
197
+ `scan-node-js` fails with an error if the Node.js version is not officially supported anymore. Otherwise it builds a list of vulnerability scanning the database published by the Node.js `security-wg` https://raw.githubusercontent.com/nodejs/security-wg/main/vuln/core/index.json, and enriching it with cvss from the nvd.nist.gov database.
198
+
199
+ The output reports vulnerabilities as they would have been found in a “fake” `.node.js` npm package, with the recommended `NSWG-COR-*`. That is useful in conjunction with `generate-vulnerability-report` as it allows the use of the same policies for ignoring vulnerabilities and includes Node.js in the report as any other package.
200
+
201
+ #### Usage
202
+
203
+ ```
204
+ Usage: bin scan-node-js [options]
205
+
206
+ Scan node.js version for known vulnerabilities
207
+
208
+ Options:
209
+ --version <version> Path to the node.js security-wg core
210
+ database of vulnerabilities
211
+ -h, --help display help for command
212
+ ```
213
+
214
+ Use in conjunction with generate-vulnerability-report:
215
+
216
+ ```sh
217
+ echo '[{name: ".node.js", version:"'"$NODE_JS_VERSION"'"}]' > node-js-dep.json
218
+ mongodb-sbom-tools scan-node-js --version=$NODE_JS_VERSION > node-js-vuln.json
219
+
220
+ mongodb-sbom-tools generate-vulnerability-report
221
+ --dependencies=node-js-vuln.json --snyk-report=node-js-vuln.json
222
+ ```
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require('../dist/bin.js');
3
+ const { main } = require('../dist/bin.js');
4
+ main(process.argv);
package/dist/bin.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export {};
1
+ export declare function main(argv: string[]): void;
2
2
  //# sourceMappingURL=bin.d.ts.map
package/dist/bin.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AAKA,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAKzC"}
package/dist/bin.js CHANGED
@@ -1,46 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.main = void 0;
3
4
  const commander_1 = require("commander");
4
5
  const generate_third_party_notices_1 = require("./commands/generate-third-party-notices");
5
6
  const generate_vulnerability_report_1 = require("./commands/generate-vulnerability-report");
6
7
  const scan_node_js_1 = require("./commands/scan-node-js");
7
- function commaSeparatedList(value) {
8
- return value.split(',');
8
+ function main(argv) {
9
+ commander_1.program.addCommand(generate_vulnerability_report_1.command);
10
+ commander_1.program.addCommand(generate_third_party_notices_1.command);
11
+ commander_1.program.addCommand(scan_node_js_1.command);
12
+ commander_1.program.parse(argv);
9
13
  }
10
- commander_1.program
11
- .command('generate-vulnerability-report')
12
- .description('Generate vulnerabilities report')
13
- .option('--dependencies <paths>', 'Comma-separated list of dependency files', commaSeparatedList, [])
14
- .option('--snyk-reports <paths>', 'Comma-separated list of snyk result files', commaSeparatedList, [])
15
- .option('--fail-on [level]', 'Fail on the specified severity level')
16
- .action(async (options) => {
17
- await (0, generate_vulnerability_report_1.generateVulnerabilityReport)({
18
- dependencyFiles: options.dependencies,
19
- snykReports: options.snykReports,
20
- failOn: options.failOn,
21
- });
22
- });
23
- commander_1.program
24
- .command('generate-3rd-party-notices')
25
- .description('Generate third-party notices')
26
- .option('--product <productName>', 'Product name')
27
- .option('--config [config]', 'Path of the configuration file', 'licenses.json')
28
- .option('--dependencies <paths>', 'Comma-separated list of dependency files', commaSeparatedList, [])
29
- .action(async (options) => {
30
- await (0, generate_third_party_notices_1.generate3rdPartyNotices)({
31
- productName: options.product,
32
- dependencyFiles: options.dependencies,
33
- configPath: options.config,
34
- });
35
- });
36
- commander_1.program
37
- .command('scan-node-js')
38
- .description('Scan node.js version for known vulnerabilities')
39
- .option('--version <version>', 'Path to the node.js security-wg core database of vulnerabilities')
40
- .action(async (options) => {
41
- await (0, scan_node_js_1.scanNodeJs)({
42
- version: options.version,
43
- });
44
- });
45
- commander_1.program.parse(process.argv);
14
+ exports.main = main;
46
15
  //# sourceMappingURL=bin.js.map
package/dist/bin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";;AAAA,yCAAoC;AACpC,0FAAkF;AAClF,4FAAuF;AACvF,0DAAqD;AAErD,SAAS,kBAAkB,CAAC,KAAa;IACvC,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED,mBAAO;KACJ,OAAO,CAAC,+BAA+B,CAAC;KACxC,WAAW,CAAC,iCAAiC,CAAC;KAC9C,MAAM,CACL,wBAAwB,EACxB,0CAA0C,EAC1C,kBAAkB,EAClB,EAAE,CACH;KACA,MAAM,CACL,wBAAwB,EACxB,2CAA2C,EAC3C,kBAAkB,EAClB,EAAE,CACH;KACA,MAAM,CAAC,mBAAmB,EAAE,sCAAsC,CAAC;KACnE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,MAAM,IAAA,2DAA2B,EAAC;QAChC,eAAe,EAAE,OAAO,CAAC,YAAY;QACrC,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,mB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import type { Package } from '../get-package-info';
2
+ import { Command } from 'commander';
2
3
  export declare function printLicenseInformation(productName: string, packages: Package[]): string;
3
- export declare function generate3rdPartyNotices({ productName, dependencyFiles, configPath, }: {
4
+ export declare function generate3rdPartyNotices({ productName, dependencyFiles, configPath, printResult, }: {
4
5
  productName: string;
5
6
  dependencyFiles: string[];
6
7
  configPath?: string;
8
+ printResult?: (result: string) => void;
7
9
  }): Promise<void>;
10
+ export declare const command: Command;
8
11
  //# sourceMappingURL=generate-third-party-notices.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-third-party-notices.d.ts","sourceRoot":"","sources":["../../src/commands/generate-third-party-notices.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AA6LnD,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,EAAE,GAClB,MAAM,CAuDR;AAyCD,wBAAsB,uBAAuB,CAAC,EAC5C,WAAW,EACX,eAAe,EACf,UAAU,GACX,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQhB"}
1
+ {"version":3,"file":"generate-third-party-notices.d.ts","sourceRoot":"","sources":["../../src/commands/generate-third-party-notices.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwGpC,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,EAAE,GAClB,MAAM,CAuDR;AA6CD,wBAAsB,uBAAuB,CAAC,EAC5C,WAAW,EACX,eAAe,EACf,UAAU,EACV,WAAW,GACZ,EAAE;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,GAAG,OAAO,CAAC,IAAI,CAAC,CAShB;AAMD,eAAO,MAAM,OAAO,SAoBhB,CAAC"}
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generate3rdPartyNotices = exports.printLicenseInformation = void 0;
6
+ exports.command = exports.generate3rdPartyNotices = exports.printLicenseInformation = void 0;
7
7
  const crypto_1 = __importDefault(require("crypto"));
8
8
  const spdx_satisfies_1 = __importDefault(require("spdx-satisfies"));
9
- const find_up_1 = __importDefault(require("find-up"));
10
9
  const fs_1 = require("fs");
11
10
  const load_dependency_files_1 = require("../load-dependency-files");
12
- const cross_spawn_1 = __importDefault(require("cross-spawn"));
11
+ const commander_1 = require("commander");
13
12
  const ALLOWED_LICENSES = [
14
13
  'MIT',
15
14
  '0BSD',
@@ -23,32 +22,12 @@ const ALLOWED_LICENSES = [
23
22
  'OFL-1.1',
24
23
  'Unlicense',
25
24
  ];
26
- function checkOverrides(packagesToCheck, packageLockJson) {
27
- const allDepsInLock = new Set();
28
- const traverseDependencies = (dependencies) => {
29
- for (const packageName in dependencies) {
30
- const packageInfo = dependencies[packageName];
31
- allDepsInLock.add(`${packageName}@${packageInfo.version}`);
32
- if (packageInfo.dependencies) {
33
- traverseDependencies(packageInfo.dependencies);
34
- }
35
- }
36
- };
37
- traverseDependencies(packageLockJson.dependencies);
25
+ function checkOverrides(packagesToCheck, dependencies) {
26
+ const depsSet = new Set(dependencies.map(({ name, version }) => `${name}@${version}`));
38
27
  for (const packageName of packagesToCheck) {
39
- if (!allDepsInLock.has(packageName)) {
40
- throw new Error(`The package "${packageName}" is not installed, please remove it from the configured ignoredPackages or licenseOverrides.`);
41
- }
42
- }
43
- }
44
- async function readPackageLock() {
45
- const packageLockJsonPath = await (0, find_up_1.default)('package-lock.json');
46
- if (packageLockJsonPath) {
47
- const packageLock = JSON.parse(await fs_1.promises.readFile(packageLockJsonPath, 'utf-8'));
48
- if (packageLock.lockfileVersion !== 2) {
49
- throw new Error('Invalid package-lock.json version: !== 2');
28
+ if (!depsSet.has(packageName)) {
29
+ throw new Error(`The package "${packageName}" is not appearing in the dependencies, please remove it from the configured ignoredPackages or licenseOverrides.`);
50
30
  }
51
- return { path: packageLockJsonPath, content: packageLock };
52
31
  }
53
32
  }
54
33
  function id(pkg) {
@@ -96,39 +75,13 @@ function validatePackage(pkg) {
96
75
  }
97
76
  });
98
77
  }
99
- function getMonorepoPackages(packageLock) {
100
- var _a, _b;
101
- if (!((_b = (_a = packageLock === null || packageLock === void 0 ? void 0 : packageLock.packages) === null || _a === void 0 ? void 0 : _a[''].workspaces) === null || _b === void 0 ? void 0 : _b.length)) {
102
- return [];
103
- }
104
- const output = cross_spawn_1.default.sync('npm', ['query', '.workspace'], {
105
- encoding: 'utf-8',
106
- });
107
- if (output.error) {
108
- console.error('Error executing command:', output.error);
109
- process.exit(1);
110
- }
111
- const packages = JSON.parse(output.stdout);
112
- return packages.map((pkg) => `${pkg.name}@${pkg.version}`);
113
- }
114
78
  async function readConfig(configPath) {
115
- var _a, _b, _c, _d, _e;
116
- const packageLock = await readPackageLock();
117
- const monorepoPackages = getMonorepoPackages(packageLock === null || packageLock === void 0 ? void 0 : packageLock.content);
79
+ var _a, _b, _c;
118
80
  const originalConfig = JSON.parse(await fs_1.promises.readFile(configPath, 'utf-8'));
119
- if (packageLock === null || packageLock === void 0 ? void 0 : packageLock.content) {
120
- checkOverrides([
121
- ...((_a = originalConfig.ignoredPackages) !== null && _a !== void 0 ? _a : []),
122
- ...Object.keys((_b = originalConfig.licenseOverrides) !== null && _b !== void 0 ? _b : {}),
123
- ], packageLock.content);
124
- }
125
81
  return Promise.resolve({
126
- ignoredOrgs: [...((_c = originalConfig.ignoredOrgs) !== null && _c !== void 0 ? _c : [])],
127
- ignoredPackages: [
128
- ...((_d = originalConfig.ignoredPackages) !== null && _d !== void 0 ? _d : []),
129
- ...(monorepoPackages !== null && monorepoPackages !== void 0 ? monorepoPackages : []),
130
- ],
131
- licenseOverrides: { ...((_e = originalConfig.licenseOverrides) !== null && _e !== void 0 ? _e : {}) },
82
+ ignoredOrgs: [...((_a = originalConfig.ignoredOrgs) !== null && _a !== void 0 ? _a : [])],
83
+ ignoredPackages: [...((_b = originalConfig.ignoredPackages) !== null && _b !== void 0 ? _b : [])],
84
+ licenseOverrides: { ...((_c = originalConfig.licenseOverrides) !== null && _c !== void 0 ? _c : {}) },
132
85
  });
133
86
  }
134
87
  function printLicenseInformation(productName, packages) {
@@ -185,15 +138,19 @@ exports.printLicenseInformation = printLicenseInformation;
185
138
  function validatePackages(packages) {
186
139
  const invalidPackages = packages.filter((pkg) => !validatePackage(pkg));
187
140
  if (invalidPackages.length) {
188
- console.error(`Generation failed, found ${invalidPackages.length} invalid packages:`);
189
- for (const pkg of invalidPackages) {
190
- console.error(`${pkg.name}@${pkg.version}:`, licenseSpdx(pkg));
191
- }
192
- process.exit(1);
141
+ throw new Error([
142
+ `Generation failed, found ${invalidPackages.length} invalid packages:`,
143
+ ...invalidPackages.map((pkg) => `- ${pkg.name}@${pkg.version}: ${licenseSpdx(pkg)}`),
144
+ ].join('\n'));
193
145
  }
194
146
  }
195
- async function loadPackages(dependencyFiles, config) {
196
- return (await (0, load_dependency_files_1.loadDependencyFiles)(dependencyFiles))
147
+ function applyConfig(dependencies, config) {
148
+ var _a, _b;
149
+ checkOverrides([
150
+ ...((_a = config.ignoredPackages) !== null && _a !== void 0 ? _a : []),
151
+ ...Object.keys((_b = config.licenseOverrides) !== null && _b !== void 0 ? _b : {}),
152
+ ], dependencies);
153
+ return dependencies
197
154
  .filter((pkg) => !(config.ignoredOrgs || []).some((org) => pkg.name.startsWith(org + '/')))
198
155
  .filter((pkg) => !(config.ignoredPackages || []).includes(`${pkg.name}@${pkg.version}`))
199
156
  .map((pkg) => {
@@ -204,12 +161,28 @@ async function loadPackages(dependencyFiles, config) {
204
161
  });
205
162
  });
206
163
  }
207
- async function generate3rdPartyNotices({ productName, dependencyFiles, configPath, }) {
164
+ async function generate3rdPartyNotices({ productName, dependencyFiles, configPath, printResult, }) {
208
165
  const config = await readConfig(configPath !== null && configPath !== void 0 ? configPath : 'licenses.json');
209
- const packages = await loadPackages(dependencyFiles, config);
166
+ const allPackages = await (0, load_dependency_files_1.loadDependencyFiles)(dependencyFiles);
167
+ const packages = applyConfig(allPackages, config);
210
168
  validatePackages(packages);
211
169
  const markdown = printLicenseInformation(productName, packages);
212
- console.info(markdown);
170
+ (printResult !== null && printResult !== void 0 ? printResult : console.info)(markdown);
213
171
  }
214
172
  exports.generate3rdPartyNotices = generate3rdPartyNotices;
173
+ function commaSeparatedList(value) {
174
+ return value.split(',');
175
+ }
176
+ exports.command = new commander_1.Command('generate-3rd-party-notices')
177
+ .description('Generate third-party notices')
178
+ .option('--product <productName>', 'Product name')
179
+ .option('--config [config]', 'Path of the configuration file', 'licenses.json')
180
+ .option('--dependencies <paths>', 'Comma-separated list of dependency files', commaSeparatedList, [])
181
+ .action(async (options) => {
182
+ await generate3rdPartyNotices({
183
+ productName: options.product,
184
+ dependencyFiles: options.dependencies,
185
+ configPath: options.config,
186
+ });
187
+ });
215
188
  //# sourceMappingURL=generate-third-party-notices.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-third-party-notices.js","sourceRoot":"","sources":["../../src/commands/generate-third-party-notices.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,oEAA2C;AAC3C,sDAA6B;AAC7B,2BAAoC;AAGpC,oEAA+D;AAC/D,8DAAqC;AAsBrC,MAAM,gBAAgB,GAAG;IACvB,KAAK;IACL,MAAM;IACN,cAAc;IACd,cAAc;IACd,cAAc;IACd,YAAY;IACZ,KAAK;IACL,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,mCAC7D,GAAG,CAAC,OAAO;SACd,CAAC,CAAA;KAAA,CAAC,CAAC;AACR,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAAC,EAC5C,WAAW,EACX,eAAe,EACf,UAAU,GAKX;IACC,MAAM,MAAM,GAAW,MAAM,UAAU,CAAC,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,eAAe,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAc,MAAM,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAExE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAE3B,MAAM,QAAQ,GAAG,uBAAuB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAChE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC;AAhBD,0DAgBC"}
1
+ {"version":3,"file":"generate-third-party-notices.js","sourceRoot":"","sources":["../../src/commands/generate-third-party-notices.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,oEAA2C;AAE3C,2BAAoC;AAGpC,oEAA+D;AAC/D,yCAAoC;AAQpC,MAAM,gBAAgB,GAAG;IACvB,KAAK;IACL,MAAM;IACN,cAAc;IACd,cAAc;IACd,cAAc;IACd,YAAY;IACZ,KAAK;IACL,WAAW;IACX,OAAO;IACP,SAAS;IACT,WAAW;CACZ,CAAC;AAEF,SAAS,cAAc,CAAC,eAAyB,EAAE,YAAuB;IACxE,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE,CAAC,CAC9D,CAAC;IAEF,KAAK,MAAM,WAAW,IAAI,eAAe,EAAE;QACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CACb,gBAAgB,WAAW,mHAAmH,CAC/I,CAAC;SACH;KACF;AACH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AAE;IACxB,MAAM,uBAAuB,CAAC;QAC5B,WAAW,EAAE,OAAO,CAAC,OAAO;QAC5B,eAAe,EAAE,OAAO,CAAC,YAAY;QACrC,UAAU,EAAE,OAAO,CAAC,MAAM;KAC3B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,23 +1,12 @@
1
+ import type { KnownSeverity, SnykTestProjectResult } from '../snyk-vulnerability';
2
+ import { Command } from 'commander';
1
3
  export declare function loadReports(files: string[]): Promise<SnykTestProjectResult[]>;
2
- declare type SnykTestProjectResult = {
3
- vulnerabilities: SnykVulnerability[];
4
- };
5
- declare type SnykVulnerability = {
6
- moduleName: string;
7
- from: string[];
8
- name: string;
9
- version: string;
10
- cvssScore: number;
11
- severity: 'low' | 'medium' | 'high' | 'critical';
12
- id: string;
13
- url: string;
14
- title: string;
15
- fixedIn: string[];
16
- };
17
4
  export declare function generateVulnerabilityReport(options: {
18
5
  dependencyFiles: string[];
19
6
  snykReports: string[];
20
- failOn: 'low' | 'medium' | 'high' | 'critical';
7
+ snykPolicyPath?: string;
8
+ failOn?: KnownSeverity;
9
+ printResult?: (result: string) => void;
21
10
  }): Promise<void>;
22
- export {};
11
+ export declare const command: Command;
23
12
  //# sourceMappingURL=generate-vulnerability-report.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate-vulnerability-report.d.ts","sourceRoot":"","sources":["../../src/commands/generate-vulnerability-report.ts"],"names":[],"mappings":"AASA,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EAAE,GACd,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAUlC;AAED,aAAK,qBAAqB,GAAG;IAC3B,eAAe,EAAE,iBAAiB,EAAE,CAAC;CACtC,CAAC;AAEF,aAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AA8HF,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;CAChD,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBhB"}
1
+ {"version":3,"file":"generate-vulnerability-report.d.ts","sourceRoot":"","sources":["../../src/commands/generate-vulnerability-report.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EAEtB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,wBAAsB,WAAW,CAC/B,KAAK,EAAE,MAAM,EAAE,GACd,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAUlC;AAiJD,wBAAsB,2BAA2B,CAAC,OAAO,EAAE;IACzD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBhB;AAMD,eAAO,MAAM,OAAO,SAyBhB,CAAC"}