@cyclonedx/cdxgen 8.4.13 → 8.5.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/README.md +2 -2
- package/docker.test.js +3 -5
- package/index.js +186 -269
- package/package.json +1 -1
- package/spdx-licenses.json +54 -0
- package/utils.js +159 -36
- package/utils.test.js +98 -47
package/spdx-licenses.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"0BSD",
|
|
3
3
|
"AAL",
|
|
4
4
|
"Abstyles",
|
|
5
|
+
"AdaCore-doc",
|
|
5
6
|
"Adobe-2006",
|
|
6
7
|
"Adobe-Glyph",
|
|
7
8
|
"ADSL",
|
|
@@ -38,16 +39,19 @@
|
|
|
38
39
|
"Artistic-1.0-cl8",
|
|
39
40
|
"Artistic-1.0-Perl",
|
|
40
41
|
"Artistic-2.0",
|
|
42
|
+
"ASWF-Digital-Assets-1.0",
|
|
41
43
|
"Baekmuk",
|
|
42
44
|
"Bahyph",
|
|
43
45
|
"Barr",
|
|
44
46
|
"Beerware",
|
|
47
|
+
"Bitstream-Charter",
|
|
45
48
|
"Bitstream-Vera",
|
|
46
49
|
"BitTorrent-1.0",
|
|
47
50
|
"BitTorrent-1.1",
|
|
48
51
|
"blessing",
|
|
49
52
|
"BlueOak-1.0.0",
|
|
50
53
|
"Borceux",
|
|
54
|
+
"Brian-Gladman-3-Clause",
|
|
51
55
|
"BSD-1-Clause",
|
|
52
56
|
"BSD-2-Clause",
|
|
53
57
|
"BSD-2-Clause-FreeBSD",
|
|
@@ -67,6 +71,10 @@
|
|
|
67
71
|
"BSD-4-Clause",
|
|
68
72
|
"BSD-4-Clause-Shortened",
|
|
69
73
|
"BSD-4-Clause-UC",
|
|
74
|
+
"BSD-4.3RENO",
|
|
75
|
+
"BSD-4.3TAHOE",
|
|
76
|
+
"BSD-Advertising-Acknowledgement",
|
|
77
|
+
"BSD-Attribution-HPND-disclaimer",
|
|
70
78
|
"BSD-Protection",
|
|
71
79
|
"BSD-Source-Code",
|
|
72
80
|
"BSL-1.0",
|
|
@@ -104,6 +112,7 @@
|
|
|
104
112
|
"CC-BY-NC-ND-4.0",
|
|
105
113
|
"CC-BY-NC-SA-1.0",
|
|
106
114
|
"CC-BY-NC-SA-2.0",
|
|
115
|
+
"CC-BY-NC-SA-2.0-DE",
|
|
107
116
|
"CC-BY-NC-SA-2.0-FR",
|
|
108
117
|
"CC-BY-NC-SA-2.0-UK",
|
|
109
118
|
"CC-BY-NC-SA-2.5",
|
|
@@ -125,6 +134,7 @@
|
|
|
125
134
|
"CC-BY-SA-3.0",
|
|
126
135
|
"CC-BY-SA-3.0-AT",
|
|
127
136
|
"CC-BY-SA-3.0-DE",
|
|
137
|
+
"CC-BY-SA-3.0-IGO",
|
|
128
138
|
"CC-BY-SA-4.0",
|
|
129
139
|
"CC-PDDC",
|
|
130
140
|
"CC0-1.0",
|
|
@@ -145,8 +155,11 @@
|
|
|
145
155
|
"CERN-OHL-P-2.0",
|
|
146
156
|
"CERN-OHL-S-2.0",
|
|
147
157
|
"CERN-OHL-W-2.0",
|
|
158
|
+
"CFITSIO",
|
|
148
159
|
"checkmk",
|
|
149
160
|
"ClArtistic",
|
|
161
|
+
"Clips",
|
|
162
|
+
"CMU-Mach",
|
|
150
163
|
"CNRI-Jython",
|
|
151
164
|
"CNRI-Python",
|
|
152
165
|
"CNRI-Python-GPL-Compatible",
|
|
@@ -155,10 +168,12 @@
|
|
|
155
168
|
"Condor-1.1",
|
|
156
169
|
"copyleft-next-0.3.0",
|
|
157
170
|
"copyleft-next-0.3.1",
|
|
171
|
+
"Cornell-Lossless-JPEG",
|
|
158
172
|
"CPAL-1.0",
|
|
159
173
|
"CPL-1.0",
|
|
160
174
|
"CPOL-1.02",
|
|
161
175
|
"Crossword",
|
|
176
|
+
"cryptsetup-OpenSSL-exception",
|
|
162
177
|
"CrystalStacker",
|
|
163
178
|
"CUA-OPL-1.0",
|
|
164
179
|
"Cube",
|
|
@@ -246,15 +261,22 @@
|
|
|
246
261
|
"GPL-3.0-or-later",
|
|
247
262
|
"GPL-3.0-with-autoconf-exception",
|
|
248
263
|
"GPL-3.0-with-GCC-exception",
|
|
264
|
+
"Graphics-Gems",
|
|
249
265
|
"gSOAP-1.3b",
|
|
250
266
|
"HaskellReport",
|
|
251
267
|
"Hippocratic-2.1",
|
|
268
|
+
"HP-1986",
|
|
252
269
|
"HPND",
|
|
270
|
+
"HPND-export-US",
|
|
271
|
+
"HPND-Markus-Kuhn",
|
|
253
272
|
"HPND-sell-variant",
|
|
273
|
+
"HPND-sell-variant-MIT-disclaimer",
|
|
254
274
|
"HTMLTIDY",
|
|
255
275
|
"IBM-pibs",
|
|
256
276
|
"ICU",
|
|
277
|
+
"IEC-Code-Components-EULA",
|
|
257
278
|
"IJG",
|
|
279
|
+
"IJG-short",
|
|
258
280
|
"ImageMagick",
|
|
259
281
|
"iMatix",
|
|
260
282
|
"Imlib2",
|
|
@@ -267,11 +289,15 @@
|
|
|
267
289
|
"ISC",
|
|
268
290
|
"Jam",
|
|
269
291
|
"JasPer-2.0",
|
|
292
|
+
"JPL-image",
|
|
270
293
|
"JPNIC",
|
|
271
294
|
"JSON",
|
|
295
|
+
"Kazlib",
|
|
296
|
+
"Knuth-CTAN",
|
|
272
297
|
"LAL-1.2",
|
|
273
298
|
"LAL-1.3",
|
|
274
299
|
"Latex2e",
|
|
300
|
+
"Latex2e-translated-notice",
|
|
275
301
|
"Leptonica",
|
|
276
302
|
"LGPL-2.0",
|
|
277
303
|
"LGPL-2.0+",
|
|
@@ -288,13 +314,17 @@
|
|
|
288
314
|
"LGPLLR",
|
|
289
315
|
"Libpng",
|
|
290
316
|
"libpng-2.0",
|
|
317
|
+
"libpri-OpenH323-exception",
|
|
291
318
|
"libselinux-1.0",
|
|
292
319
|
"libtiff",
|
|
320
|
+
"libutil-David-Nugent",
|
|
293
321
|
"LiLiQ-P-1.1",
|
|
294
322
|
"LiLiQ-R-1.1",
|
|
295
323
|
"LiLiQ-Rplus-1.1",
|
|
296
324
|
"Linux-man-pages-copyleft",
|
|
325
|
+
"Linux-man-pages-one-para",
|
|
297
326
|
"Linux-OpenIB",
|
|
327
|
+
"LOOP",
|
|
298
328
|
"LPL-1.0",
|
|
299
329
|
"LPL-1.02",
|
|
300
330
|
"LPPL-1.0",
|
|
@@ -305,6 +335,8 @@
|
|
|
305
335
|
"LZMA-SDK-9.11-to-9.20",
|
|
306
336
|
"LZMA-SDK-9.22",
|
|
307
337
|
"MakeIndex",
|
|
338
|
+
"Martin-Birgmeier",
|
|
339
|
+
"metamail",
|
|
308
340
|
"Minpack",
|
|
309
341
|
"MirOS",
|
|
310
342
|
"MIT",
|
|
@@ -313,8 +345,10 @@
|
|
|
313
345
|
"MIT-CMU",
|
|
314
346
|
"MIT-enna",
|
|
315
347
|
"MIT-feh",
|
|
348
|
+
"MIT-Festival",
|
|
316
349
|
"MIT-Modern-Variant",
|
|
317
350
|
"MIT-open-group",
|
|
351
|
+
"MIT-Wu",
|
|
318
352
|
"MITNFA",
|
|
319
353
|
"Motosoto",
|
|
320
354
|
"mpi-permissive",
|
|
@@ -345,6 +379,7 @@
|
|
|
345
379
|
"NICTA-1.0",
|
|
346
380
|
"NIST-PD",
|
|
347
381
|
"NIST-PD-fallback",
|
|
382
|
+
"NIST-Software",
|
|
348
383
|
"NLOD-1.0",
|
|
349
384
|
"NLOD-2.0",
|
|
350
385
|
"NLPL",
|
|
@@ -363,6 +398,7 @@
|
|
|
363
398
|
"OCLC-2.0",
|
|
364
399
|
"ODbL-1.0",
|
|
365
400
|
"ODC-By-1.0",
|
|
401
|
+
"OFFIS",
|
|
366
402
|
"OFL-1.0",
|
|
367
403
|
"OFL-1.0-no-RFN",
|
|
368
404
|
"OFL-1.0-RFN",
|
|
@@ -392,7 +428,9 @@
|
|
|
392
428
|
"OLDAP-2.6",
|
|
393
429
|
"OLDAP-2.7",
|
|
394
430
|
"OLDAP-2.8",
|
|
431
|
+
"OLFL-1.3",
|
|
395
432
|
"OML",
|
|
433
|
+
"OpenPBS-2.3",
|
|
396
434
|
"OpenSSL",
|
|
397
435
|
"OPL-1.0",
|
|
398
436
|
"OPUBL-1.0",
|
|
@@ -418,6 +456,7 @@
|
|
|
418
456
|
"Python-2.0.1",
|
|
419
457
|
"Qhull",
|
|
420
458
|
"QPL-1.0",
|
|
459
|
+
"QPL-1.0-INRIA-2004",
|
|
421
460
|
"Rdisc",
|
|
422
461
|
"RHeCos-1.1",
|
|
423
462
|
"RPL-1.1",
|
|
@@ -435,6 +474,7 @@
|
|
|
435
474
|
"SGI-B-1.0",
|
|
436
475
|
"SGI-B-1.1",
|
|
437
476
|
"SGI-B-2.0",
|
|
477
|
+
"SGP4",
|
|
438
478
|
"SHL-0.5",
|
|
439
479
|
"SHL-0.51",
|
|
440
480
|
"SimPL-2.0",
|
|
@@ -444,6 +484,7 @@
|
|
|
444
484
|
"SMLNJ",
|
|
445
485
|
"SMPPL",
|
|
446
486
|
"SNIA",
|
|
487
|
+
"snprintf",
|
|
447
488
|
"Spencer-86",
|
|
448
489
|
"Spencer-94",
|
|
449
490
|
"Spencer-99",
|
|
@@ -453,19 +494,27 @@
|
|
|
453
494
|
"SSPL-1.0",
|
|
454
495
|
"StandardML-NJ",
|
|
455
496
|
"SugarCRM-1.1.3",
|
|
497
|
+
"SunPro",
|
|
456
498
|
"SWL",
|
|
499
|
+
"Symlinks",
|
|
457
500
|
"TAPR-OHL-1.0",
|
|
458
501
|
"TCL",
|
|
459
502
|
"TCP-wrappers",
|
|
503
|
+
"TermReadKey",
|
|
460
504
|
"TMate",
|
|
461
505
|
"TORQUE-1.1",
|
|
462
506
|
"TOSL",
|
|
507
|
+
"TPDL",
|
|
508
|
+
"TPL-1.0",
|
|
509
|
+
"TTWL",
|
|
463
510
|
"TU-Berlin-1.0",
|
|
464
511
|
"TU-Berlin-2.0",
|
|
512
|
+
"UCAR",
|
|
465
513
|
"UCL-1.0",
|
|
466
514
|
"Unicode-DFS-2015",
|
|
467
515
|
"Unicode-DFS-2016",
|
|
468
516
|
"Unicode-TOU",
|
|
517
|
+
"UnixCrypt",
|
|
469
518
|
"Unlicense",
|
|
470
519
|
"UPL-1.0",
|
|
471
520
|
"Vim",
|
|
@@ -474,15 +523,20 @@
|
|
|
474
523
|
"W3C",
|
|
475
524
|
"W3C-19980720",
|
|
476
525
|
"W3C-20150513",
|
|
526
|
+
"w3m",
|
|
477
527
|
"Watcom-1.0",
|
|
528
|
+
"Widget-Workshop",
|
|
478
529
|
"Wsuipa",
|
|
479
530
|
"WTFPL",
|
|
480
531
|
"wxWindows",
|
|
481
532
|
"X11",
|
|
482
533
|
"X11-distribute-modifications-variant",
|
|
534
|
+
"Xdebug-1.03",
|
|
483
535
|
"Xerox",
|
|
536
|
+
"Xfig",
|
|
484
537
|
"XFree86-1.1",
|
|
485
538
|
"xinetd",
|
|
539
|
+
"xlock",
|
|
486
540
|
"Xnet",
|
|
487
541
|
"xpp",
|
|
488
542
|
"XSkat",
|
package/utils.js
CHANGED
|
@@ -1181,11 +1181,13 @@ exports.parseMavenTree = parseMavenTree;
|
|
|
1181
1181
|
/**
|
|
1182
1182
|
* Parse gradle dependencies output
|
|
1183
1183
|
* @param {string} rawOutput Raw string output
|
|
1184
|
+
* @param {string} rootProjectGroup Root project group
|
|
1184
1185
|
* @param {string} rootProjectName Root project name
|
|
1185
1186
|
* @param {string} rootProjectVersion Root project version
|
|
1186
1187
|
*/
|
|
1187
1188
|
const parseGradleDep = function (
|
|
1188
1189
|
rawOutput,
|
|
1190
|
+
rootProjectGroup = "",
|
|
1189
1191
|
rootProjectName = "root",
|
|
1190
1192
|
rootProjectVersion = "latest"
|
|
1191
1193
|
) {
|
|
@@ -1205,18 +1207,27 @@ const parseGradleDep = function (
|
|
|
1205
1207
|
let match = "";
|
|
1206
1208
|
// To render dependency tree we need a root project
|
|
1207
1209
|
const rootProject = {
|
|
1208
|
-
group: "",
|
|
1210
|
+
group: rootProjectGroup || "",
|
|
1209
1211
|
name: rootProjectName,
|
|
1210
1212
|
version: rootProjectVersion,
|
|
1211
1213
|
type: "maven",
|
|
1212
1214
|
qualifiers: { type: "jar" }
|
|
1213
1215
|
};
|
|
1214
|
-
const deps = [
|
|
1216
|
+
const deps = [];
|
|
1215
1217
|
const dependenciesList = [];
|
|
1216
1218
|
const keys_cache = {};
|
|
1217
1219
|
const deps_keys_cache = {};
|
|
1218
1220
|
let last_level = 0;
|
|
1219
|
-
let last_purl =
|
|
1221
|
+
let last_purl = decodeURIComponent(
|
|
1222
|
+
new PackageURL(
|
|
1223
|
+
"maven",
|
|
1224
|
+
rootProject.group,
|
|
1225
|
+
rootProject.name,
|
|
1226
|
+
rootProject.version,
|
|
1227
|
+
rootProject.qualifiers,
|
|
1228
|
+
null
|
|
1229
|
+
).toString()
|
|
1230
|
+
);
|
|
1220
1231
|
const first_purl = last_purl;
|
|
1221
1232
|
let last_project_purl = first_purl;
|
|
1222
1233
|
const level_trees = {};
|
|
@@ -1230,7 +1241,7 @@ const parseGradleDep = function (
|
|
|
1230
1241
|
decodeURIComponent(
|
|
1231
1242
|
new PackageURL(
|
|
1232
1243
|
"maven",
|
|
1233
|
-
|
|
1244
|
+
rootProjectGroup,
|
|
1234
1245
|
sd.replace(":", ""),
|
|
1235
1246
|
rootProject.version,
|
|
1236
1247
|
rootProject.qualifiers,
|
|
@@ -1452,7 +1463,6 @@ exports.parseLeinMap = parseLeinMap;
|
|
|
1452
1463
|
|
|
1453
1464
|
/**
|
|
1454
1465
|
* Parse gradle projects output
|
|
1455
|
-
* FIXME: The method needs to be enhanced to capture project dependency tree. See issue #249
|
|
1456
1466
|
*
|
|
1457
1467
|
* @param {string} rawOutput Raw string output
|
|
1458
1468
|
*/
|
|
@@ -1486,18 +1496,121 @@ const parseGradleProjects = function (rawOutput) {
|
|
|
1486
1496
|
}
|
|
1487
1497
|
}
|
|
1488
1498
|
});
|
|
1489
|
-
return {
|
|
1490
|
-
rootProject,
|
|
1491
|
-
projects: Array.from(projects)
|
|
1492
|
-
};
|
|
1493
1499
|
}
|
|
1494
1500
|
return {
|
|
1495
1501
|
rootProject,
|
|
1496
|
-
projects:
|
|
1502
|
+
projects: Array.from(projects)
|
|
1497
1503
|
};
|
|
1498
1504
|
};
|
|
1499
1505
|
exports.parseGradleProjects = parseGradleProjects;
|
|
1500
1506
|
|
|
1507
|
+
/**
|
|
1508
|
+
* Parse gradle properties output
|
|
1509
|
+
*
|
|
1510
|
+
* @param {string} rawOutput Raw string output
|
|
1511
|
+
*/
|
|
1512
|
+
const parseGradleProperties = function (rawOutput) {
|
|
1513
|
+
let rootProject = "root";
|
|
1514
|
+
let projects = new Set();
|
|
1515
|
+
const metadata = { group: "", version: "latest", properties: [] };
|
|
1516
|
+
if (typeof rawOutput === "string") {
|
|
1517
|
+
const tmpA = rawOutput.split("\n");
|
|
1518
|
+
tmpA.forEach((l) => {
|
|
1519
|
+
if (l.startsWith("----") || l.startsWith(">") || !l.includes(": ")) {
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
const tmpB = l.split(": ");
|
|
1523
|
+
if (tmpB && tmpB.length === 2) {
|
|
1524
|
+
if (tmpB[0] === "name") {
|
|
1525
|
+
rootProject = tmpB[1].trim();
|
|
1526
|
+
} else if (tmpB[0] === "group") {
|
|
1527
|
+
metadata[tmpB[0]] = tmpB[1];
|
|
1528
|
+
} else if (tmpB[0] === "version") {
|
|
1529
|
+
metadata[tmpB[0]] = tmpB[1].trim().replace("unspecified", "latest");
|
|
1530
|
+
} else if (["buildFile", "projectDir", "rootDir"].includes(tmpB[0])) {
|
|
1531
|
+
metadata.properties.push({ name: tmpB[0], value: tmpB[1].trim() });
|
|
1532
|
+
} else if (tmpB[0] === "subprojects") {
|
|
1533
|
+
const spStrs = tmpB[1].replace(/[[\]']/g, "").split(", ");
|
|
1534
|
+
const tmpprojects = spStrs
|
|
1535
|
+
.flatMap((s) => s.replace("project ", ""))
|
|
1536
|
+
.filter((s) => s !== ":app");
|
|
1537
|
+
tmpprojects.forEach(projects.add, projects);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
return {
|
|
1543
|
+
rootProject,
|
|
1544
|
+
projects: Array.from(projects),
|
|
1545
|
+
metadata
|
|
1546
|
+
};
|
|
1547
|
+
};
|
|
1548
|
+
exports.parseGradleProperties = parseGradleProperties;
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* Execute gradle properties command and return parsed output
|
|
1552
|
+
*
|
|
1553
|
+
* @param {string} dir Directory to execute the command
|
|
1554
|
+
* @param {string} rootPath Root directory
|
|
1555
|
+
* @param {string} subProject Sub project name
|
|
1556
|
+
*/
|
|
1557
|
+
const executeGradleProperties = function (dir, rootPath, subProject) {
|
|
1558
|
+
const defaultProps = {
|
|
1559
|
+
rootProject: subProject,
|
|
1560
|
+
projects: [],
|
|
1561
|
+
metadata: {
|
|
1562
|
+
version: "latest"
|
|
1563
|
+
}
|
|
1564
|
+
};
|
|
1565
|
+
// To optimize performance and reduce errors do not query for properties
|
|
1566
|
+
// beyond the first level
|
|
1567
|
+
if (subProject && subProject.match(/:/g).length >= 2) {
|
|
1568
|
+
return defaultProps;
|
|
1569
|
+
}
|
|
1570
|
+
let gradlePropertiesArgs = [
|
|
1571
|
+
subProject ? `${subProject}:properties` : "properties",
|
|
1572
|
+
"-q",
|
|
1573
|
+
"--console",
|
|
1574
|
+
"plain",
|
|
1575
|
+
"--build-cache"
|
|
1576
|
+
];
|
|
1577
|
+
let gradleCmd = getGradleCommand(dir, rootPath);
|
|
1578
|
+
if (process.env.GRADLE_ARGS) {
|
|
1579
|
+
const addArgs = process.env.GRADLE_ARGS.split(" ");
|
|
1580
|
+
gradlePropertiesArgs = gradlePropertiesArgs.concat(addArgs);
|
|
1581
|
+
}
|
|
1582
|
+
console.log(
|
|
1583
|
+
"Executing",
|
|
1584
|
+
gradleCmd,
|
|
1585
|
+
gradlePropertiesArgs.join(" "),
|
|
1586
|
+
"in",
|
|
1587
|
+
dir
|
|
1588
|
+
);
|
|
1589
|
+
const result = spawnSync(gradleCmd, gradlePropertiesArgs, {
|
|
1590
|
+
cwd: dir,
|
|
1591
|
+
encoding: "utf-8"
|
|
1592
|
+
});
|
|
1593
|
+
if (result.status !== 0 || result.error) {
|
|
1594
|
+
if (result.stderr) {
|
|
1595
|
+
if (result.stderr.includes("does not exist")) {
|
|
1596
|
+
return defaultProps;
|
|
1597
|
+
} else {
|
|
1598
|
+
console.error(result.stdout, result.stderr);
|
|
1599
|
+
console.log(
|
|
1600
|
+
"1. Check if the correct version of java and gradle are installed and available in PATH. For example, some project might require Java 11 with gradle 7.\n cdxgen container image bundles Java 17 with gradle 8 which might be incompatible."
|
|
1601
|
+
);
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
const stdout = result.stdout;
|
|
1606
|
+
if (stdout) {
|
|
1607
|
+
const cmdOutput = Buffer.from(stdout).toString();
|
|
1608
|
+
return parseGradleProperties(cmdOutput);
|
|
1609
|
+
}
|
|
1610
|
+
return {};
|
|
1611
|
+
};
|
|
1612
|
+
exports.executeGradleProperties = executeGradleProperties;
|
|
1613
|
+
|
|
1501
1614
|
/**
|
|
1502
1615
|
* Parse bazel skyframe state output
|
|
1503
1616
|
* @param {string} rawOutput Raw string output
|
|
@@ -1766,15 +1879,14 @@ exports.parsePyRequiresDist = parsePyRequiresDist;
|
|
|
1766
1879
|
* Method to retrieve metadata for python packages by querying pypi
|
|
1767
1880
|
*
|
|
1768
1881
|
* @param {Array} pkgList Package list
|
|
1769
|
-
* @param {Boolean}
|
|
1882
|
+
* @param {Boolean} fetchDepsInfo Fetch dependencies info from pypi
|
|
1770
1883
|
*/
|
|
1771
|
-
const getPyMetadata = async function (pkgList,
|
|
1772
|
-
if (!fetchLicenses && !
|
|
1884
|
+
const getPyMetadata = async function (pkgList, fetchDepsInfo) {
|
|
1885
|
+
if (!fetchLicenses && !fetchDepsInfo) {
|
|
1773
1886
|
return pkgList;
|
|
1774
1887
|
}
|
|
1775
1888
|
const PYPI_URL = "https://pypi.org/pypi/";
|
|
1776
1889
|
let cdepList = [];
|
|
1777
|
-
let indirectDeps = [];
|
|
1778
1890
|
for (const p of pkgList) {
|
|
1779
1891
|
if (!p || !p.name) {
|
|
1780
1892
|
continue;
|
|
@@ -1810,12 +1922,6 @@ const getPyMetadata = async function (pkgList, fetchIndirectDeps) {
|
|
|
1810
1922
|
) {
|
|
1811
1923
|
p.version = body.info.version;
|
|
1812
1924
|
}
|
|
1813
|
-
const requires_dist = body.info.requires_dist;
|
|
1814
|
-
if (requires_dist && requires_dist.length) {
|
|
1815
|
-
indirectDeps = indirectDeps.concat(
|
|
1816
|
-
requires_dist.map(parsePyRequiresDist)
|
|
1817
|
-
);
|
|
1818
|
-
}
|
|
1819
1925
|
if (body.releases && body.releases[p.version]) {
|
|
1820
1926
|
const digest = body.releases[p.version][0].digests;
|
|
1821
1927
|
if (digest["sha256"]) {
|
|
@@ -1832,13 +1938,6 @@ const getPyMetadata = async function (pkgList, fetchIndirectDeps) {
|
|
|
1832
1938
|
}
|
|
1833
1939
|
}
|
|
1834
1940
|
}
|
|
1835
|
-
if (indirectDeps.length && fetchIndirectDeps) {
|
|
1836
|
-
if (DEBUG_MODE) {
|
|
1837
|
-
console.log("Fetching metadata for indirect dependencies");
|
|
1838
|
-
}
|
|
1839
|
-
const extraList = await getPyMetadata(indirectDeps, false);
|
|
1840
|
-
cdepList = cdepList.concat(extraList);
|
|
1841
|
-
}
|
|
1842
1941
|
return cdepList;
|
|
1843
1942
|
};
|
|
1844
1943
|
exports.getPyMetadata = getPyMetadata;
|
|
@@ -1938,18 +2037,22 @@ exports.parsePoetrylockData = parsePoetrylockData;
|
|
|
1938
2037
|
* Method to parse requirements.txt data
|
|
1939
2038
|
*
|
|
1940
2039
|
* @param {Object} reqData Requirements.txt data
|
|
2040
|
+
* @param {Boolean} fetchIndirectDeps Should we also fetch data about indirect dependencies from pypi
|
|
1941
2041
|
*/
|
|
1942
|
-
|
|
2042
|
+
async function parseReqFile(reqData, fetchIndirectDeps) {
|
|
1943
2043
|
const pkgList = [];
|
|
1944
|
-
let fetchIndirectDeps = false;
|
|
1945
2044
|
let compScope = undefined;
|
|
1946
2045
|
reqData.split("\n").forEach((l) => {
|
|
2046
|
+
l = l.trim();
|
|
1947
2047
|
if (l.includes("# Basic requirements")) {
|
|
1948
2048
|
compScope = "required";
|
|
1949
2049
|
} else if (l.includes("added by pip freeze")) {
|
|
1950
2050
|
compScope = undefined;
|
|
1951
2051
|
}
|
|
1952
|
-
if (!l.startsWith("#")) {
|
|
2052
|
+
if (!l.startsWith("#") && !l.startsWith("-")) {
|
|
2053
|
+
if (l.includes(" ")) {
|
|
2054
|
+
l = l.split(" ")[0];
|
|
2055
|
+
}
|
|
1953
2056
|
if (l.indexOf("=") > -1) {
|
|
1954
2057
|
let tmpA = l.split(/(==|<=|~=|>=)/);
|
|
1955
2058
|
if (tmpA.includes("#")) {
|
|
@@ -1964,11 +2067,24 @@ const parseReqFile = async function (reqData) {
|
|
|
1964
2067
|
}
|
|
1965
2068
|
if (!tmpA[0].includes("=") && !tmpA[0].trim().includes(" ")) {
|
|
1966
2069
|
pkgList.push({
|
|
1967
|
-
name: tmpA[0].trim(),
|
|
2070
|
+
name: tmpA[0].trim().replace(";", ""),
|
|
1968
2071
|
version: versionStr,
|
|
1969
2072
|
scope: compScope
|
|
1970
2073
|
});
|
|
1971
2074
|
}
|
|
2075
|
+
} else if (l.includes("<") && l.includes(">")) {
|
|
2076
|
+
let tmpA = l.split(">");
|
|
2077
|
+
let name = tmpA[0].trim().replace(";", "");
|
|
2078
|
+
let version = undefined;
|
|
2079
|
+
const tmpB = tmpA[1].split("<");
|
|
2080
|
+
if (tmpB && tmpB.length) {
|
|
2081
|
+
version = tmpB[tmpB.length - 1];
|
|
2082
|
+
}
|
|
2083
|
+
pkgList.push({
|
|
2084
|
+
name,
|
|
2085
|
+
version,
|
|
2086
|
+
scope: compScope
|
|
2087
|
+
});
|
|
1972
2088
|
} else if (/[>|[|@]/.test(l)) {
|
|
1973
2089
|
let tmpA = l.split(/(>|\[|@)/);
|
|
1974
2090
|
if (tmpA.includes("#")) {
|
|
@@ -1976,7 +2092,7 @@ const parseReqFile = async function (reqData) {
|
|
|
1976
2092
|
}
|
|
1977
2093
|
if (!tmpA[0].trim().includes(" ")) {
|
|
1978
2094
|
pkgList.push({
|
|
1979
|
-
name: tmpA[0].trim(),
|
|
2095
|
+
name: tmpA[0].trim().replace(";", ""),
|
|
1980
2096
|
version: null,
|
|
1981
2097
|
scope: compScope
|
|
1982
2098
|
});
|
|
@@ -1986,9 +2102,16 @@ const parseReqFile = async function (reqData) {
|
|
|
1986
2102
|
l = l.split("#")[0];
|
|
1987
2103
|
}
|
|
1988
2104
|
l = l.trim();
|
|
1989
|
-
|
|
2105
|
+
let tmpA = l.split(/(<|>)/);
|
|
2106
|
+
if (tmpA && tmpA.length === 3) {
|
|
2107
|
+
pkgList.push({
|
|
2108
|
+
name: tmpA[0].trim().replace(";", ""),
|
|
2109
|
+
version: tmpA[2].replace(";", ""),
|
|
2110
|
+
scope: compScope
|
|
2111
|
+
});
|
|
2112
|
+
} else if (!l.includes(" ")) {
|
|
1990
2113
|
pkgList.push({
|
|
1991
|
-
name: l,
|
|
2114
|
+
name: l.replace(";", ""),
|
|
1992
2115
|
version: null,
|
|
1993
2116
|
scope: compScope
|
|
1994
2117
|
});
|
|
@@ -1997,7 +2120,7 @@ const parseReqFile = async function (reqData) {
|
|
|
1997
2120
|
}
|
|
1998
2121
|
});
|
|
1999
2122
|
return await getPyMetadata(pkgList, fetchIndirectDeps);
|
|
2000
|
-
}
|
|
2123
|
+
}
|
|
2001
2124
|
exports.parseReqFile = parseReqFile;
|
|
2002
2125
|
|
|
2003
2126
|
/**
|
|
@@ -2025,7 +2148,7 @@ const parseSetupPyFile = async function (setupPyData) {
|
|
|
2025
2148
|
lines = lines.concat(tmpA);
|
|
2026
2149
|
}
|
|
2027
2150
|
});
|
|
2028
|
-
return await parseReqFile(lines.join("\n"));
|
|
2151
|
+
return await parseReqFile(lines.join("\n"), false);
|
|
2029
2152
|
};
|
|
2030
2153
|
exports.parseSetupPyFile = parseSetupPyFile;
|
|
2031
2154
|
|