@mongodb-js/sbom-tools 0.2.0
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/LICENSE +201 -0
- package/README.md +3 -0
- package/bin/mongodb-sbom-tools.js +3 -0
- package/dist/.esm-wrapper.mjs +4 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +46 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/generate-third-party-notices.d.ts +8 -0
- package/dist/commands/generate-third-party-notices.d.ts.map +1 -0
- package/dist/commands/generate-third-party-notices.js +214 -0
- package/dist/commands/generate-third-party-notices.js.map +1 -0
- package/dist/commands/generate-vulnerability-report.d.ts +23 -0
- package/dist/commands/generate-vulnerability-report.d.ts.map +1 -0
- package/dist/commands/generate-vulnerability-report.js +100 -0
- package/dist/commands/generate-vulnerability-report.js.map +1 -0
- package/dist/commands/scan-node-js.d.ts +4 -0
- package/dist/commands/scan-node-js.d.ts.map +1 -0
- package/dist/commands/scan-node-js.js +113 -0
- package/dist/commands/scan-node-js.js.map +1 -0
- package/dist/get-package-info.d.ts +38 -0
- package/dist/get-package-info.d.ts.map +1 -0
- package/dist/get-package-info.js +62 -0
- package/dist/get-package-info.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/load-dependency-files.d.ts +5 -0
- package/dist/load-dependency-files.d.ts.map +1 -0
- package/dist/load-dependency-files.js +15 -0
- package/dist/load-dependency-files.js.map +1 -0
- package/dist/production-deps.d.ts +3 -0
- package/dist/production-deps.d.ts.map +1 -0
- package/dist/production-deps.js +81 -0
- package/dist/production-deps.js.map +1 -0
- package/dist/webpack-dependencies-plugin.d.ts +18 -0
- package/dist/webpack-dependencies-plugin.d.ts.map +1 -0
- package/dist/webpack-dependencies-plugin.js +59 -0
- package/dist/webpack-dependencies-plugin.js.map +1 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commander_1 = require("commander");
|
|
4
|
+
const generate_third_party_notices_1 = require("./commands/generate-third-party-notices");
|
|
5
|
+
const generate_vulnerability_report_1 = require("./commands/generate-vulnerability-report");
|
|
6
|
+
const scan_node_js_1 = require("./commands/scan-node-js");
|
|
7
|
+
function commaSeparatedList(value) {
|
|
8
|
+
return value.split(',');
|
|
9
|
+
}
|
|
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);
|
|
46
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +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,mBAAO;KACJ,OAAO,CAAC,4BAA4B,CAAC;KACrC,WAAW,CAAC,8BAA8B,CAAC;KAC3C,MAAM,CAAC,yBAAyB,EAAE,cAAc,CAAC;KACjD,MAAM,CACL,mBAAmB,EACnB,gCAAgC,EAChC,eAAe,CAChB;KACA,MAAM,CACL,wBAAwB,EACxB,0CAA0C,EAC1C,kBAAkB,EAClB,EAAE,CACH;KACA,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,MAAM,IAAA,sDAAuB,EAAC;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;AAEL,mBAAO;KACJ,OAAO,CAAC,cAAc,CAAC;KACvB,WAAW,CAAC,gDAAgD,CAAC;KAC7D,MAAM,CACL,qBAAqB,EACrB,kEAAkE,CACnE;KACA,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,MAAM,IAAA,yBAAU,EAAC;QACf,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,mBAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Package } from '../get-package-info';
|
|
2
|
+
export declare function printLicenseInformation(productName: string, packages: Package[]): string;
|
|
3
|
+
export declare function generate3rdPartyNotices({ productName, dependencyFiles, configPath, }: {
|
|
4
|
+
productName: string;
|
|
5
|
+
dependencyFiles: string[];
|
|
6
|
+
configPath?: string;
|
|
7
|
+
}): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=generate-third-party-notices.d.ts.map
|
|
@@ -0,0 +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;AA4LnD,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"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generate3rdPartyNotices = exports.printLicenseInformation = void 0;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const spdx_satisfies_1 = __importDefault(require("spdx-satisfies"));
|
|
9
|
+
const find_up_1 = __importDefault(require("find-up"));
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const load_dependency_files_1 = require("../load-dependency-files");
|
|
12
|
+
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
13
|
+
const ALLOWED_LICENSES = [
|
|
14
|
+
'MIT',
|
|
15
|
+
'BSD-2-Clause',
|
|
16
|
+
'BSD-3-Clause',
|
|
17
|
+
'BSD-4-Clause',
|
|
18
|
+
'Apache-2.0',
|
|
19
|
+
'ISC',
|
|
20
|
+
'CC-BY-4.0',
|
|
21
|
+
'WTFPL',
|
|
22
|
+
'OFL-1.1',
|
|
23
|
+
'Unlicense',
|
|
24
|
+
];
|
|
25
|
+
function checkOverrides(packagesToCheck, packageLockJson) {
|
|
26
|
+
const allDepsInLock = new Set();
|
|
27
|
+
const traverseDependencies = (dependencies) => {
|
|
28
|
+
for (const packageName in dependencies) {
|
|
29
|
+
const packageInfo = dependencies[packageName];
|
|
30
|
+
allDepsInLock.add(`${packageName}@${packageInfo.version}`);
|
|
31
|
+
if (packageInfo.dependencies) {
|
|
32
|
+
traverseDependencies(packageInfo.dependencies);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
traverseDependencies(packageLockJson.dependencies);
|
|
37
|
+
for (const packageName of packagesToCheck) {
|
|
38
|
+
if (!allDepsInLock.has(packageName)) {
|
|
39
|
+
throw new Error(`The package "${packageName}" is not installed, please remove it from the configured ignoredPackages or licenseOverrides.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function readPackageLock() {
|
|
44
|
+
const packageLockJsonPath = await (0, find_up_1.default)('package-lock.json');
|
|
45
|
+
if (packageLockJsonPath) {
|
|
46
|
+
const packageLock = JSON.parse(await fs_1.promises.readFile(packageLockJsonPath, 'utf-8'));
|
|
47
|
+
if (packageLock.lockfileVersion !== 2) {
|
|
48
|
+
throw new Error('Invalid package-lock.json version: !== 2');
|
|
49
|
+
}
|
|
50
|
+
return { path: packageLockJsonPath, content: packageLock };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function id(pkg) {
|
|
54
|
+
return crypto_1.default
|
|
55
|
+
.createHash('sha256')
|
|
56
|
+
.update(`${pkg.name}@${pkg.version}`)
|
|
57
|
+
.digest('hex');
|
|
58
|
+
}
|
|
59
|
+
function normalizeLicenseProperty(license) {
|
|
60
|
+
if (typeof license === 'object') {
|
|
61
|
+
return license.type || '';
|
|
62
|
+
}
|
|
63
|
+
if (typeof license === 'string') {
|
|
64
|
+
return license;
|
|
65
|
+
}
|
|
66
|
+
return '';
|
|
67
|
+
}
|
|
68
|
+
function getLicenses(pkg) {
|
|
69
|
+
var _a;
|
|
70
|
+
return (pkg.license ? [pkg.license] : (_a = pkg.licenses) !== null && _a !== void 0 ? _a : [])
|
|
71
|
+
.filter(Boolean)
|
|
72
|
+
.map(normalizeLicenseProperty);
|
|
73
|
+
}
|
|
74
|
+
function licenseSpdx(pkg) {
|
|
75
|
+
const licenses = getLicenses(pkg);
|
|
76
|
+
if (!licenses.length) {
|
|
77
|
+
return '';
|
|
78
|
+
}
|
|
79
|
+
if (licenses.length === 1) {
|
|
80
|
+
return licenses[0];
|
|
81
|
+
}
|
|
82
|
+
return '(' + licenses.filter(Boolean).join(' OR ') + ')';
|
|
83
|
+
}
|
|
84
|
+
function indent(input, depth) {
|
|
85
|
+
return input.replace(/^/gm, ' '.repeat(depth));
|
|
86
|
+
}
|
|
87
|
+
function validatePackage(pkg) {
|
|
88
|
+
return ALLOWED_LICENSES.some((allowedLicense) => {
|
|
89
|
+
const spdx = licenseSpdx(pkg);
|
|
90
|
+
try {
|
|
91
|
+
return (0, spdx_satisfies_1.default)(allowedLicense, spdx);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return allowedLicense === spdx;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function getMonorepoPackages(packageLock) {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
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)) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
const output = cross_spawn_1.default.sync('npm', ['query', '.workspace'], {
|
|
104
|
+
encoding: 'utf-8',
|
|
105
|
+
});
|
|
106
|
+
if (output.error) {
|
|
107
|
+
console.error('Error executing command:', output.error);
|
|
108
|
+
process.exit(1);
|
|
109
|
+
}
|
|
110
|
+
const packages = JSON.parse(output.stdout);
|
|
111
|
+
return packages.map((pkg) => `${pkg.name}@${pkg.version}`);
|
|
112
|
+
}
|
|
113
|
+
async function readConfig(configPath) {
|
|
114
|
+
var _a, _b, _c, _d, _e;
|
|
115
|
+
const packageLock = await readPackageLock();
|
|
116
|
+
const monorepoPackages = getMonorepoPackages(packageLock === null || packageLock === void 0 ? void 0 : packageLock.content);
|
|
117
|
+
const originalConfig = JSON.parse(await fs_1.promises.readFile(configPath, 'utf-8'));
|
|
118
|
+
if (packageLock === null || packageLock === void 0 ? void 0 : packageLock.content) {
|
|
119
|
+
checkOverrides([
|
|
120
|
+
...((_a = originalConfig.ignoredPackages) !== null && _a !== void 0 ? _a : []),
|
|
121
|
+
...Object.keys((_b = originalConfig.licenseOverrides) !== null && _b !== void 0 ? _b : {}),
|
|
122
|
+
], packageLock.content);
|
|
123
|
+
}
|
|
124
|
+
return Promise.resolve({
|
|
125
|
+
ignoredOrgs: [...((_c = originalConfig.ignoredOrgs) !== null && _c !== void 0 ? _c : [])],
|
|
126
|
+
ignoredPackages: [
|
|
127
|
+
...((_d = originalConfig.ignoredPackages) !== null && _d !== void 0 ? _d : []),
|
|
128
|
+
...(monorepoPackages !== null && monorepoPackages !== void 0 ? monorepoPackages : []),
|
|
129
|
+
],
|
|
130
|
+
licenseOverrides: { ...((_e = originalConfig.licenseOverrides) !== null && _e !== void 0 ? _e : {}) },
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function printLicenseInformation(productName, packages) {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
let output = `\
|
|
136
|
+
The following third-party software is used by and included in **${productName}**.
|
|
137
|
+
This document was automatically generated on ${new Date().toDateString()}.
|
|
138
|
+
|
|
139
|
+
## List of dependencies
|
|
140
|
+
|
|
141
|
+
Package|Version|License
|
|
142
|
+
-------|-------|-------
|
|
143
|
+
${packages
|
|
144
|
+
.map((pkg) => `**[${pkg.name}](#${id(pkg)})**|${pkg.version}|${licenseSpdx(pkg)}`)
|
|
145
|
+
.join('\n')}
|
|
146
|
+
|
|
147
|
+
## Package details
|
|
148
|
+
`;
|
|
149
|
+
for (const pkg of packages) {
|
|
150
|
+
const spdx = licenseSpdx(pkg);
|
|
151
|
+
const linkedPackageName = pkg.private
|
|
152
|
+
? pkg.name
|
|
153
|
+
: `[${pkg.name}](https://www.npmjs.com/package/${pkg.name})`;
|
|
154
|
+
output += `
|
|
155
|
+
<a id="${id(pkg)}"></a>
|
|
156
|
+
### ${linkedPackageName} (version ${pkg.version})
|
|
157
|
+
`;
|
|
158
|
+
if (pkg.description) {
|
|
159
|
+
output += `> ${pkg.description}\n\n`;
|
|
160
|
+
}
|
|
161
|
+
output += `License tags: ${spdx}\n\n`;
|
|
162
|
+
if ((_a = pkg.licenseFiles) === null || _a === void 0 ? void 0 : _a.length) {
|
|
163
|
+
output += 'License files:\n';
|
|
164
|
+
for (const file of pkg.licenseFiles) {
|
|
165
|
+
output += `* ${file.filename}:\n\n${indent(file.content, 6)}\n\n`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if ((_b = pkg.contributors) === null || _b === void 0 ? void 0 : _b.length) {
|
|
169
|
+
output += 'Authors:\n';
|
|
170
|
+
for (const person of pkg.contributors) {
|
|
171
|
+
const name = typeof person !== 'object'
|
|
172
|
+
? person
|
|
173
|
+
: person.name +
|
|
174
|
+
(person.email ? ` <[${person.email}](nomail)>` : '') +
|
|
175
|
+
(person.url ? ` (${person.url})` : '');
|
|
176
|
+
output += `* ${name}\n`;
|
|
177
|
+
}
|
|
178
|
+
output += '\n';
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return output;
|
|
182
|
+
}
|
|
183
|
+
exports.printLicenseInformation = printLicenseInformation;
|
|
184
|
+
function validatePackages(packages) {
|
|
185
|
+
const invalidPackages = packages.filter((pkg) => !validatePackage(pkg));
|
|
186
|
+
if (invalidPackages.length) {
|
|
187
|
+
console.error(`Generation failed, found ${invalidPackages.length} invalid packages:`);
|
|
188
|
+
for (const pkg of invalidPackages) {
|
|
189
|
+
console.error(`${pkg.name}@${pkg.version}:`, licenseSpdx(pkg));
|
|
190
|
+
}
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async function loadPackages(dependencyFiles, config) {
|
|
195
|
+
return (await (0, load_dependency_files_1.loadDependencyFiles)(dependencyFiles))
|
|
196
|
+
.filter((pkg) => !(config.ignoredOrgs || []).some((org) => pkg.name.startsWith(org + '/')))
|
|
197
|
+
.filter((pkg) => !(config.ignoredPackages || []).includes(`${pkg.name}@${pkg.version}`))
|
|
198
|
+
.map((pkg) => {
|
|
199
|
+
var _a;
|
|
200
|
+
return ({
|
|
201
|
+
...pkg,
|
|
202
|
+
license: (_a = (config.licenseOverrides || {})[`${pkg.name}@${pkg.version}`]) !== null && _a !== void 0 ? _a : pkg.license,
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
async function generate3rdPartyNotices({ productName, dependencyFiles, configPath, }) {
|
|
207
|
+
const config = await readConfig(configPath !== null && configPath !== void 0 ? configPath : 'licenses.json');
|
|
208
|
+
const packages = await loadPackages(dependencyFiles, config);
|
|
209
|
+
validatePackages(packages);
|
|
210
|
+
const markdown = printLicenseInformation(productName, packages);
|
|
211
|
+
console.info(markdown);
|
|
212
|
+
}
|
|
213
|
+
exports.generate3rdPartyNotices = generate3rdPartyNotices;
|
|
214
|
+
//# sourceMappingURL=generate-third-party-notices.js.map
|
|
@@ -0,0 +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;AAs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CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
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
|
+
export declare function generateVulnerabilityReport(options: {
|
|
18
|
+
dependencyFiles: string[];
|
|
19
|
+
snykReports: string[];
|
|
20
|
+
failOn: 'low' | 'medium' | 'high' | 'critical';
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=generate-vulnerability-report.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateVulnerabilityReport = exports.loadReports = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const snykPolicy = require('snyk-policy');
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
const load_dependency_files_1 = require("../load-dependency-files");
|
|
12
|
+
async function loadReports(files) {
|
|
13
|
+
return (await Promise.all(files.map(async (fileName) => JSON.parse(await fs_1.promises.readFile(fileName, 'utf-8'))))).flat();
|
|
14
|
+
}
|
|
15
|
+
exports.loadReports = loadReports;
|
|
16
|
+
async function fetchSnykVulnerabilities(snykTestResults, dependencies) {
|
|
17
|
+
const rules = await snykPolicy.load(process.cwd());
|
|
18
|
+
const affectedDependencies = [];
|
|
19
|
+
snykTestResults.forEach((projectResult) => {
|
|
20
|
+
projectResult.vulnerabilities.forEach((vuln) => {
|
|
21
|
+
dependencies.forEach((dep) => {
|
|
22
|
+
if (vuln.moduleName === dep.name &&
|
|
23
|
+
vuln.from.includes(`${dep.name}@${dep.version}`)) {
|
|
24
|
+
affectedDependencies.push(vuln);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
const uniqueVulnerabilities = new Map();
|
|
30
|
+
affectedDependencies.forEach((vuln) => {
|
|
31
|
+
const key = `${vuln.name}@${vuln.version}_${vuln.id}`;
|
|
32
|
+
const origin = '-';
|
|
33
|
+
if (uniqueVulnerabilities.has(key)) {
|
|
34
|
+
const existingVuln = uniqueVulnerabilities.get(key);
|
|
35
|
+
if (!existingVuln.origins.includes(origin)) {
|
|
36
|
+
existingVuln.origins.push(origin);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
uniqueVulnerabilities.set(key, {
|
|
41
|
+
name: `${vuln.name}@${vuln.version}`,
|
|
42
|
+
id: vuln.id,
|
|
43
|
+
score: vuln.cvssScore,
|
|
44
|
+
severity: `${vuln.severity
|
|
45
|
+
.charAt(0)
|
|
46
|
+
.toUpperCase()}${vuln.severity.slice(1)}`,
|
|
47
|
+
fixedIn: vuln.fixedIn.join(', '),
|
|
48
|
+
origins: [origin],
|
|
49
|
+
policy: snykPolicy.getByVuln(rules, vuln),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const sortedVulnerabilities = Array.from(uniqueVulnerabilities.values()).sort((a, b) => a.name.localeCompare(b.name));
|
|
54
|
+
return sortedVulnerabilities;
|
|
55
|
+
}
|
|
56
|
+
function printTable(title, vulnerabilities) {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
console.info(`## ${title} (${vulnerabilities.length} vulnerabilities)`);
|
|
59
|
+
console.info('| dep@version | id | score | fixed in | origin | ignored |');
|
|
60
|
+
console.info('| ----------- | -- | ----- | -------- | ------ | ------- |');
|
|
61
|
+
const sortedVulns = lodash_1.default.orderBy(vulnerabilities, ['score', 'name'], ['desc', 'asc']);
|
|
62
|
+
for (const vuln of sortedVulns) {
|
|
63
|
+
const severity = `${vuln.score} (${vuln.severity})`;
|
|
64
|
+
const ignored = ((_a = vuln.policy) === null || _a === void 0 ? void 0 : _a.type) === 'ignore'
|
|
65
|
+
? (_b = vuln.policy) === null || _b === void 0 ? void 0 : _b.reason
|
|
66
|
+
: !vuln.fixedIn
|
|
67
|
+
? 'Remediation not available yet'
|
|
68
|
+
: '-';
|
|
69
|
+
console.info(`| ${vuln.name} | ${vuln.id} | ${severity} | ${vuln.fixedIn} | ${ignored} |`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const SEVERITY_TO_SCORE = {
|
|
73
|
+
low: 0,
|
|
74
|
+
medium: 4,
|
|
75
|
+
high: 7,
|
|
76
|
+
critical: 9,
|
|
77
|
+
};
|
|
78
|
+
function fail(failOn, bundleVulnerabilities) {
|
|
79
|
+
var _a;
|
|
80
|
+
const minScore = SEVERITY_TO_SCORE[failOn];
|
|
81
|
+
for (const vuln of bundleVulnerabilities) {
|
|
82
|
+
if (vuln.score >= minScore &&
|
|
83
|
+
vuln.fixedIn &&
|
|
84
|
+
((_a = vuln.policy) === null || _a === void 0 ? void 0 : _a.type) !== 'ignore') {
|
|
85
|
+
console.error(chalk_1.default.red(`Vulnerabilities check failed: found vulnerabilies >= "${failOn}"`));
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function generateVulnerabilityReport(options) {
|
|
91
|
+
const productionDependencies = await (0, load_dependency_files_1.loadDependencyFiles)(options.dependencyFiles);
|
|
92
|
+
const snykTestResult = await loadReports(options.snykReports);
|
|
93
|
+
const bundleVulnerabilities = await fetchSnykVulnerabilities(snykTestResult, productionDependencies);
|
|
94
|
+
printTable('Snyk Report', bundleVulnerabilities);
|
|
95
|
+
if (options.failOn) {
|
|
96
|
+
fail(options.failOn, bundleVulnerabilities);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.generateVulnerabilityReport = generateVulnerabilityReport;
|
|
100
|
+
//# sourceMappingURL=generate-vulnerability-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-vulnerability-report.js","sourceRoot":"","sources":["../../src/commands/generate-vulnerability-report.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAoC;AAGpC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAC1C,oDAAuB;AACvB,kDAA0B;AAE1B,oEAA+D;AAExD,KAAK,UAAU,WAAW,CAC/B,KAAe;IAIf,OAAO,CACL,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,aAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CACjD,CACF,CACF,CAAC,IAAI,EAAE,CAAC;AACX,CAAC;AAZD,kCAYC;AAqCD,KAAK,UAAU,wBAAwB,CACrC,eAAwC,EACxC,YAA0B;IAE1B,MAAM,KAAK,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAA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,MAAM,EAAE;QAClB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;KAC7C;AACH,CAAC;AArBD,kEAqBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-node-js.d.ts","sourceRoot":"","sources":["../../src/commands/scan-node-js.ts"],"names":[],"mappings":"AA2HA,wBAAsB,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,iBAoBhE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.scanNodeJs = void 0;
|
|
7
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
|
+
const semver_1 = __importDefault(require("semver"));
|
|
9
|
+
const nv_1 = __importDefault(require("@pkgjs/nv"));
|
|
10
|
+
function scoreToSeverity(score) {
|
|
11
|
+
if (score >= 9) {
|
|
12
|
+
return 'critical';
|
|
13
|
+
}
|
|
14
|
+
if (score >= 7) {
|
|
15
|
+
return 'high';
|
|
16
|
+
}
|
|
17
|
+
if (score >= 4) {
|
|
18
|
+
return 'medium';
|
|
19
|
+
}
|
|
20
|
+
return 'low';
|
|
21
|
+
}
|
|
22
|
+
async function formatVuln(id, nodeVuln, nodeVersion) {
|
|
23
|
+
let score;
|
|
24
|
+
try {
|
|
25
|
+
const cves = await Promise.all(nodeVuln.cve.map((cve) => (0, node_fetch_1.default)(`https://cve.circl.lu/api/cve/${cve}`).then((res) => res.json())));
|
|
26
|
+
const allCvss = cves.map((cve) => cve.cvss);
|
|
27
|
+
score = Math.max(...allCvss);
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
console.error(e);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
id: `NSWG-COR-${id}`,
|
|
34
|
+
title: `Node.js core vulnerability #${id}`,
|
|
35
|
+
CVSSv3: '-',
|
|
36
|
+
credit: ['-'],
|
|
37
|
+
semver: {
|
|
38
|
+
vulnerable: nodeVuln.vulnerable,
|
|
39
|
+
},
|
|
40
|
+
exploit: '-',
|
|
41
|
+
patched: [nodeVuln.patched],
|
|
42
|
+
patches: [],
|
|
43
|
+
fixedIn: (nodeVuln.patched || '').split(' || '),
|
|
44
|
+
insights: {
|
|
45
|
+
triageAdvice: null,
|
|
46
|
+
},
|
|
47
|
+
language: 'js',
|
|
48
|
+
severity: scoreToSeverity(score !== null && score !== void 0 ? score : 9),
|
|
49
|
+
cvssScore: score,
|
|
50
|
+
functions: [],
|
|
51
|
+
moduleName: '.node.js',
|
|
52
|
+
references: [
|
|
53
|
+
{
|
|
54
|
+
url: nodeVuln.ref,
|
|
55
|
+
title: 'Ref',
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
cvssDetails: [],
|
|
59
|
+
description: nodeVuln.overview,
|
|
60
|
+
epssDetails: null,
|
|
61
|
+
identifiers: {
|
|
62
|
+
CVE: nodeVuln.cve,
|
|
63
|
+
},
|
|
64
|
+
packageName: '.node.js',
|
|
65
|
+
proprietary: true,
|
|
66
|
+
creationTime: '-',
|
|
67
|
+
functions_new: [],
|
|
68
|
+
alternativeIds: [],
|
|
69
|
+
disclosureTime: '-',
|
|
70
|
+
packageManager: 'npm',
|
|
71
|
+
publicationTime: '-',
|
|
72
|
+
modificationTime: '-',
|
|
73
|
+
socialTrendAlert: false,
|
|
74
|
+
severityWithCritical: 'high',
|
|
75
|
+
from: [`.node.js@${nodeVersion}`],
|
|
76
|
+
upgradePath: [],
|
|
77
|
+
isUpgradable: true,
|
|
78
|
+
isPatchable: false,
|
|
79
|
+
name: '.node.js',
|
|
80
|
+
version: nodeVersion,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
async function downloadCoreDb() {
|
|
84
|
+
const url = 'https://raw.githubusercontent.com/nodejs/security-wg/main/vuln/core/index.json';
|
|
85
|
+
const response = await (0, node_fetch_1.default)(url);
|
|
86
|
+
if (!response.ok) {
|
|
87
|
+
throw new Error(`Download failed: ${response.status}`);
|
|
88
|
+
}
|
|
89
|
+
return await response.json();
|
|
90
|
+
}
|
|
91
|
+
async function isSupported(version) {
|
|
92
|
+
const supported = (await (0, nv_1.default)('supported'))
|
|
93
|
+
.map((v) => `${v.major}.x`)
|
|
94
|
+
.join(' || ');
|
|
95
|
+
return semver_1.default.satisfies(version, supported);
|
|
96
|
+
}
|
|
97
|
+
async function scanNodeJs({ version }) {
|
|
98
|
+
if (!(await isSupported(version))) {
|
|
99
|
+
throw new Error(`Failed: node.js@${version} is not supported anymore.`);
|
|
100
|
+
}
|
|
101
|
+
const coreDbVuln = await downloadCoreDb();
|
|
102
|
+
const affectedBy = [];
|
|
103
|
+
for (const [id, vuln] of Object.entries(coreDbVuln)) {
|
|
104
|
+
if (semver_1.default.satisfies(version, vuln.vulnerable) &&
|
|
105
|
+
vuln.patched &&
|
|
106
|
+
!semver_1.default.satisfies(version, vuln.patched)) {
|
|
107
|
+
affectedBy.push(await formatVuln(id, vuln, version));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
console.log(JSON.stringify({ vulnerabilities: affectedBy }, null, 2));
|
|
111
|
+
}
|
|
112
|
+
exports.scanNodeJs = scanNodeJs;
|
|
113
|
+
//# sourceMappingURL=scan-node-js.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-node-js.js","sourceRoot":"","sources":["../../src/commands/scan-node-js.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAC/B,oDAA4B;AAC5B,mDAA2B;AAc3B,SAAS,eAAe,CAAC,KAAa;IACpC,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,OAAO,UAAU,CAAC;KACnB;IACD,IAAI,KAAK,IAAI,CAAC,EAAE;QACd,OAAO,MA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AAC,CAAC;SACtC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;SAC1B,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,OAAO,gBAAM,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAC9C,CAAC;AAEM,KAAK,UAAU,UAAU,CAAC,EAAE,OAAO,EAAuB;IAC/D,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,4BAA4B,CAAC,CAAC;KACzE;IAED,MAAM,UAAU,GAAG,MAAM,cAAc,EAAE,CAAC;IAE1C,MAAM,UAAU,GAAG,EAAE,CAAC;IAEtB,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;QACnD,IACE,gBAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC;YAC1C,IAAI,CAAC,OAAO;YACZ,CAAC,gBAAM,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,EACxC;YACA,UAAU,CAAC,IAAI,CAAC,MAAM,UAAU,CAAC,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;SACtD;KACF;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC;AApBD,gCAoBC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface PackageJSON {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
license?: string | {
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
licenses?: {
|
|
9
|
+
type: string;
|
|
10
|
+
}[];
|
|
11
|
+
dependencies?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
optionalDependencies?: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
author?: string | {
|
|
18
|
+
name: string;
|
|
19
|
+
email?: string;
|
|
20
|
+
url?: string;
|
|
21
|
+
};
|
|
22
|
+
contributors?: (string | {
|
|
23
|
+
name: string;
|
|
24
|
+
email?: string;
|
|
25
|
+
url?: string;
|
|
26
|
+
})[];
|
|
27
|
+
private?: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface Package extends PackageJSON {
|
|
30
|
+
path: string;
|
|
31
|
+
licenseFiles: {
|
|
32
|
+
filename: string;
|
|
33
|
+
content: string;
|
|
34
|
+
}[];
|
|
35
|
+
}
|
|
36
|
+
export declare function getPackageInfo(modulePath: string): Promise<Package>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=get-package-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-package-info.d.ts","sourceRoot":"","sources":["../src/get-package-info.ts"],"names":[],"mappings":"AAMA,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC9B,YAAY,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACzC,oBAAoB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACjD,MAAM,CAAC,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE,YAAY,CAAC,EAAE,CAAC,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE,CAAC;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,OAAQ,SAAQ,WAAW;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACvD;AA6CD,wBAAsB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAoCzE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPackageInfo = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const find_up_1 = __importDefault(require("find-up"));
|
|
10
|
+
const licenseRegexp = /^(license|copyright|copying)/i;
|
|
11
|
+
const fileCache = {};
|
|
12
|
+
function readFileWithCache(filePath) {
|
|
13
|
+
var _a;
|
|
14
|
+
(_a = fileCache[filePath]) !== null && _a !== void 0 ? _a : (fileCache[filePath] = fs_1.promises.readFile(filePath, 'utf-8'));
|
|
15
|
+
return fileCache[filePath];
|
|
16
|
+
}
|
|
17
|
+
const findPackageJson = async (modulePath) => {
|
|
18
|
+
const candidatePath = await (0, find_up_1.default)('package.json', {
|
|
19
|
+
cwd: path_1.default.dirname(modulePath),
|
|
20
|
+
});
|
|
21
|
+
if (!candidatePath) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const packageJson = JSON.parse(await readFileWithCache(candidatePath));
|
|
26
|
+
if (typeof packageJson.name === 'string' &&
|
|
27
|
+
typeof packageJson.version === 'string') {
|
|
28
|
+
return { path: candidatePath, content: packageJson };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
}
|
|
33
|
+
return await findPackageJson(path_1.default.dirname(candidatePath));
|
|
34
|
+
};
|
|
35
|
+
async function getPackageInfo(modulePath) {
|
|
36
|
+
const packageJSONInfo = await findPackageJson(modulePath);
|
|
37
|
+
if (!packageJSONInfo) {
|
|
38
|
+
throw new Error(`package.json not found for ${modulePath}`);
|
|
39
|
+
}
|
|
40
|
+
const { path: packageJSONPath, content: packageJSON } = packageJSONInfo;
|
|
41
|
+
const packagePath = path_1.default.dirname(packageJSONPath);
|
|
42
|
+
packageJSON.contributors = [
|
|
43
|
+
...new Set([packageJSON.author, packageJSON.contributors].flat()),
|
|
44
|
+
].filter(Boolean);
|
|
45
|
+
const licenseFiles = await Promise.all((await fs_1.promises.readdir(packagePath))
|
|
46
|
+
.filter((filename) => licenseRegexp.test(filename))
|
|
47
|
+
.sort()
|
|
48
|
+
.map(async (filename) => ({
|
|
49
|
+
filename,
|
|
50
|
+
content: await readFileWithCache(path_1.default.join(packagePath, filename)),
|
|
51
|
+
})));
|
|
52
|
+
return {
|
|
53
|
+
name: packageJSON.name,
|
|
54
|
+
version: packageJSON.version,
|
|
55
|
+
license: packageJSON.license,
|
|
56
|
+
licenses: packageJSON.licenses,
|
|
57
|
+
path: packagePath,
|
|
58
|
+
licenseFiles,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.getPackageInfo = getPackageInfo;
|
|
62
|
+
//# sourceMappingURL=get-package-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-package-info.js","sourceRoot":"","sources":["../src/get-package-info.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AE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,eAAe,CAAC;IAExE,MAAM,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAGlD,WAAW,CAAC,YAAY,GAAG;QACzB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,CAAC;KAClE,CAAC,MAAM,CAAC,OAAO,CAAQ,CAAC;IAEzB,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,GAAG,CACpC,CACE,MAAM,aAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAC9B;SACE,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAClD,IAAI,EAAE;SACN,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;QACxB,QAAQ;QACR,OAAO,EAAE,MAAM,iBAAiB,CAAC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;KACnE,CAAC,CAAC,CACN,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,WAAW,CAAC,IAAI;QACtB,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,IAAI,EAAE,WAAW;QACjB,YAAY;KACb,CAAC;AACJ,CAAC;AApCD,wCAoCC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebpackDependenciesPlugin = void 0;
|
|
4
|
+
var webpack_dependencies_plugin_1 = require("./webpack-dependencies-plugin");
|
|
5
|
+
Object.defineProperty(exports, "WebpackDependenciesPlugin", { enumerable: true, get: function () { return webpack_dependencies_plugin_1.WebpackDependenciesPlugin; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6EAA0E;AAAjE,wIAAA,yBAAyB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-dependency-files.d.ts","sourceRoot":"","sources":["../src/load-dependency-files.ts"],"names":[],"mappings":"AAGA,wBAAsB,mBAAmB,CACvC,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC3C,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAkB/B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadDependencyFiles = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
9
|
+
async function loadDependencyFiles(files) {
|
|
10
|
+
const data = (await Promise.all(files.map(async (fileName) => JSON.parse(await fs_1.promises.readFile(fileName, 'utf-8'))))).flat();
|
|
11
|
+
const uniqueData = lodash_1.default.uniqBy(data, ({ name, version }) => `${name}@${version}`);
|
|
12
|
+
return lodash_1.default.sortBy(uniqueData, ({ name, version }) => `${name}@${version}`);
|
|
13
|
+
}
|
|
14
|
+
exports.loadDependencyFiles = loadDependencyFiles;
|
|
15
|
+
//# sourceMappingURL=load-dependency-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-dependency-files.js","sourceRoot":"","sources":["../src/load-dependency-files.ts"],"names":[],"mappings":";;;;;;AAAA,2BAAoC;AACpC,oDAAuB;AAEhB,KAAK,UAAU,mBAAmB,CAEvC,KAAe;IACf,MAAM,IAAI,GAAG,CACX,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAC3B,IAAI,CAAC,KAAK,CAAC,MAAM,aAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CACjD,CACF,CACF,CAAC,IAAI,EAAE,CAAC;IAET,MAAM,UAAU,GAAG,gBAAC,CAAC,MAAM,CACzB,IAAI,EACJ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,IAAc,IAAI,OAAiB,EAAE,CAChE,CAAC;IAEF,OAAO,gBAAC,CAAC,MAAM,CACb,UAAU,EACV,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,IAAc,IAAI,OAAiB,EAAE,CAChE,CAAC;AACJ,CAAC;AApBD,kDAoBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"production-deps.d.ts","sourceRoot":"","sources":["../src/production-deps.ts"],"names":[],"mappings":"AAeA,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,UAWtD;AAiBD,wBAAgB,4BAA4B,IAAI,MAAM,EAAE,CA6CvD"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.findAllProdDepsTreeLocations = exports.findPackageLocation = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const find_up_1 = __importDefault(require("find-up"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
function resolvePackage(packageName) {
|
|
11
|
+
const resolved = require.resolve(packageName);
|
|
12
|
+
if (resolved === packageName) {
|
|
13
|
+
return require.resolve(packageName + '/');
|
|
14
|
+
}
|
|
15
|
+
return resolved;
|
|
16
|
+
}
|
|
17
|
+
function findPackageLocation(packageName) {
|
|
18
|
+
const packageJsonPath = find_up_1.default.sync('package.json', {
|
|
19
|
+
cwd: resolvePackage(packageName),
|
|
20
|
+
allowSymlinks: false,
|
|
21
|
+
});
|
|
22
|
+
if (!packageJsonPath) {
|
|
23
|
+
throw new Error(`Failed to find package.json for ${packageName}`);
|
|
24
|
+
}
|
|
25
|
+
return path_1.default.dirname(packageJsonPath);
|
|
26
|
+
}
|
|
27
|
+
exports.findPackageLocation = findPackageLocation;
|
|
28
|
+
function getProductionDeps(packageLocation) {
|
|
29
|
+
const packageJsonPath = path_1.default.join(packageLocation, 'package.json');
|
|
30
|
+
let dependencies = {};
|
|
31
|
+
let optionalDependencies = {};
|
|
32
|
+
try {
|
|
33
|
+
const packageJsonContents = fs_1.default.readFileSync(packageJsonPath, 'utf8');
|
|
34
|
+
const packageJson = JSON.parse(packageJsonContents);
|
|
35
|
+
dependencies = packageJson.dependencies || {};
|
|
36
|
+
optionalDependencies = packageJson.optionalDependencies || {};
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
console.error(`Failed to read package.json in ${packageLocation}`);
|
|
40
|
+
}
|
|
41
|
+
return { dependencies, optionalDependencies };
|
|
42
|
+
}
|
|
43
|
+
function findAllProdDepsTreeLocations() {
|
|
44
|
+
const rootPackageJsonPath = find_up_1.default.sync('package.json');
|
|
45
|
+
if (!rootPackageJsonPath) {
|
|
46
|
+
throw new Error('cannot find root package.json');
|
|
47
|
+
}
|
|
48
|
+
const root = path_1.default.dirname(rootPackageJsonPath);
|
|
49
|
+
const allLocations = new Set();
|
|
50
|
+
const visited = new Set();
|
|
51
|
+
const queue = [root];
|
|
52
|
+
while (queue.length > 0) {
|
|
53
|
+
const packageLocation = queue.shift();
|
|
54
|
+
if (!packageLocation) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (visited.has(packageLocation)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
visited.add(packageLocation);
|
|
61
|
+
const { dependencies, optionalDependencies } = getProductionDeps(packageLocation);
|
|
62
|
+
[
|
|
63
|
+
...Object.keys(dependencies),
|
|
64
|
+
...Object.keys(optionalDependencies),
|
|
65
|
+
].forEach((dep) => {
|
|
66
|
+
try {
|
|
67
|
+
const depLocation = findPackageLocation(dep);
|
|
68
|
+
if (depLocation) {
|
|
69
|
+
allLocations.add(depLocation);
|
|
70
|
+
queue.push(depLocation);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error(`Warning: failed to resolve ${dep} from ${packageLocation}. This is normal if this dependency is optional. ${error.message}`);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return Array.from(allLocations);
|
|
79
|
+
}
|
|
80
|
+
exports.findAllProdDepsTreeLocations = findAllProdDepsTreeLocations;
|
|
81
|
+
//# sourceMappingURL=production-deps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"production-deps.js","sourceRoot":"","sources":["../src/production-deps.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,sDAA6B;AAC7B,4CAAoB;AAEpB,SAAS,cAAc,CAAC,WAAmB;IACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAG9C,IAAI,QAAQ,KAAK,WAAW,EAAE;QAC5B,OAAO,OAAO,CAAC,OAAO,CAAC,WAAW,GAAG,GAAG,CAAC,CAA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PluginOptions = {
|
|
3
|
+
outputFilename?: string;
|
|
4
|
+
includePackages?: string[];
|
|
5
|
+
includeExternalProductionDependencies?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare class WebpackDependenciesPlugin implements WebpackPluginInstance {
|
|
8
|
+
private options;
|
|
9
|
+
private readonly pluginName;
|
|
10
|
+
outputPath: string;
|
|
11
|
+
includePackages: string[];
|
|
12
|
+
resolvedModules: Set<string>;
|
|
13
|
+
constructor(options?: WebpackDependenciesPluginOptions);
|
|
14
|
+
private handleTap;
|
|
15
|
+
apply(compiler: Compiler): void;
|
|
16
|
+
}
|
|
17
|
+
export default WebpackDependenciesPlugin;
|
|
18
|
+
//# sourceMappingURL=webpack-dependencies-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack-dependencies-plugin.d.ts","sourceRoot":"","sources":["../src/webpack-dependencies-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAe,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAW5E,aAAK,gCAAgC,GAAG;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,qCAAqC,CAAC,EAAE,OAAO,CAAC;CACjD,CAAC;AAMF,qBAAa,yBAA0B,YAAW,qBAAqB;IAMzD,OAAO,CAAC,OAAO;IAL3B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAM;IAC/B,eAAe,cAAqB;gBAEhB,OAAO,GAAE,gCAAqC;IAWlE,OAAO,CAAC,SAAS,CAkBf;IAEF,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAyBhC;AAED,eAAe,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WebpackDependenciesPlugin = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
const production_deps_1 = require("./production-deps");
|
|
11
|
+
const get_package_info_1 = require("./get-package-info");
|
|
12
|
+
const PLUGIN_NAME = 'WebpackDependenciesPlugin';
|
|
13
|
+
class WebpackDependenciesPlugin {
|
|
14
|
+
constructor(options = {}) {
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.pluginName = PLUGIN_NAME;
|
|
17
|
+
this.includePackages = [];
|
|
18
|
+
this.resolvedModules = new Set();
|
|
19
|
+
this.handleTap = (compilation) => {
|
|
20
|
+
for (const module of compilation.modules) {
|
|
21
|
+
const resource = module.resource;
|
|
22
|
+
if (resource) {
|
|
23
|
+
const modulePath = resource;
|
|
24
|
+
if (typeof modulePath === 'string') {
|
|
25
|
+
this.resolvedModules.add(modulePath);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
for (const includedPackagePath of this.includePackages) {
|
|
30
|
+
const packageJsonPath = path_1.default.join(includedPackagePath, 'package.json');
|
|
31
|
+
if (packageJsonPath) {
|
|
32
|
+
this.resolvedModules.add(packageJsonPath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
this.includePackages = [
|
|
37
|
+
...(options.includeExternalProductionDependencies
|
|
38
|
+
? (0, production_deps_1.findAllProdDepsTreeLocations)()
|
|
39
|
+
: []),
|
|
40
|
+
...(options.includePackages || []).map(production_deps_1.findPackageLocation),
|
|
41
|
+
];
|
|
42
|
+
this.outputPath = options.outputFilename || 'dependencies.json';
|
|
43
|
+
}
|
|
44
|
+
apply(compiler) {
|
|
45
|
+
compiler.hooks.shutdown.tapPromise(PLUGIN_NAME, async () => {
|
|
46
|
+
const dependencyList = await Promise.all(Array.from(this.resolvedModules).map(get_package_info_1.getPackageInfo));
|
|
47
|
+
const uniqueList = lodash_1.default.uniqBy(dependencyList, ({ name, version }) => `${name}@${version}`);
|
|
48
|
+
const sortedList = lodash_1.default.sortBy(uniqueList, ({ name, version }) => `${name}@${version}`);
|
|
49
|
+
await fs_1.promises.mkdir(path_1.default.dirname(path_1.default.resolve(this.outputPath)), {
|
|
50
|
+
recursive: true,
|
|
51
|
+
});
|
|
52
|
+
await fs_1.promises.writeFile(this.outputPath, JSON.stringify(sortedList, null, 2));
|
|
53
|
+
});
|
|
54
|
+
compiler.hooks.emit.tap(PLUGIN_NAME, this.handleTap);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.WebpackDependenciesPlugin = WebpackDependenciesPlugin;
|
|
58
|
+
exports.default = WebpackDependenciesPlugin;
|
|
59
|
+
//# sourceMappingURL=webpack-dependencies-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webpack-dependencies-plugin.js","sourceRoot":"","sources":["../src/webpack-dependencies-plugin.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,2BAAoC;AAEpC,oDAAuB;AAEvB,uDAG2B;AAC3B,yDAAoD;AAEpD,MAAM,WAAW,GAAG,2BAA2B,CAAC;AAYhD,MAAa,yBAAyB;IAMpC,YAAoB,UAA4C,EAAE;QAA9C,YAAO,GAAP,OAAO,CAAuC;QALjD,eAAU,GAAG,WAAW,CAAC;QAE1C,oBAAe,GAAa,EAAE,CAAC;QAC/B,oBAAe,GAAG,IAAI,GAAG,EAAU,CAAC;QAa5B,cAAS,GAAG,CAAC,WAAwB,EAAE,EAAE;YAC/C,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,OAAO,EAAE;gBACxC,MAAM,QAAQ,GAAI,MAAyB,CAAC,QAAQ,CAAC;gBACrD,IAAI,QAAQ,EAA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AAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,OAAO,EAAE,CAC5C,CAAC;YAEF,MAAM,aAAE,CAAC,KAAK,CAAC,cAAI,CAAC,OAAO,CAAC,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE;gBAC1D,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YAEH,MAAM,aAAE,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3E,CAAC,CAAC,CAAC;QAEH,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CACF;AA9DD,8DA8DC;AAED,kBAAe,yBAAyB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mongodb-js/sbom-tools",
|
|
3
|
+
"description": "Reporting tools for 3rd party vulnerabilities and licenses",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "MongoDB Inc",
|
|
6
|
+
"email": "compass@mongodb.com"
|
|
7
|
+
},
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"mongodb-sbom-tools": "./bin/mongodb-sbom-tools.js"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://jira.mongodb.org/projects/COMPASS/issues",
|
|
16
|
+
"email": "compass@mongodb.com"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/mongodb-js/devtools-shared",
|
|
19
|
+
"version": "0.2.0",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/mongodb-js/devtools-shared.git"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"exports": {
|
|
30
|
+
"require": "./dist/index.js",
|
|
31
|
+
"import": "./dist/.esm-wrapper.mjs"
|
|
32
|
+
},
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"scripts": {
|
|
35
|
+
"bootstrap": "npm run compile",
|
|
36
|
+
"prepublishOnly": "npm run compile",
|
|
37
|
+
"compile": "tsc -p tsconfig.json && gen-esm-wrapper . ./dist/.esm-wrapper.mjs",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"eslint": "eslint",
|
|
40
|
+
"prettier": "prettier",
|
|
41
|
+
"lint": "npm run eslint . && npm run prettier -- --check .",
|
|
42
|
+
"depcheck": "depcheck",
|
|
43
|
+
"check": "npm run typecheck && npm run lint && npm run depcheck",
|
|
44
|
+
"check-ci": "npm run check",
|
|
45
|
+
"test": "mocha",
|
|
46
|
+
"test-cov": "nyc -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test",
|
|
47
|
+
"test-watch": "npm run test -- --watch",
|
|
48
|
+
"test-ci": "npm run test-cov",
|
|
49
|
+
"reformat": "npm run prettier -- --write ."
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@mongodb-js/eslint-config-devtools": "0.9.3",
|
|
53
|
+
"@mongodb-js/mocha-config-compass": "^0.10.0",
|
|
54
|
+
"@mongodb-js/prettier-config-compass": "^0.5.0",
|
|
55
|
+
"@mongodb-js/tsconfig-compass": "^0.6.0",
|
|
56
|
+
"@types/chai": "^4.2.21",
|
|
57
|
+
"@types/cross-spawn": "^6.0.2",
|
|
58
|
+
"@types/lodash": "^4.14.194",
|
|
59
|
+
"@types/mocha": "^9.0.0",
|
|
60
|
+
"@types/node": "^17.0.35",
|
|
61
|
+
"@types/node-fetch": "^2.6.3",
|
|
62
|
+
"@types/sinon-chai": "^3.2.5",
|
|
63
|
+
"@types/spdx-satisfies": "^0.1.0",
|
|
64
|
+
"chai": "^4.3.6",
|
|
65
|
+
"depcheck": "^1.4.1",
|
|
66
|
+
"eslint": "^7.25.0",
|
|
67
|
+
"gen-esm-wrapper": "^1.1.0",
|
|
68
|
+
"mocha": "^8.4.0",
|
|
69
|
+
"nyc": "^15.1.0",
|
|
70
|
+
"prettier": "2.3.2",
|
|
71
|
+
"sinon": "^9.2.3",
|
|
72
|
+
"typescript": "^4.3.5"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@pkgjs/nv": "^0.2.1",
|
|
76
|
+
"chalk": "^4.1.2",
|
|
77
|
+
"commander": "^10.0.1",
|
|
78
|
+
"cross-spawn": "^7.0.3",
|
|
79
|
+
"find-up": "^4.1.0",
|
|
80
|
+
"lodash": "^4.17.21",
|
|
81
|
+
"node-fetch": "^2.6.7",
|
|
82
|
+
"semver": "^7.5.0",
|
|
83
|
+
"snyk-policy": "^2.0.4",
|
|
84
|
+
"spdx-satisfies": "^5.0.1",
|
|
85
|
+
"webpack": "^5.82.0"
|
|
86
|
+
},
|
|
87
|
+
"gitHead": "74f42368e64635116eff6ccaa0bdfbaf97ea0d14"
|
|
88
|
+
}
|