@cyclonedx/cdxgen 8.0.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/server.js ADDED
@@ -0,0 +1,110 @@
1
+ const connect = require("connect");
2
+ const http = require("http");
3
+ const bodyParser = require("body-parser");
4
+ const url = require("url");
5
+ const { spawnSync } = require("child_process");
6
+ const os = require("os");
7
+ const fs = require("fs");
8
+ const path = require("path");
9
+ const bom = require("./index.js");
10
+ const compression = require("compression");
11
+
12
+ const app = connect();
13
+
14
+ app.use(
15
+ bodyParser.json({
16
+ deflate: true,
17
+ limit: "1mb"
18
+ })
19
+ );
20
+ app.use(compression());
21
+
22
+ const gitClone = (repoUrl) => {
23
+ const tempDir = fs.mkdtempSync(
24
+ path.join(os.tmpdir(), path.basename(repoUrl))
25
+ );
26
+ console.log("Cloning", repoUrl, "to", tempDir);
27
+ const result = spawnSync("git", ["clone", repoUrl, "--depth", "1", tempDir], {
28
+ encoding: "utf-8",
29
+ shell: false
30
+ });
31
+ if (result.status !== 0 || result.error) {
32
+ console.log(result.error);
33
+ }
34
+ return tempDir;
35
+ };
36
+
37
+ const parseQueryString = (q, body, options = {}) => {
38
+ if (body && Object.keys(body).length) {
39
+ options = Object.assign(options, body);
40
+ }
41
+ if (q.type) {
42
+ options.projectType = q.type;
43
+ }
44
+ if (q.multiProject && q.multiProject !== "false") {
45
+ options.multiProject = true;
46
+ }
47
+ if (q.requiredOnly && q.requiredOnly !== "false") {
48
+ options.requiredOnly = true;
49
+ }
50
+ if (q.noBabel) {
51
+ options.noBabel = q.noBabel;
52
+ }
53
+ if (q.installDeps) {
54
+ options.installDeps = q.installDeps;
55
+ }
56
+ if (q.project) {
57
+ options.project = q.project;
58
+ }
59
+ if (q.projectName) {
60
+ options.projectName = q.projectName;
61
+ }
62
+ if (q.projectGroup) {
63
+ options.projectGroup = q.projectGroup;
64
+ }
65
+ if (q.projectVersion) {
66
+ options.projectVersion = q.projectVersion;
67
+ }
68
+ return options;
69
+ };
70
+
71
+ const start = async (options) => {
72
+ console.log("Listening on", options.serverHost, options.serverPort);
73
+ http.createServer(app).listen(options.serverPort, options.serverHost);
74
+ app.use("/sbom", async function (req, res) {
75
+ const q = url.parse(req.url, true).query;
76
+ let cleanup = false;
77
+ options = parseQueryString(q, req.body, options);
78
+ let filePath = q.path || q.url || req.body.path || req.body.url;
79
+ if (!filePath) {
80
+ res.writeHead(500, { "Content-Type": "application/json" });
81
+ return res.end(
82
+ "{'error': 'true', 'message': 'path or url is required.'}\n"
83
+ );
84
+ }
85
+ res.writeHead(200, { "Content-Type": "application/json" });
86
+ let srcDir = filePath;
87
+ if (filePath.startsWith("http") || filePath.startsWith("git")) {
88
+ srcDir = gitClone(filePath);
89
+ cleanup = true;
90
+ }
91
+ console.log("Generating SBoM for", srcDir);
92
+ const bomNSData = (await bom.createBom(srcDir, options)) || {};
93
+ if (bomNSData.bomJson) {
94
+ if (
95
+ typeof bomNSData.bomJson === "string" ||
96
+ bomNSData.bomJson instanceof String
97
+ ) {
98
+ res.write(bomNSData.bomJson);
99
+ } else {
100
+ res.write(JSON.stringify(bomNSData.bomJson, null, 2));
101
+ }
102
+ }
103
+ res.end("\n");
104
+ if (cleanup && srcDir && srcDir.startsWith(os.tmpdir())) {
105
+ console.log(`Cleaning up ${srcDir}`);
106
+ fs.rmSync(srcDir, { recursive: true, force: true });
107
+ }
108
+ });
109
+ };
110
+ exports.start = start;
@@ -0,0 +1,500 @@
1
+ [
2
+ "0BSD",
3
+ "AAL",
4
+ "Abstyles",
5
+ "Adobe-2006",
6
+ "Adobe-Glyph",
7
+ "ADSL",
8
+ "AFL-1.1",
9
+ "AFL-1.2",
10
+ "AFL-2.0",
11
+ "AFL-2.1",
12
+ "AFL-3.0",
13
+ "Afmparse",
14
+ "AGPL-1.0",
15
+ "AGPL-1.0-only",
16
+ "AGPL-1.0-or-later",
17
+ "AGPL-3.0",
18
+ "AGPL-3.0-only",
19
+ "AGPL-3.0-or-later",
20
+ "Aladdin",
21
+ "AMDPLPA",
22
+ "AML",
23
+ "AMPAS",
24
+ "ANTLR-PD",
25
+ "ANTLR-PD-fallback",
26
+ "Apache-1.0",
27
+ "Apache-1.1",
28
+ "Apache-2.0",
29
+ "APAFML",
30
+ "APL-1.0",
31
+ "App-s2p",
32
+ "APSL-1.0",
33
+ "APSL-1.1",
34
+ "APSL-1.2",
35
+ "APSL-2.0",
36
+ "Arphic-1999",
37
+ "Artistic-1.0",
38
+ "Artistic-1.0-cl8",
39
+ "Artistic-1.0-Perl",
40
+ "Artistic-2.0",
41
+ "Baekmuk",
42
+ "Bahyph",
43
+ "Barr",
44
+ "Beerware",
45
+ "Bitstream-Vera",
46
+ "BitTorrent-1.0",
47
+ "BitTorrent-1.1",
48
+ "blessing",
49
+ "BlueOak-1.0.0",
50
+ "Borceux",
51
+ "BSD-1-Clause",
52
+ "BSD-2-Clause",
53
+ "BSD-2-Clause-FreeBSD",
54
+ "BSD-2-Clause-NetBSD",
55
+ "BSD-2-Clause-Patent",
56
+ "BSD-2-Clause-Views",
57
+ "BSD-3-Clause",
58
+ "BSD-3-Clause-Attribution",
59
+ "BSD-3-Clause-Clear",
60
+ "BSD-3-Clause-LBNL",
61
+ "BSD-3-Clause-Modification",
62
+ "BSD-3-Clause-No-Military-License",
63
+ "BSD-3-Clause-No-Nuclear-License",
64
+ "BSD-3-Clause-No-Nuclear-License-2014",
65
+ "BSD-3-Clause-No-Nuclear-Warranty",
66
+ "BSD-3-Clause-Open-MPI",
67
+ "BSD-4-Clause",
68
+ "BSD-4-Clause-Shortened",
69
+ "BSD-4-Clause-UC",
70
+ "BSD-Protection",
71
+ "BSD-Source-Code",
72
+ "BSL-1.0",
73
+ "BUSL-1.1",
74
+ "bzip2-1.0.5",
75
+ "bzip2-1.0.6",
76
+ "C-UDA-1.0",
77
+ "CAL-1.0",
78
+ "CAL-1.0-Combined-Work-Exception",
79
+ "Caldera",
80
+ "CATOSL-1.1",
81
+ "CC-BY-1.0",
82
+ "CC-BY-2.0",
83
+ "CC-BY-2.5",
84
+ "CC-BY-2.5-AU",
85
+ "CC-BY-3.0",
86
+ "CC-BY-3.0-AT",
87
+ "CC-BY-3.0-DE",
88
+ "CC-BY-3.0-IGO",
89
+ "CC-BY-3.0-NL",
90
+ "CC-BY-3.0-US",
91
+ "CC-BY-4.0",
92
+ "CC-BY-NC-1.0",
93
+ "CC-BY-NC-2.0",
94
+ "CC-BY-NC-2.5",
95
+ "CC-BY-NC-3.0",
96
+ "CC-BY-NC-3.0-DE",
97
+ "CC-BY-NC-4.0",
98
+ "CC-BY-NC-ND-1.0",
99
+ "CC-BY-NC-ND-2.0",
100
+ "CC-BY-NC-ND-2.5",
101
+ "CC-BY-NC-ND-3.0",
102
+ "CC-BY-NC-ND-3.0-DE",
103
+ "CC-BY-NC-ND-3.0-IGO",
104
+ "CC-BY-NC-ND-4.0",
105
+ "CC-BY-NC-SA-1.0",
106
+ "CC-BY-NC-SA-2.0",
107
+ "CC-BY-NC-SA-2.0-FR",
108
+ "CC-BY-NC-SA-2.0-UK",
109
+ "CC-BY-NC-SA-2.5",
110
+ "CC-BY-NC-SA-3.0",
111
+ "CC-BY-NC-SA-3.0-DE",
112
+ "CC-BY-NC-SA-3.0-IGO",
113
+ "CC-BY-NC-SA-4.0",
114
+ "CC-BY-ND-1.0",
115
+ "CC-BY-ND-2.0",
116
+ "CC-BY-ND-2.5",
117
+ "CC-BY-ND-3.0",
118
+ "CC-BY-ND-3.0-DE",
119
+ "CC-BY-ND-4.0",
120
+ "CC-BY-SA-1.0",
121
+ "CC-BY-SA-2.0",
122
+ "CC-BY-SA-2.0-UK",
123
+ "CC-BY-SA-2.1-JP",
124
+ "CC-BY-SA-2.5",
125
+ "CC-BY-SA-3.0",
126
+ "CC-BY-SA-3.0-AT",
127
+ "CC-BY-SA-3.0-DE",
128
+ "CC-BY-SA-4.0",
129
+ "CC-PDDC",
130
+ "CC0-1.0",
131
+ "CDDL-1.0",
132
+ "CDDL-1.1",
133
+ "CDL-1.0",
134
+ "CDLA-Permissive-1.0",
135
+ "CDLA-Permissive-2.0",
136
+ "CDLA-Sharing-1.0",
137
+ "CECILL-1.0",
138
+ "CECILL-1.1",
139
+ "CECILL-2.0",
140
+ "CECILL-2.1",
141
+ "CECILL-B",
142
+ "CECILL-C",
143
+ "CERN-OHL-1.1",
144
+ "CERN-OHL-1.2",
145
+ "CERN-OHL-P-2.0",
146
+ "CERN-OHL-S-2.0",
147
+ "CERN-OHL-W-2.0",
148
+ "checkmk",
149
+ "ClArtistic",
150
+ "CNRI-Jython",
151
+ "CNRI-Python",
152
+ "CNRI-Python-GPL-Compatible",
153
+ "COIL-1.0",
154
+ "Community-Spec-1.0",
155
+ "Condor-1.1",
156
+ "copyleft-next-0.3.0",
157
+ "copyleft-next-0.3.1",
158
+ "CPAL-1.0",
159
+ "CPL-1.0",
160
+ "CPOL-1.02",
161
+ "Crossword",
162
+ "CrystalStacker",
163
+ "CUA-OPL-1.0",
164
+ "Cube",
165
+ "curl",
166
+ "D-FSL-1.0",
167
+ "diffmark",
168
+ "DL-DE-BY-2.0",
169
+ "DOC",
170
+ "Dotseqn",
171
+ "DRL-1.0",
172
+ "DSDP",
173
+ "dvipdfm",
174
+ "ECL-1.0",
175
+ "ECL-2.0",
176
+ "eCos-2.0",
177
+ "EFL-1.0",
178
+ "EFL-2.0",
179
+ "eGenix",
180
+ "Elastic-2.0",
181
+ "Entessa",
182
+ "EPICS",
183
+ "EPL-1.0",
184
+ "EPL-2.0",
185
+ "ErlPL-1.1",
186
+ "etalab-2.0",
187
+ "EUDatagrid",
188
+ "EUPL-1.0",
189
+ "EUPL-1.1",
190
+ "EUPL-1.2",
191
+ "Eurosym",
192
+ "Fair",
193
+ "FDK-AAC",
194
+ "Frameworx-1.0",
195
+ "FreeBSD-DOC",
196
+ "FreeImage",
197
+ "FSFAP",
198
+ "FSFUL",
199
+ "FSFULLR",
200
+ "FSFULLRWD",
201
+ "FTL",
202
+ "GD",
203
+ "GFDL-1.1",
204
+ "GFDL-1.1-invariants-only",
205
+ "GFDL-1.1-invariants-or-later",
206
+ "GFDL-1.1-no-invariants-only",
207
+ "GFDL-1.1-no-invariants-or-later",
208
+ "GFDL-1.1-only",
209
+ "GFDL-1.1-or-later",
210
+ "GFDL-1.2",
211
+ "GFDL-1.2-invariants-only",
212
+ "GFDL-1.2-invariants-or-later",
213
+ "GFDL-1.2-no-invariants-only",
214
+ "GFDL-1.2-no-invariants-or-later",
215
+ "GFDL-1.2-only",
216
+ "GFDL-1.2-or-later",
217
+ "GFDL-1.3",
218
+ "GFDL-1.3-invariants-only",
219
+ "GFDL-1.3-invariants-or-later",
220
+ "GFDL-1.3-no-invariants-only",
221
+ "GFDL-1.3-no-invariants-or-later",
222
+ "GFDL-1.3-only",
223
+ "GFDL-1.3-or-later",
224
+ "Giftware",
225
+ "GL2PS",
226
+ "Glide",
227
+ "Glulxe",
228
+ "GLWTPL",
229
+ "gnuplot",
230
+ "GPL-1.0",
231
+ "GPL-1.0+",
232
+ "GPL-1.0-only",
233
+ "GPL-1.0-or-later",
234
+ "GPL-2.0",
235
+ "GPL-2.0+",
236
+ "GPL-2.0-only",
237
+ "GPL-2.0-or-later",
238
+ "GPL-2.0-with-autoconf-exception",
239
+ "GPL-2.0-with-bison-exception",
240
+ "GPL-2.0-with-classpath-exception",
241
+ "GPL-2.0-with-font-exception",
242
+ "GPL-2.0-with-GCC-exception",
243
+ "GPL-3.0",
244
+ "GPL-3.0+",
245
+ "GPL-3.0-only",
246
+ "GPL-3.0-or-later",
247
+ "GPL-3.0-with-autoconf-exception",
248
+ "GPL-3.0-with-GCC-exception",
249
+ "gSOAP-1.3b",
250
+ "HaskellReport",
251
+ "Hippocratic-2.1",
252
+ "HPND",
253
+ "HPND-sell-variant",
254
+ "HTMLTIDY",
255
+ "IBM-pibs",
256
+ "ICU",
257
+ "IJG",
258
+ "ImageMagick",
259
+ "iMatix",
260
+ "Imlib2",
261
+ "Info-ZIP",
262
+ "Intel",
263
+ "Intel-ACPI",
264
+ "Interbase-1.0",
265
+ "IPA",
266
+ "IPL-1.0",
267
+ "ISC",
268
+ "Jam",
269
+ "JasPer-2.0",
270
+ "JPNIC",
271
+ "JSON",
272
+ "LAL-1.2",
273
+ "LAL-1.3",
274
+ "Latex2e",
275
+ "Leptonica",
276
+ "LGPL-2.0",
277
+ "LGPL-2.0+",
278
+ "LGPL-2.0-only",
279
+ "LGPL-2.0-or-later",
280
+ "LGPL-2.1",
281
+ "LGPL-2.1+",
282
+ "LGPL-2.1-only",
283
+ "LGPL-2.1-or-later",
284
+ "LGPL-3.0",
285
+ "LGPL-3.0+",
286
+ "LGPL-3.0-only",
287
+ "LGPL-3.0-or-later",
288
+ "LGPLLR",
289
+ "Libpng",
290
+ "libpng-2.0",
291
+ "libselinux-1.0",
292
+ "libtiff",
293
+ "LiLiQ-P-1.1",
294
+ "LiLiQ-R-1.1",
295
+ "LiLiQ-Rplus-1.1",
296
+ "Linux-man-pages-copyleft",
297
+ "Linux-OpenIB",
298
+ "LPL-1.0",
299
+ "LPL-1.02",
300
+ "LPPL-1.0",
301
+ "LPPL-1.1",
302
+ "LPPL-1.2",
303
+ "LPPL-1.3a",
304
+ "LPPL-1.3c",
305
+ "LZMA-SDK-9.11-to-9.20",
306
+ "LZMA-SDK-9.22",
307
+ "MakeIndex",
308
+ "Minpack",
309
+ "MirOS",
310
+ "MIT",
311
+ "MIT-0",
312
+ "MIT-advertising",
313
+ "MIT-CMU",
314
+ "MIT-enna",
315
+ "MIT-feh",
316
+ "MIT-Modern-Variant",
317
+ "MIT-open-group",
318
+ "MITNFA",
319
+ "Motosoto",
320
+ "mpi-permissive",
321
+ "mpich2",
322
+ "MPL-1.0",
323
+ "MPL-1.1",
324
+ "MPL-2.0",
325
+ "MPL-2.0-no-copyleft-exception",
326
+ "mplus",
327
+ "MS-LPL",
328
+ "MS-PL",
329
+ "MS-RL",
330
+ "MTLL",
331
+ "MulanPSL-1.0",
332
+ "MulanPSL-2.0",
333
+ "Multics",
334
+ "Mup",
335
+ "NAIST-2003",
336
+ "NASA-1.3",
337
+ "Naumen",
338
+ "NBPL-1.0",
339
+ "NCGL-UK-2.0",
340
+ "NCSA",
341
+ "Net-SNMP",
342
+ "NetCDF",
343
+ "Newsletr",
344
+ "NGPL",
345
+ "NICTA-1.0",
346
+ "NIST-PD",
347
+ "NIST-PD-fallback",
348
+ "NLOD-1.0",
349
+ "NLOD-2.0",
350
+ "NLPL",
351
+ "Nokia",
352
+ "NOSL",
353
+ "Noweb",
354
+ "NPL-1.0",
355
+ "NPL-1.1",
356
+ "NPOSL-3.0",
357
+ "NRL",
358
+ "NTP",
359
+ "NTP-0",
360
+ "Nunit",
361
+ "O-UDA-1.0",
362
+ "OCCT-PL",
363
+ "OCLC-2.0",
364
+ "ODbL-1.0",
365
+ "ODC-By-1.0",
366
+ "OFL-1.0",
367
+ "OFL-1.0-no-RFN",
368
+ "OFL-1.0-RFN",
369
+ "OFL-1.1",
370
+ "OFL-1.1-no-RFN",
371
+ "OFL-1.1-RFN",
372
+ "OGC-1.0",
373
+ "OGDL-Taiwan-1.0",
374
+ "OGL-Canada-2.0",
375
+ "OGL-UK-1.0",
376
+ "OGL-UK-2.0",
377
+ "OGL-UK-3.0",
378
+ "OGTSL",
379
+ "OLDAP-1.1",
380
+ "OLDAP-1.2",
381
+ "OLDAP-1.3",
382
+ "OLDAP-1.4",
383
+ "OLDAP-2.0",
384
+ "OLDAP-2.0.1",
385
+ "OLDAP-2.1",
386
+ "OLDAP-2.2",
387
+ "OLDAP-2.2.1",
388
+ "OLDAP-2.2.2",
389
+ "OLDAP-2.3",
390
+ "OLDAP-2.4",
391
+ "OLDAP-2.5",
392
+ "OLDAP-2.6",
393
+ "OLDAP-2.7",
394
+ "OLDAP-2.8",
395
+ "OML",
396
+ "OpenSSL",
397
+ "OPL-1.0",
398
+ "OPUBL-1.0",
399
+ "OSET-PL-2.1",
400
+ "OSL-1.0",
401
+ "OSL-1.1",
402
+ "OSL-2.0",
403
+ "OSL-2.1",
404
+ "OSL-3.0",
405
+ "Parity-6.0.0",
406
+ "Parity-7.0.0",
407
+ "PDDL-1.0",
408
+ "PHP-3.0",
409
+ "PHP-3.01",
410
+ "Plexus",
411
+ "PolyForm-Noncommercial-1.0.0",
412
+ "PolyForm-Small-Business-1.0.0",
413
+ "PostgreSQL",
414
+ "PSF-2.0",
415
+ "psfrag",
416
+ "psutils",
417
+ "Python-2.0",
418
+ "Python-2.0.1",
419
+ "Qhull",
420
+ "QPL-1.0",
421
+ "Rdisc",
422
+ "RHeCos-1.1",
423
+ "RPL-1.1",
424
+ "RPL-1.5",
425
+ "RPSL-1.0",
426
+ "RSA-MD",
427
+ "RSCPL",
428
+ "Ruby",
429
+ "SAX-PD",
430
+ "Saxpath",
431
+ "SCEA",
432
+ "SchemeReport",
433
+ "Sendmail",
434
+ "Sendmail-8.23",
435
+ "SGI-B-1.0",
436
+ "SGI-B-1.1",
437
+ "SGI-B-2.0",
438
+ "SHL-0.5",
439
+ "SHL-0.51",
440
+ "SimPL-2.0",
441
+ "SISSL",
442
+ "SISSL-1.2",
443
+ "Sleepycat",
444
+ "SMLNJ",
445
+ "SMPPL",
446
+ "SNIA",
447
+ "Spencer-86",
448
+ "Spencer-94",
449
+ "Spencer-99",
450
+ "SPL-1.0",
451
+ "SSH-OpenSSH",
452
+ "SSH-short",
453
+ "SSPL-1.0",
454
+ "StandardML-NJ",
455
+ "SugarCRM-1.1.3",
456
+ "SWL",
457
+ "TAPR-OHL-1.0",
458
+ "TCL",
459
+ "TCP-wrappers",
460
+ "TMate",
461
+ "TORQUE-1.1",
462
+ "TOSL",
463
+ "TU-Berlin-1.0",
464
+ "TU-Berlin-2.0",
465
+ "UCL-1.0",
466
+ "Unicode-DFS-2015",
467
+ "Unicode-DFS-2016",
468
+ "Unicode-TOU",
469
+ "Unlicense",
470
+ "UPL-1.0",
471
+ "Vim",
472
+ "VOSTROM",
473
+ "VSL-1.0",
474
+ "W3C",
475
+ "W3C-19980720",
476
+ "W3C-20150513",
477
+ "Watcom-1.0",
478
+ "Wsuipa",
479
+ "WTFPL",
480
+ "wxWindows",
481
+ "X11",
482
+ "X11-distribute-modifications-variant",
483
+ "Xerox",
484
+ "XFree86-1.1",
485
+ "xinetd",
486
+ "Xnet",
487
+ "xpp",
488
+ "XSkat",
489
+ "YPL-1.0",
490
+ "YPL-1.1",
491
+ "Zed",
492
+ "Zend-2.0",
493
+ "Zimbra-1.3",
494
+ "Zimbra-1.4",
495
+ "Zlib",
496
+ "zlib-acknowledgement",
497
+ "ZPL-1.1",
498
+ "ZPL-2.0",
499
+ "ZPL-2.1"
500
+ ]