@cyclonedx/cdxgen 10.3.5 → 10.4.1
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 -4
- package/analyzer.js +19 -21
- package/bin/cdxgen.js +78 -77
- package/bin/evinse.js +26 -26
- package/bin/repl.js +56 -62
- package/bin/verify.js +9 -9
- package/binary.js +55 -54
- package/cbomutils.js +6 -6
- package/db.js +17 -17
- package/display.js +30 -30
- package/display.test.js +2 -2
- package/docker.js +93 -90
- package/docker.test.js +30 -30
- package/envcontext.js +15 -15
- package/envcontext.test.js +1 -1
- package/evinser.js +94 -93
- package/evinser.test.js +24 -24
- package/index.js +522 -482
- package/package.json +8 -16
- package/piptree.js +6 -6
- package/postgen.js +2 -5
- package/postgen.test.js +5 -5
- package/protobom.js +37 -7
- package/protobom.test.js +6 -6
- package/server.js +16 -16
- package/types/analyzer.d.ts +7 -4
- package/types/analyzer.d.ts.map +1 -1
- package/types/binary.d.ts +12 -8
- package/types/binary.d.ts.map +1 -1
- package/types/cbomutils.d.ts +1 -1
- package/types/db.d.ts +22 -9
- package/types/db.d.ts.map +1 -1
- package/types/display.d.ts +1 -1
- package/types/docker.d.ts +52 -32
- package/types/docker.d.ts.map +1 -1
- package/types/envcontext.d.ts +40 -40
- package/types/evinser.d.ts +3436 -717
- package/types/evinser.d.ts.map +1 -1
- package/types/index.d.ts +66 -40
- package/types/index.d.ts.map +1 -1
- package/types/jest.config.d.ts +2 -2
- package/types/piptree.d.ts +6 -2
- package/types/postgen.d.ts +1 -1
- package/types/postgen.d.ts.map +1 -1
- package/types/protobom.d.ts +7 -3
- package/types/protobom.d.ts.map +1 -1
- package/types/server.d.ts +1 -1
- package/types/utils.d.ts +521 -303
- package/types/utils.d.ts.map +1 -1
- package/types/validator.d.ts +1 -1
- package/types/validator.d.ts.map +1 -1
- package/utils.js +748 -676
- package/utils.test.js +720 -674
- package/validator.js +20 -17
package/utils.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import { globSync } from "glob";
|
|
2
|
-
import { homedir, platform, tmpdir } from "node:os";
|
|
3
|
-
import process from "node:process";
|
|
4
1
|
import { Buffer } from "node:buffer";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
5
4
|
import {
|
|
6
|
-
delimiter as _delimiter,
|
|
7
|
-
sep as _sep,
|
|
8
|
-
basename,
|
|
9
|
-
dirname,
|
|
10
|
-
extname,
|
|
11
|
-
join,
|
|
12
|
-
resolve
|
|
13
|
-
} from "node:path";
|
|
14
|
-
import {
|
|
15
|
-
chmodSync,
|
|
16
5
|
constants,
|
|
6
|
+
chmodSync,
|
|
17
7
|
copyFileSync,
|
|
18
8
|
createReadStream,
|
|
19
9
|
existsSync,
|
|
@@ -22,17 +12,30 @@ import {
|
|
|
22
12
|
readFileSync,
|
|
23
13
|
rmSync,
|
|
24
14
|
unlinkSync,
|
|
25
|
-
writeFileSync
|
|
15
|
+
writeFileSync,
|
|
26
16
|
} from "node:fs";
|
|
27
|
-
import {
|
|
28
|
-
import
|
|
29
|
-
|
|
17
|
+
import { homedir, platform, tmpdir } from "node:os";
|
|
18
|
+
import {
|
|
19
|
+
delimiter as _delimiter,
|
|
20
|
+
sep as _sep,
|
|
21
|
+
basename,
|
|
22
|
+
dirname,
|
|
23
|
+
extname,
|
|
24
|
+
join,
|
|
25
|
+
resolve,
|
|
26
|
+
} from "node:path";
|
|
30
27
|
import path from "node:path";
|
|
31
|
-
import
|
|
28
|
+
import process from "node:process";
|
|
32
29
|
import { URL, fileURLToPath } from "node:url";
|
|
30
|
+
import Arborist from "@npmcli/arborist";
|
|
33
31
|
import { load } from "cheerio";
|
|
32
|
+
import { parseEDNString } from "edn-data";
|
|
33
|
+
import { globSync } from "glob";
|
|
34
|
+
import got from "got";
|
|
35
|
+
import iconv from "iconv-lite";
|
|
34
36
|
import { load as _load } from "js-yaml";
|
|
35
|
-
import
|
|
37
|
+
import StreamZip from "node-stream-zip";
|
|
38
|
+
import { PackageURL } from "packageurl-js";
|
|
36
39
|
import propertiesReader from "properties-reader";
|
|
37
40
|
import {
|
|
38
41
|
clean,
|
|
@@ -41,13 +44,10 @@ import {
|
|
|
41
44
|
maxSatisfying,
|
|
42
45
|
parse,
|
|
43
46
|
satisfies,
|
|
44
|
-
valid
|
|
47
|
+
valid,
|
|
45
48
|
} from "semver";
|
|
46
|
-
import
|
|
47
|
-
import { parseEDNString } from "edn-data";
|
|
48
|
-
import { PackageURL } from "packageurl-js";
|
|
49
|
+
import { xml2js } from "xml-js";
|
|
49
50
|
import { getTreeWithPlugin } from "./piptree.js";
|
|
50
|
-
import iconv from "iconv-lite";
|
|
51
51
|
|
|
52
52
|
let url = import.meta.url;
|
|
53
53
|
if (!url.startsWith("file://")) {
|
|
@@ -64,36 +64,36 @@ if (isWin) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
const licenseMapping = JSON.parse(
|
|
67
|
-
readFileSync(join(dirNameStr, "data", "lic-mapping.json"), "utf-8")
|
|
67
|
+
readFileSync(join(dirNameStr, "data", "lic-mapping.json"), "utf-8"),
|
|
68
68
|
);
|
|
69
69
|
const vendorAliases = JSON.parse(
|
|
70
|
-
readFileSync(join(dirNameStr, "data", "vendor-alias.json"), "utf-8")
|
|
70
|
+
readFileSync(join(dirNameStr, "data", "vendor-alias.json"), "utf-8"),
|
|
71
71
|
);
|
|
72
72
|
const spdxLicenses = JSON.parse(
|
|
73
|
-
readFileSync(join(dirNameStr, "data", "spdx-licenses.json"), "utf-8")
|
|
73
|
+
readFileSync(join(dirNameStr, "data", "spdx-licenses.json"), "utf-8"),
|
|
74
74
|
);
|
|
75
75
|
const knownLicenses = JSON.parse(
|
|
76
|
-
readFileSync(join(dirNameStr, "data", "known-licenses.json"), "utf-8")
|
|
76
|
+
readFileSync(join(dirNameStr, "data", "known-licenses.json"), "utf-8"),
|
|
77
77
|
);
|
|
78
78
|
const mesonWrapDB = JSON.parse(
|
|
79
|
-
readFileSync(join(dirNameStr, "data", "wrapdb-releases.json"), "utf-8")
|
|
79
|
+
readFileSync(join(dirNameStr, "data", "wrapdb-releases.json"), "utf-8"),
|
|
80
80
|
);
|
|
81
81
|
export const frameworksList = JSON.parse(
|
|
82
|
-
readFileSync(join(dirNameStr, "data", "frameworks-list.json"), "utf-8")
|
|
82
|
+
readFileSync(join(dirNameStr, "data", "frameworks-list.json"), "utf-8"),
|
|
83
83
|
);
|
|
84
84
|
const selfPJson = JSON.parse(
|
|
85
|
-
readFileSync(join(dirNameStr, "package.json"), "utf-8")
|
|
85
|
+
readFileSync(join(dirNameStr, "package.json"), "utf-8"),
|
|
86
86
|
);
|
|
87
87
|
const _version = selfPJson.version;
|
|
88
88
|
|
|
89
89
|
// Refer to contrib/py-modules.py for a script to generate this list
|
|
90
90
|
// The script needs to be used once every few months to update this list
|
|
91
91
|
const PYTHON_STD_MODULES = JSON.parse(
|
|
92
|
-
readFileSync(join(dirNameStr, "data", "python-stdlib.json"), "utf-8")
|
|
92
|
+
readFileSync(join(dirNameStr, "data", "python-stdlib.json"), "utf-8"),
|
|
93
93
|
);
|
|
94
94
|
// Mapping between modules and package names
|
|
95
95
|
const PYPI_MODULE_PACKAGE_MAPPING = JSON.parse(
|
|
96
|
-
readFileSync(join(dirNameStr, "data", "pypi-pkg-aliases.json"), "utf-8")
|
|
96
|
+
readFileSync(join(dirNameStr, "data", "pypi-pkg-aliases.json"), "utf-8"),
|
|
97
97
|
);
|
|
98
98
|
|
|
99
99
|
// Debug mode flag
|
|
@@ -105,11 +105,11 @@ export const DEBUG_MODE =
|
|
|
105
105
|
|
|
106
106
|
// Timeout milliseconds. Default 20 mins
|
|
107
107
|
export const TIMEOUT_MS =
|
|
108
|
-
parseInt(process.env.CDXGEN_TIMEOUT_MS) || 20 * 60 * 1000;
|
|
108
|
+
Number.parseInt(process.env.CDXGEN_TIMEOUT_MS) || 20 * 60 * 1000;
|
|
109
109
|
|
|
110
110
|
// Max buffer for stdout and stderr. Defaults to 100MB
|
|
111
111
|
export const MAX_BUFFER =
|
|
112
|
-
parseInt(process.env.CDXGEN_MAX_BUFFER) || 100 * 1024 * 1024;
|
|
112
|
+
Number.parseInt(process.env.CDXGEN_MAX_BUFFER) || 100 * 1024 * 1024;
|
|
113
113
|
|
|
114
114
|
// Metadata cache
|
|
115
115
|
export let metadata_cache = {};
|
|
@@ -209,8 +209,8 @@ if (process.env.SWIFT_CMD) {
|
|
|
209
209
|
// Custom user-agent for cdxgen
|
|
210
210
|
export const cdxgenAgent = got.extend({
|
|
211
211
|
headers: {
|
|
212
|
-
"user-agent": `@CycloneDX/cdxgen ${_version}
|
|
213
|
-
}
|
|
212
|
+
"user-agent": `@CycloneDX/cdxgen ${_version}`,
|
|
213
|
+
},
|
|
214
214
|
});
|
|
215
215
|
|
|
216
216
|
/**
|
|
@@ -226,7 +226,7 @@ export function getAllFiles(dirPath, pattern, options = {}) {
|
|
|
226
226
|
"**/venv/**",
|
|
227
227
|
"**/docs/**",
|
|
228
228
|
"**/examples/**",
|
|
229
|
-
"**/site-packages/**"
|
|
229
|
+
"**/site-packages/**",
|
|
230
230
|
];
|
|
231
231
|
// Only ignore node_modules if the caller is not looking for package.json
|
|
232
232
|
if (!pattern.includes("package.json")) {
|
|
@@ -254,7 +254,7 @@ export function getAllFilesWithIgnore(dirPath, pattern, ignoreList) {
|
|
|
254
254
|
nodir: true,
|
|
255
255
|
dot: pattern.startsWith(".") ? true : false,
|
|
256
256
|
follow: false,
|
|
257
|
-
ignore: ignoreList
|
|
257
|
+
ignore: ignoreList,
|
|
258
258
|
});
|
|
259
259
|
} catch (err) {
|
|
260
260
|
if (DEBUG_MODE) {
|
|
@@ -274,6 +274,71 @@ function toBase64(hexString) {
|
|
|
274
274
|
return Buffer.from(hexString, "hex").toString("base64");
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
+
/**
|
|
278
|
+
* Return the current timestamp in YYYY-MM-DDTHH:MM:SSZ format.
|
|
279
|
+
*
|
|
280
|
+
* @returns {string} ISO formatted timestamp, without milliseconds.
|
|
281
|
+
*/
|
|
282
|
+
export function getTimestamp() {
|
|
283
|
+
return new Date().toISOString().split(".")[0] + "Z";
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Method to determine if a license is a valid SPDX license expression
|
|
288
|
+
*
|
|
289
|
+
* @param {string} license License string
|
|
290
|
+
* @returns {boolean} true if the license is a valid SPDX license expression
|
|
291
|
+
* @see https://spdx.dev/learn/handling-license-info/
|
|
292
|
+
**/
|
|
293
|
+
export function isSpdxLicenseExpression(license) {
|
|
294
|
+
if (!license) {
|
|
295
|
+
return false;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (/[(\s]+/g.test(license)) {
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (license.endsWith("+")) {
|
|
303
|
+
return true; // GPL-2.0+ means GPL-2.0 or any later version, at the licensee’s option.
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Convert the array of licenses to a CycloneDX 1.5 compliant license array.
|
|
311
|
+
* This should return an array containing:
|
|
312
|
+
* - one or more SPDX license if no expression is present
|
|
313
|
+
* - the first license expression if at least one is present
|
|
314
|
+
*
|
|
315
|
+
* @param {Array} licenses Array of licenses
|
|
316
|
+
* @returns {Array} CycloneDX 1.5 compliant license array
|
|
317
|
+
*/
|
|
318
|
+
export function adjustLicenseInformation(licenses) {
|
|
319
|
+
if (!licenses || !Array.isArray(licenses)) {
|
|
320
|
+
return [];
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const expressions = licenses.filter((f) => {
|
|
324
|
+
return f.expression;
|
|
325
|
+
});
|
|
326
|
+
if (expressions.length >= 1) {
|
|
327
|
+
if (expressions.length > 1) {
|
|
328
|
+
console.warn("multiple license expressions found", expressions);
|
|
329
|
+
}
|
|
330
|
+
return [{ expression: expressions[0].expression }];
|
|
331
|
+
} else {
|
|
332
|
+
return licenses.map((l) => {
|
|
333
|
+
if (typeof l.license === "object") {
|
|
334
|
+
return l;
|
|
335
|
+
} else {
|
|
336
|
+
return { license: l };
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
277
342
|
/**
|
|
278
343
|
* Performs a lookup + validation of the license specified in the
|
|
279
344
|
* package. If the license is a valid SPDX license ID, set the 'id'
|
|
@@ -286,8 +351,8 @@ export function getLicenses(pkg) {
|
|
|
286
351
|
if (!Array.isArray(license)) {
|
|
287
352
|
license = [license];
|
|
288
353
|
}
|
|
289
|
-
return
|
|
290
|
-
.map((l) => {
|
|
354
|
+
return adjustLicenseInformation(
|
|
355
|
+
license.map((l) => {
|
|
291
356
|
let licenseContent = {};
|
|
292
357
|
if (typeof l === "string" || l instanceof String) {
|
|
293
358
|
if (
|
|
@@ -309,6 +374,8 @@ export function getLicenses(pkg) {
|
|
|
309
374
|
licenseContent.name = "CUSTOM";
|
|
310
375
|
}
|
|
311
376
|
licenseContent.url = l;
|
|
377
|
+
} else if (isSpdxLicenseExpression(l)) {
|
|
378
|
+
licenseContent.expression = l;
|
|
312
379
|
} else {
|
|
313
380
|
licenseContent.name = l;
|
|
314
381
|
}
|
|
@@ -321,8 +388,8 @@ export function getLicenses(pkg) {
|
|
|
321
388
|
addLicenseText(pkg, l, licenseContent);
|
|
322
389
|
}
|
|
323
390
|
return licenseContent;
|
|
324
|
-
})
|
|
325
|
-
|
|
391
|
+
}),
|
|
392
|
+
);
|
|
326
393
|
} else {
|
|
327
394
|
const knownLicense = getKnownLicense(undefined, pkg);
|
|
328
395
|
if (knownLicense) {
|
|
@@ -414,26 +481,26 @@ export function addLicenseText(pkg, l, licenseContent) {
|
|
|
414
481
|
"licence",
|
|
415
482
|
"NOTICE",
|
|
416
483
|
"Notice",
|
|
417
|
-
"notice"
|
|
484
|
+
"notice",
|
|
418
485
|
];
|
|
419
486
|
const licenseContentTypes = {
|
|
420
487
|
"text/plain": "",
|
|
421
488
|
"text/txt": ".txt",
|
|
422
489
|
"text/markdown": ".md",
|
|
423
|
-
"text/xml": ".xml"
|
|
490
|
+
"text/xml": ".xml",
|
|
424
491
|
};
|
|
425
492
|
/* Loops over different name combinations starting from the license specified
|
|
426
493
|
naming (e.g., 'LICENSE.Apache-2.0') and proceeding towards more generic names. */
|
|
427
494
|
for (const licenseName of [`.${l}`, ""]) {
|
|
428
495
|
for (const licenseFilename of licenseFilenames) {
|
|
429
496
|
for (const [licenseContentType, fileExtension] of Object.entries(
|
|
430
|
-
licenseContentTypes
|
|
497
|
+
licenseContentTypes,
|
|
431
498
|
)) {
|
|
432
499
|
const licenseFilepath = `${pkg.realPath}/${licenseFilename}${licenseName}${fileExtension}`;
|
|
433
500
|
if (existsSync(licenseFilepath)) {
|
|
434
501
|
licenseContent.text = readLicenseText(
|
|
435
502
|
licenseFilepath,
|
|
436
|
-
licenseContentType
|
|
503
|
+
licenseContentType,
|
|
437
504
|
);
|
|
438
505
|
return;
|
|
439
506
|
}
|
|
@@ -472,7 +539,7 @@ export async function getSwiftPackageMetadata(pkgList) {
|
|
|
472
539
|
if (DEBUG_MODE) {
|
|
473
540
|
console.log(
|
|
474
541
|
p.repository.url,
|
|
475
|
-
"is currently not supported to fetch for licenses"
|
|
542
|
+
"is currently not supported to fetch for licenses",
|
|
476
543
|
);
|
|
477
544
|
}
|
|
478
545
|
}
|
|
@@ -509,7 +576,7 @@ export async function getNpmMetadata(pkgList) {
|
|
|
509
576
|
body = metadata_cache[key];
|
|
510
577
|
} else {
|
|
511
578
|
const res = await cdxgenAgent.get(NPM_URL + key, {
|
|
512
|
-
responseType: "json"
|
|
579
|
+
responseType: "json",
|
|
513
580
|
});
|
|
514
581
|
body = res.body;
|
|
515
582
|
metadata_cache[key] = body;
|
|
@@ -552,7 +619,7 @@ export async function parsePkgJson(pkgJsonFile, simple = false) {
|
|
|
552
619
|
const name = pkgIdentifier.fullName || pkgData.name;
|
|
553
620
|
if (DEBUG_MODE && !name && !pkgJsonFile.includes("node_modules")) {
|
|
554
621
|
console.log(
|
|
555
|
-
`${pkgJsonFile} doesn't contain the package name. Consider using the 'npm init' command to create a valid package.json file for this project
|
|
622
|
+
`${pkgJsonFile} doesn't contain the package name. Consider using the 'npm init' command to create a valid package.json file for this project.`,
|
|
556
623
|
);
|
|
557
624
|
return pkgList;
|
|
558
625
|
}
|
|
@@ -563,7 +630,7 @@ export async function parsePkgJson(pkgJsonFile, simple = false) {
|
|
|
563
630
|
name,
|
|
564
631
|
pkgData.version,
|
|
565
632
|
null,
|
|
566
|
-
null
|
|
633
|
+
null,
|
|
567
634
|
).toString();
|
|
568
635
|
const author = pkgData.author;
|
|
569
636
|
const authorString =
|
|
@@ -580,7 +647,7 @@ export async function parsePkgJson(pkgJsonFile, simple = false) {
|
|
|
580
647
|
purl: purl,
|
|
581
648
|
"bom-ref": decodeURIComponent(purl),
|
|
582
649
|
author: authorString,
|
|
583
|
-
license: pkgData.license
|
|
650
|
+
license: pkgData.license,
|
|
584
651
|
};
|
|
585
652
|
if (pkgData.homepage) {
|
|
586
653
|
apkg.homepage = { url: pkgData.homepage };
|
|
@@ -592,8 +659,8 @@ export async function parsePkgJson(pkgJsonFile, simple = false) {
|
|
|
592
659
|
apkg.properties = [
|
|
593
660
|
{
|
|
594
661
|
name: "SrcFile",
|
|
595
|
-
value: pkgJsonFile
|
|
596
|
-
}
|
|
662
|
+
value: pkgJsonFile,
|
|
663
|
+
},
|
|
597
664
|
];
|
|
598
665
|
apkg.evidence = {
|
|
599
666
|
identity: {
|
|
@@ -603,10 +670,10 @@ export async function parsePkgJson(pkgJsonFile, simple = false) {
|
|
|
603
670
|
{
|
|
604
671
|
technique: "manifest-analysis",
|
|
605
672
|
confidence: 0.7,
|
|
606
|
-
value: pkgJsonFile
|
|
607
|
-
}
|
|
608
|
-
]
|
|
609
|
-
}
|
|
673
|
+
value: pkgJsonFile,
|
|
674
|
+
},
|
|
675
|
+
],
|
|
676
|
+
},
|
|
610
677
|
};
|
|
611
678
|
}
|
|
612
679
|
pkgList.push(apkg);
|
|
@@ -617,7 +684,7 @@ export async function parsePkgJson(pkgJsonFile, simple = false) {
|
|
|
617
684
|
if (!simple && FETCH_LICENSE && pkgList && pkgList.length) {
|
|
618
685
|
if (DEBUG_MODE) {
|
|
619
686
|
console.log(
|
|
620
|
-
`About to fetch license information for ${pkgList.length} packages in parsePkgJson
|
|
687
|
+
`About to fetch license information for ${pkgList.length} packages in parsePkgJson`,
|
|
621
688
|
);
|
|
622
689
|
}
|
|
623
690
|
return await getNpmMetadata(pkgList);
|
|
@@ -641,7 +708,7 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
641
708
|
if (!existsSync(pkgLockFile)) {
|
|
642
709
|
return {
|
|
643
710
|
pkgList,
|
|
644
|
-
dependenciesList
|
|
711
|
+
dependenciesList,
|
|
645
712
|
};
|
|
646
713
|
}
|
|
647
714
|
|
|
@@ -650,7 +717,7 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
650
717
|
rootNode,
|
|
651
718
|
parentRef = null,
|
|
652
719
|
visited = new Set(),
|
|
653
|
-
options = {}
|
|
720
|
+
options = {},
|
|
654
721
|
) => {
|
|
655
722
|
if (visited.has(node)) {
|
|
656
723
|
return { pkgList: [], dependenciesList: [] };
|
|
@@ -682,7 +749,7 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
682
749
|
options.projectName || node.packageName,
|
|
683
750
|
options.projectVersion || node.version,
|
|
684
751
|
null,
|
|
685
|
-
null
|
|
752
|
+
null,
|
|
686
753
|
)
|
|
687
754
|
.toString()
|
|
688
755
|
.replace(/%2F/g, "/");
|
|
@@ -693,7 +760,7 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
693
760
|
version: options.projectVersion || node.version,
|
|
694
761
|
type: "application",
|
|
695
762
|
purl: purlString,
|
|
696
|
-
"bom-ref": decodeURIComponent(purlString)
|
|
763
|
+
"bom-ref": decodeURIComponent(purlString),
|
|
697
764
|
};
|
|
698
765
|
} else {
|
|
699
766
|
purlString = new PackageURL(
|
|
@@ -702,13 +769,13 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
702
769
|
node.packageName,
|
|
703
770
|
node.version,
|
|
704
771
|
null,
|
|
705
|
-
null
|
|
772
|
+
null,
|
|
706
773
|
)
|
|
707
774
|
.toString()
|
|
708
775
|
.replace(/%2F/g, "/");
|
|
709
776
|
const pkgLockFile = join(
|
|
710
777
|
srcFilePath.replace("/", _sep),
|
|
711
|
-
"package-lock.json"
|
|
778
|
+
"package-lock.json",
|
|
712
779
|
);
|
|
713
780
|
pkg = {
|
|
714
781
|
group: "",
|
|
@@ -720,8 +787,8 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
720
787
|
properties: [
|
|
721
788
|
{
|
|
722
789
|
name: "SrcFile",
|
|
723
|
-
value: pkgLockFile
|
|
724
|
-
}
|
|
790
|
+
value: pkgLockFile,
|
|
791
|
+
},
|
|
725
792
|
],
|
|
726
793
|
evidence: {
|
|
727
794
|
identity: {
|
|
@@ -731,25 +798,25 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
731
798
|
{
|
|
732
799
|
technique: "manifest-analysis",
|
|
733
800
|
confidence: 1,
|
|
734
|
-
value: pkgLockFile
|
|
735
|
-
}
|
|
736
|
-
]
|
|
737
|
-
}
|
|
801
|
+
value: pkgLockFile,
|
|
802
|
+
},
|
|
803
|
+
],
|
|
804
|
+
},
|
|
738
805
|
},
|
|
739
806
|
type: parentRef ? "npm" : "application",
|
|
740
807
|
purl: purlString,
|
|
741
|
-
"bom-ref": decodeURIComponent(purlString)
|
|
808
|
+
"bom-ref": decodeURIComponent(purlString),
|
|
742
809
|
};
|
|
743
810
|
if (node.resolved) {
|
|
744
811
|
pkg.properties.push({
|
|
745
812
|
name: "ResolvedUrl",
|
|
746
|
-
value: node.resolved
|
|
813
|
+
value: node.resolved,
|
|
747
814
|
});
|
|
748
815
|
}
|
|
749
816
|
if (node.location) {
|
|
750
817
|
pkg.properties.push({
|
|
751
818
|
name: "LocalNodeModulesPath",
|
|
752
|
-
value: node.location
|
|
819
|
+
value: node.location,
|
|
753
820
|
});
|
|
754
821
|
}
|
|
755
822
|
}
|
|
@@ -766,7 +833,7 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
766
833
|
for (const workspaceNode of node.fsChildren) {
|
|
767
834
|
const {
|
|
768
835
|
pkgList: childPkgList,
|
|
769
|
-
dependenciesList: childDependenciesList
|
|
836
|
+
dependenciesList: childDependenciesList,
|
|
770
837
|
} = parseArboristNode(workspaceNode, rootNode, purlString, visited);
|
|
771
838
|
pkgList = pkgList.concat(childPkgList);
|
|
772
839
|
dependenciesList = dependenciesList.concat(childDependenciesList);
|
|
@@ -777,10 +844,10 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
777
844
|
workspaceNode.name,
|
|
778
845
|
workspaceNode.version,
|
|
779
846
|
null,
|
|
780
|
-
null
|
|
847
|
+
null,
|
|
781
848
|
)
|
|
782
849
|
.toString()
|
|
783
|
-
.replace(/%2F/g, "/")
|
|
850
|
+
.replace(/%2F/g, "/"),
|
|
784
851
|
);
|
|
785
852
|
if (decodeURIComponent(purlString) !== depWorkspacePurlString) {
|
|
786
853
|
workspaceDependsOn.push(depWorkspacePurlString);
|
|
@@ -796,12 +863,12 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
796
863
|
const childNode = child[1];
|
|
797
864
|
const {
|
|
798
865
|
pkgList: childPkgList,
|
|
799
|
-
dependenciesList: childDependenciesList
|
|
866
|
+
dependenciesList: childDependenciesList,
|
|
800
867
|
} = parseArboristNode(
|
|
801
868
|
childNode,
|
|
802
869
|
rootNode,
|
|
803
870
|
decodeURIComponent(purlString),
|
|
804
|
-
visited
|
|
871
|
+
visited,
|
|
805
872
|
);
|
|
806
873
|
pkgList = pkgList.concat(childPkgList);
|
|
807
874
|
dependenciesList = dependenciesList.concat(childDependenciesList);
|
|
@@ -812,10 +879,10 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
812
879
|
childNode.name,
|
|
813
880
|
childNode.version,
|
|
814
881
|
null,
|
|
815
|
-
null
|
|
882
|
+
null,
|
|
816
883
|
)
|
|
817
884
|
.toString()
|
|
818
|
-
.replace(/%2F/g, "/")
|
|
885
|
+
.replace(/%2F/g, "/"),
|
|
819
886
|
);
|
|
820
887
|
if (decodeURIComponent(purlString) !== depChildString) {
|
|
821
888
|
childrenDependsOn.push(depChildString);
|
|
@@ -892,7 +959,7 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
892
959
|
const depPurlString = decodeURIComponent(
|
|
893
960
|
new PackageURL("npm", "", targetName, targetVersion, null, null)
|
|
894
961
|
.toString()
|
|
895
|
-
.replace(/%2F/g, "/")
|
|
962
|
+
.replace(/%2F/g, "/"),
|
|
896
963
|
);
|
|
897
964
|
if (decodeURIComponent(purlString) !== depPurlString) {
|
|
898
965
|
pkgDependsOn.push(depPurlString);
|
|
@@ -905,7 +972,7 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
905
972
|
edge.to,
|
|
906
973
|
rootNode,
|
|
907
974
|
decodeURIComponent(purlString),
|
|
908
|
-
visited
|
|
975
|
+
visited,
|
|
909
976
|
);
|
|
910
977
|
pkgList = pkgList.concat(childPkgList);
|
|
911
978
|
dependenciesList = dependenciesList.concat(childDependenciesList);
|
|
@@ -914,7 +981,7 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
914
981
|
ref: decodeURIComponent(purlString),
|
|
915
982
|
dependsOn: workspaceDependsOn
|
|
916
983
|
.concat(childrenDependsOn)
|
|
917
|
-
.concat(pkgDependsOn)
|
|
984
|
+
.concat(pkgDependsOn),
|
|
918
985
|
});
|
|
919
986
|
|
|
920
987
|
return { pkgList, dependenciesList };
|
|
@@ -923,24 +990,24 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
923
990
|
let arb = new Arborist({
|
|
924
991
|
path: path.dirname(pkgLockFile),
|
|
925
992
|
// legacyPeerDeps=false enables npm >v3 package dependency resolution
|
|
926
|
-
legacyPeerDeps: false
|
|
993
|
+
legacyPeerDeps: false,
|
|
927
994
|
});
|
|
928
995
|
let tree = undefined;
|
|
929
996
|
try {
|
|
930
997
|
tree = await arb.loadVirtual();
|
|
931
998
|
} catch (e) {
|
|
932
999
|
console.log(
|
|
933
|
-
`Unable to parse ${pkgLockFile} without legacy peer dependencies. Retrying
|
|
1000
|
+
`Unable to parse ${pkgLockFile} without legacy peer dependencies. Retrying ...`,
|
|
934
1001
|
);
|
|
935
1002
|
try {
|
|
936
1003
|
arb = new Arborist({
|
|
937
1004
|
path: path.dirname(pkgLockFile),
|
|
938
|
-
legacyPeerDeps: true
|
|
1005
|
+
legacyPeerDeps: true,
|
|
939
1006
|
});
|
|
940
1007
|
tree = await arb.loadVirtual();
|
|
941
1008
|
} catch (e) {
|
|
942
1009
|
console.log(
|
|
943
|
-
`Unable to parse ${pkgLockFile} in legacy and non-legacy mode. The resulting SBOM would be incomplete
|
|
1010
|
+
`Unable to parse ${pkgLockFile} in legacy and non-legacy mode. The resulting SBOM would be incomplete.`,
|
|
944
1011
|
);
|
|
945
1012
|
return { pkgList, dependenciesList };
|
|
946
1013
|
}
|
|
@@ -953,13 +1020,13 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
953
1020
|
tree,
|
|
954
1021
|
null,
|
|
955
1022
|
new Set(),
|
|
956
|
-
options
|
|
1023
|
+
options,
|
|
957
1024
|
));
|
|
958
1025
|
|
|
959
1026
|
if (FETCH_LICENSE && pkgList && pkgList.length) {
|
|
960
1027
|
if (DEBUG_MODE) {
|
|
961
1028
|
console.log(
|
|
962
|
-
`About to fetch license information for ${pkgList.length} packages in parsePkgLock
|
|
1029
|
+
`About to fetch license information for ${pkgList.length} packages in parsePkgLock`,
|
|
963
1030
|
);
|
|
964
1031
|
}
|
|
965
1032
|
pkgList = await getNpmMetadata(pkgList);
|
|
@@ -967,7 +1034,7 @@ export async function parsePkgLock(pkgLockFile, options = {}) {
|
|
|
967
1034
|
}
|
|
968
1035
|
return {
|
|
969
1036
|
pkgList,
|
|
970
|
-
dependenciesList
|
|
1037
|
+
dependenciesList,
|
|
971
1038
|
};
|
|
972
1039
|
}
|
|
973
1040
|
|
|
@@ -1105,7 +1172,7 @@ export async function parseYarnLock(yarnLockFile) {
|
|
|
1105
1172
|
name,
|
|
1106
1173
|
version,
|
|
1107
1174
|
null,
|
|
1108
|
-
null
|
|
1175
|
+
null,
|
|
1109
1176
|
).toString();
|
|
1110
1177
|
// Trim duplicates
|
|
1111
1178
|
if (!pkgAddedMap[purlString]) {
|
|
@@ -1120,8 +1187,8 @@ export async function parseYarnLock(yarnLockFile) {
|
|
|
1120
1187
|
properties: [
|
|
1121
1188
|
{
|
|
1122
1189
|
name: "SrcFile",
|
|
1123
|
-
value: yarnLockFile
|
|
1124
|
-
}
|
|
1190
|
+
value: yarnLockFile,
|
|
1191
|
+
},
|
|
1125
1192
|
],
|
|
1126
1193
|
evidence: {
|
|
1127
1194
|
identity: {
|
|
@@ -1131,11 +1198,11 @@ export async function parseYarnLock(yarnLockFile) {
|
|
|
1131
1198
|
{
|
|
1132
1199
|
technique: "manifest-analysis",
|
|
1133
1200
|
confidence: 1,
|
|
1134
|
-
value: yarnLockFile
|
|
1135
|
-
}
|
|
1136
|
-
]
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1201
|
+
value: yarnLockFile,
|
|
1202
|
+
},
|
|
1203
|
+
],
|
|
1204
|
+
},
|
|
1205
|
+
},
|
|
1139
1206
|
});
|
|
1140
1207
|
}
|
|
1141
1208
|
}
|
|
@@ -1150,7 +1217,7 @@ export async function parseYarnLock(yarnLockFile) {
|
|
|
1150
1217
|
// Create an entry for dependencies
|
|
1151
1218
|
dependenciesList.push({
|
|
1152
1219
|
ref: decodeURIComponent(purlString),
|
|
1153
|
-
dependsOn: deplist
|
|
1220
|
+
dependsOn: deplist,
|
|
1154
1221
|
});
|
|
1155
1222
|
depKeys[purlString] = true;
|
|
1156
1223
|
deplist = [];
|
|
@@ -1179,7 +1246,7 @@ export async function parseYarnLock(yarnLockFile) {
|
|
|
1179
1246
|
) {
|
|
1180
1247
|
name_aliases.push({
|
|
1181
1248
|
group: parsedline.group,
|
|
1182
|
-
name: parsedline.name
|
|
1249
|
+
name: parsedline.name,
|
|
1183
1250
|
});
|
|
1184
1251
|
}
|
|
1185
1252
|
}
|
|
@@ -1207,7 +1274,7 @@ export async function parseYarnLock(yarnLockFile) {
|
|
|
1207
1274
|
dgroupname,
|
|
1208
1275
|
resolvedVersion,
|
|
1209
1276
|
null,
|
|
1210
|
-
null
|
|
1277
|
+
null,
|
|
1211
1278
|
).toString();
|
|
1212
1279
|
deplist.push(decodeURIComponent(depPurlString));
|
|
1213
1280
|
}
|
|
@@ -1244,18 +1311,18 @@ export async function parseYarnLock(yarnLockFile) {
|
|
|
1244
1311
|
if (FETCH_LICENSE && pkgList && pkgList.length) {
|
|
1245
1312
|
if (DEBUG_MODE) {
|
|
1246
1313
|
console.log(
|
|
1247
|
-
`About to fetch license information for ${pkgList.length} packages in parseYarnLock
|
|
1314
|
+
`About to fetch license information for ${pkgList.length} packages in parseYarnLock`,
|
|
1248
1315
|
);
|
|
1249
1316
|
}
|
|
1250
1317
|
pkgList = await getNpmMetadata(pkgList);
|
|
1251
1318
|
return {
|
|
1252
1319
|
pkgList,
|
|
1253
|
-
dependenciesList
|
|
1320
|
+
dependenciesList,
|
|
1254
1321
|
};
|
|
1255
1322
|
}
|
|
1256
1323
|
return {
|
|
1257
1324
|
pkgList,
|
|
1258
|
-
dependenciesList
|
|
1325
|
+
dependenciesList,
|
|
1259
1326
|
};
|
|
1260
1327
|
}
|
|
1261
1328
|
|
|
@@ -1298,8 +1365,8 @@ export async function parseNodeShrinkwrap(swFile) {
|
|
|
1298
1365
|
properties: [
|
|
1299
1366
|
{
|
|
1300
1367
|
name: "SrcFile",
|
|
1301
|
-
value: swFile
|
|
1302
|
-
}
|
|
1368
|
+
value: swFile,
|
|
1369
|
+
},
|
|
1303
1370
|
],
|
|
1304
1371
|
evidence: {
|
|
1305
1372
|
identity: {
|
|
@@ -1309,11 +1376,11 @@ export async function parseNodeShrinkwrap(swFile) {
|
|
|
1309
1376
|
{
|
|
1310
1377
|
technique: "manifest-analysis",
|
|
1311
1378
|
confidence: 1,
|
|
1312
|
-
value: swFile
|
|
1313
|
-
}
|
|
1314
|
-
]
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1379
|
+
value: swFile,
|
|
1380
|
+
},
|
|
1381
|
+
],
|
|
1382
|
+
},
|
|
1383
|
+
},
|
|
1317
1384
|
});
|
|
1318
1385
|
}
|
|
1319
1386
|
}
|
|
@@ -1321,7 +1388,7 @@ export async function parseNodeShrinkwrap(swFile) {
|
|
|
1321
1388
|
if (FETCH_LICENSE && pkgList && pkgList.length) {
|
|
1322
1389
|
if (DEBUG_MODE) {
|
|
1323
1390
|
console.log(
|
|
1324
|
-
`About to fetch license information for ${pkgList.length} packages in parseNodeShrinkwrap
|
|
1391
|
+
`About to fetch license information for ${pkgList.length} packages in parseNodeShrinkwrap`,
|
|
1325
1392
|
);
|
|
1326
1393
|
}
|
|
1327
1394
|
return await getNpmMetadata(pkgList);
|
|
@@ -1348,7 +1415,7 @@ export async function parsePnpmLock(pnpmLock, parentComponent = null) {
|
|
|
1348
1415
|
parentComponent.name,
|
|
1349
1416
|
parentComponent.version,
|
|
1350
1417
|
null,
|
|
1351
|
-
null
|
|
1418
|
+
null,
|
|
1352
1419
|
).toString();
|
|
1353
1420
|
}
|
|
1354
1421
|
if (existsSync(pnpmLock)) {
|
|
@@ -1375,18 +1442,18 @@ export async function parsePnpmLock(pnpmLock, parentComponent = null) {
|
|
|
1375
1442
|
dk,
|
|
1376
1443
|
version,
|
|
1377
1444
|
null,
|
|
1378
|
-
null
|
|
1445
|
+
null,
|
|
1379
1446
|
).toString();
|
|
1380
1447
|
ddeplist.push(decodeURIComponent(dpurl));
|
|
1381
1448
|
}
|
|
1382
1449
|
dependenciesList.push({
|
|
1383
1450
|
ref: decodeURIComponent(ppurl),
|
|
1384
|
-
dependsOn: ddeplist
|
|
1451
|
+
dependsOn: ddeplist,
|
|
1385
1452
|
});
|
|
1386
1453
|
}
|
|
1387
1454
|
let lockfileVersion = yamlObj.lockfileVersion;
|
|
1388
1455
|
try {
|
|
1389
|
-
lockfileVersion = parseInt(lockfileVersion, 10);
|
|
1456
|
+
lockfileVersion = Number.parseInt(lockfileVersion, 10);
|
|
1390
1457
|
} catch (e) {
|
|
1391
1458
|
// ignore parse errors
|
|
1392
1459
|
}
|
|
@@ -1430,7 +1497,7 @@ export async function parsePnpmLock(pnpmLock, parentComponent = null) {
|
|
|
1430
1497
|
// Let's have some warnings till we fully support pnpm 8
|
|
1431
1498
|
if (!name) {
|
|
1432
1499
|
console.warn(
|
|
1433
|
-
`Unable to extract name and version for string ${pkgKeys[k]}
|
|
1500
|
+
`Unable to extract name and version for string ${pkgKeys[k]}`,
|
|
1434
1501
|
);
|
|
1435
1502
|
continue;
|
|
1436
1503
|
}
|
|
@@ -1441,7 +1508,7 @@ export async function parsePnpmLock(pnpmLock, parentComponent = null) {
|
|
|
1441
1508
|
name,
|
|
1442
1509
|
version,
|
|
1443
1510
|
null,
|
|
1444
|
-
null
|
|
1511
|
+
null,
|
|
1445
1512
|
).toString();
|
|
1446
1513
|
const deplist = [];
|
|
1447
1514
|
for (const dpkgName of Object.keys(deps)) {
|
|
@@ -1451,13 +1518,13 @@ export async function parsePnpmLock(pnpmLock, parentComponent = null) {
|
|
|
1451
1518
|
dpkgName,
|
|
1452
1519
|
deps[dpkgName],
|
|
1453
1520
|
null,
|
|
1454
|
-
null
|
|
1521
|
+
null,
|
|
1455
1522
|
).toString();
|
|
1456
1523
|
deplist.push(decodeURIComponent(dpurlString));
|
|
1457
1524
|
}
|
|
1458
1525
|
dependenciesList.push({
|
|
1459
1526
|
ref: decodeURIComponent(purlString),
|
|
1460
|
-
dependsOn: deplist
|
|
1527
|
+
dependsOn: deplist,
|
|
1461
1528
|
});
|
|
1462
1529
|
pkgList.push({
|
|
1463
1530
|
group: group,
|
|
@@ -1470,8 +1537,8 @@ export async function parsePnpmLock(pnpmLock, parentComponent = null) {
|
|
|
1470
1537
|
properties: [
|
|
1471
1538
|
{
|
|
1472
1539
|
name: "SrcFile",
|
|
1473
|
-
value: pnpmLock
|
|
1474
|
-
}
|
|
1540
|
+
value: pnpmLock,
|
|
1541
|
+
},
|
|
1475
1542
|
],
|
|
1476
1543
|
evidence: {
|
|
1477
1544
|
identity: {
|
|
@@ -1481,11 +1548,11 @@ export async function parsePnpmLock(pnpmLock, parentComponent = null) {
|
|
|
1481
1548
|
{
|
|
1482
1549
|
technique: "manifest-analysis",
|
|
1483
1550
|
confidence: 1,
|
|
1484
|
-
value: pnpmLock
|
|
1485
|
-
}
|
|
1486
|
-
]
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1551
|
+
value: pnpmLock,
|
|
1552
|
+
},
|
|
1553
|
+
],
|
|
1554
|
+
},
|
|
1555
|
+
},
|
|
1489
1556
|
});
|
|
1490
1557
|
}
|
|
1491
1558
|
}
|
|
@@ -1494,18 +1561,18 @@ export async function parsePnpmLock(pnpmLock, parentComponent = null) {
|
|
|
1494
1561
|
if (FETCH_LICENSE && pkgList && pkgList.length) {
|
|
1495
1562
|
if (DEBUG_MODE) {
|
|
1496
1563
|
console.log(
|
|
1497
|
-
`About to fetch license information for ${pkgList.length} packages in parsePnpmLock
|
|
1564
|
+
`About to fetch license information for ${pkgList.length} packages in parsePnpmLock`,
|
|
1498
1565
|
);
|
|
1499
1566
|
}
|
|
1500
1567
|
pkgList = await getNpmMetadata(pkgList);
|
|
1501
1568
|
return {
|
|
1502
1569
|
pkgList,
|
|
1503
|
-
dependenciesList
|
|
1570
|
+
dependenciesList,
|
|
1504
1571
|
};
|
|
1505
1572
|
}
|
|
1506
1573
|
return {
|
|
1507
1574
|
pkgList,
|
|
1508
|
-
dependenciesList
|
|
1575
|
+
dependenciesList,
|
|
1509
1576
|
};
|
|
1510
1577
|
}
|
|
1511
1578
|
|
|
@@ -1529,8 +1596,8 @@ export async function parseBowerJson(bowerJsonFile) {
|
|
|
1529
1596
|
properties: [
|
|
1530
1597
|
{
|
|
1531
1598
|
name: "SrcFile",
|
|
1532
|
-
value: bowerJsonFile
|
|
1533
|
-
}
|
|
1599
|
+
value: bowerJsonFile,
|
|
1600
|
+
},
|
|
1534
1601
|
],
|
|
1535
1602
|
evidence: {
|
|
1536
1603
|
identity: {
|
|
@@ -1540,11 +1607,11 @@ export async function parseBowerJson(bowerJsonFile) {
|
|
|
1540
1607
|
{
|
|
1541
1608
|
technique: "manifest-analysis",
|
|
1542
1609
|
confidence: 1,
|
|
1543
|
-
value: bowerJsonFile
|
|
1544
|
-
}
|
|
1545
|
-
]
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1610
|
+
value: bowerJsonFile,
|
|
1611
|
+
},
|
|
1612
|
+
],
|
|
1613
|
+
},
|
|
1614
|
+
},
|
|
1548
1615
|
});
|
|
1549
1616
|
} catch (err) {
|
|
1550
1617
|
// continue regardless of error
|
|
@@ -1553,7 +1620,7 @@ export async function parseBowerJson(bowerJsonFile) {
|
|
|
1553
1620
|
if (FETCH_LICENSE && pkgList && pkgList.length) {
|
|
1554
1621
|
if (DEBUG_MODE) {
|
|
1555
1622
|
console.log(
|
|
1556
|
-
`About to fetch license information for ${pkgList.length} packages in parseBowerJson
|
|
1623
|
+
`About to fetch license information for ${pkgList.length} packages in parseBowerJson`,
|
|
1557
1624
|
);
|
|
1558
1625
|
}
|
|
1559
1626
|
return await getNpmMetadata(pkgList);
|
|
@@ -1610,8 +1677,8 @@ export async function parseMinJs(minJsFile) {
|
|
|
1610
1677
|
properties: [
|
|
1611
1678
|
{
|
|
1612
1679
|
name: "SrcFile",
|
|
1613
|
-
value: minJsFile
|
|
1614
|
-
}
|
|
1680
|
+
value: minJsFile,
|
|
1681
|
+
},
|
|
1615
1682
|
],
|
|
1616
1683
|
evidence: {
|
|
1617
1684
|
identity: {
|
|
@@ -1621,11 +1688,11 @@ export async function parseMinJs(minJsFile) {
|
|
|
1621
1688
|
{
|
|
1622
1689
|
technique: "filename",
|
|
1623
1690
|
confidence: 0.25,
|
|
1624
|
-
value: minJsFile
|
|
1625
|
-
}
|
|
1626
|
-
]
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1691
|
+
value: minJsFile,
|
|
1692
|
+
},
|
|
1693
|
+
],
|
|
1694
|
+
},
|
|
1695
|
+
},
|
|
1629
1696
|
});
|
|
1630
1697
|
}
|
|
1631
1698
|
}
|
|
@@ -1638,7 +1705,7 @@ export async function parseMinJs(minJsFile) {
|
|
|
1638
1705
|
if (FETCH_LICENSE && pkgList && pkgList.length) {
|
|
1639
1706
|
if (DEBUG_MODE) {
|
|
1640
1707
|
console.log(
|
|
1641
|
-
`About to fetch license information for ${pkgList.length} packages in parseMinJs
|
|
1708
|
+
`About to fetch license information for ${pkgList.length} packages in parseMinJs`,
|
|
1642
1709
|
);
|
|
1643
1710
|
}
|
|
1644
1711
|
return await getNpmMetadata(pkgList);
|
|
@@ -1659,7 +1726,7 @@ export function parsePom(pomFile) {
|
|
|
1659
1726
|
spaces: 4,
|
|
1660
1727
|
textKey: "_",
|
|
1661
1728
|
attributesKey: "$",
|
|
1662
|
-
commentKey: "value"
|
|
1729
|
+
commentKey: "value",
|
|
1663
1730
|
}).project;
|
|
1664
1731
|
if (project && project.dependencies) {
|
|
1665
1732
|
let dependencies = project.dependencies.dependency;
|
|
@@ -1683,8 +1750,8 @@ export function parsePom(pomFile) {
|
|
|
1683
1750
|
properties: [
|
|
1684
1751
|
{
|
|
1685
1752
|
name: "SrcFile",
|
|
1686
|
-
value: pomFile
|
|
1687
|
-
}
|
|
1753
|
+
value: pomFile,
|
|
1754
|
+
},
|
|
1688
1755
|
],
|
|
1689
1756
|
evidence: {
|
|
1690
1757
|
identity: {
|
|
@@ -1694,11 +1761,11 @@ export function parsePom(pomFile) {
|
|
|
1694
1761
|
{
|
|
1695
1762
|
technique: "manifest-analysis",
|
|
1696
1763
|
confidence: 1,
|
|
1697
|
-
value: pomFile
|
|
1698
|
-
}
|
|
1699
|
-
]
|
|
1700
|
-
}
|
|
1701
|
-
}
|
|
1764
|
+
value: pomFile,
|
|
1765
|
+
},
|
|
1766
|
+
],
|
|
1767
|
+
},
|
|
1768
|
+
},
|
|
1702
1769
|
});
|
|
1703
1770
|
}
|
|
1704
1771
|
}
|
|
@@ -1749,14 +1816,14 @@ export function parseMavenTree(rawOutput) {
|
|
|
1749
1816
|
pkgArr[1],
|
|
1750
1817
|
versionStr,
|
|
1751
1818
|
{ type: pkgArr[2] },
|
|
1752
|
-
null
|
|
1819
|
+
null,
|
|
1753
1820
|
).toString();
|
|
1754
1821
|
purlString = decodeURIComponent(purlString);
|
|
1755
1822
|
deps.push({
|
|
1756
1823
|
group: pkgArr[0],
|
|
1757
1824
|
name: pkgArr[1],
|
|
1758
1825
|
version: versionStr,
|
|
1759
|
-
qualifiers: { type: pkgArr[2] }
|
|
1826
|
+
qualifiers: { type: pkgArr[2] },
|
|
1760
1827
|
});
|
|
1761
1828
|
if (!level_trees[purlString]) {
|
|
1762
1829
|
level_trees[purlString] = [];
|
|
@@ -1789,12 +1856,12 @@ export function parseMavenTree(rawOutput) {
|
|
|
1789
1856
|
for (const lk of Object.keys(level_trees)) {
|
|
1790
1857
|
dependenciesList.push({
|
|
1791
1858
|
ref: lk,
|
|
1792
|
-
dependsOn: level_trees[lk]
|
|
1859
|
+
dependsOn: level_trees[lk],
|
|
1793
1860
|
});
|
|
1794
1861
|
}
|
|
1795
1862
|
return {
|
|
1796
1863
|
pkgList: deps,
|
|
1797
|
-
dependenciesList
|
|
1864
|
+
dependenciesList,
|
|
1798
1865
|
};
|
|
1799
1866
|
}
|
|
1800
1867
|
|
|
@@ -1809,7 +1876,7 @@ export function parseGradleDep(
|
|
|
1809
1876
|
rawOutput,
|
|
1810
1877
|
rootProjectGroup = "",
|
|
1811
1878
|
rootProjectName = "root",
|
|
1812
|
-
rootProjectVersion = "latest"
|
|
1879
|
+
rootProjectVersion = "latest",
|
|
1813
1880
|
) {
|
|
1814
1881
|
if (typeof rawOutput === "string") {
|
|
1815
1882
|
// Bug: 249. Get any sub-projects refered here
|
|
@@ -1831,7 +1898,7 @@ export function parseGradleDep(
|
|
|
1831
1898
|
name: rootProjectName,
|
|
1832
1899
|
version: rootProjectVersion,
|
|
1833
1900
|
type: "maven",
|
|
1834
|
-
qualifiers: { type: "jar" }
|
|
1901
|
+
qualifiers: { type: "jar" },
|
|
1835
1902
|
};
|
|
1836
1903
|
const deps = [];
|
|
1837
1904
|
const dependenciesList = [];
|
|
@@ -1845,8 +1912,8 @@ export function parseGradleDep(
|
|
|
1845
1912
|
rootProject.name,
|
|
1846
1913
|
rootProject.version,
|
|
1847
1914
|
rootProject.qualifiers,
|
|
1848
|
-
null
|
|
1849
|
-
).toString()
|
|
1915
|
+
null,
|
|
1916
|
+
).toString(),
|
|
1850
1917
|
);
|
|
1851
1918
|
const first_purl = last_purl;
|
|
1852
1919
|
let last_project_purl = first_purl;
|
|
@@ -1865,9 +1932,9 @@ export function parseGradleDep(
|
|
|
1865
1932
|
sd.replace(":", ""),
|
|
1866
1933
|
rootProject.version,
|
|
1867
1934
|
rootProject.qualifiers,
|
|
1868
|
-
null
|
|
1869
|
-
).toString()
|
|
1870
|
-
)
|
|
1935
|
+
null,
|
|
1936
|
+
).toString(),
|
|
1937
|
+
),
|
|
1871
1938
|
);
|
|
1872
1939
|
}
|
|
1873
1940
|
level_trees[last_purl] = subDependsOn;
|
|
@@ -1915,7 +1982,7 @@ export function parseGradleDep(
|
|
|
1915
1982
|
versionspecified,
|
|
1916
1983
|
groupoverride,
|
|
1917
1984
|
nameoverride,
|
|
1918
|
-
versionoverride
|
|
1985
|
+
versionoverride,
|
|
1919
1986
|
] = match;
|
|
1920
1987
|
let group = groupoverride || groupspecified;
|
|
1921
1988
|
let name = nameoverride || namespecified;
|
|
@@ -1938,7 +2005,7 @@ export function parseGradleDep(
|
|
|
1938
2005
|
name,
|
|
1939
2006
|
version !== undefined ? version : rootProjectVersion,
|
|
1940
2007
|
{ type: "jar" },
|
|
1941
|
-
null
|
|
2008
|
+
null,
|
|
1942
2009
|
).toString();
|
|
1943
2010
|
purlString = decodeURIComponent(purlString);
|
|
1944
2011
|
keys_cache[purlString + "_" + last_purl] = true;
|
|
@@ -1949,7 +2016,7 @@ export function parseGradleDep(
|
|
|
1949
2016
|
group: group !== "project" ? group : rootProjectGroup,
|
|
1950
2017
|
name: name,
|
|
1951
2018
|
version: version !== undefined ? version : rootProjectVersion,
|
|
1952
|
-
qualifiers: { type: "jar" }
|
|
2019
|
+
qualifiers: { type: "jar" },
|
|
1953
2020
|
};
|
|
1954
2021
|
adep["purl"] = purlString;
|
|
1955
2022
|
adep["bom-ref"] = decodeURIComponent(purlString);
|
|
@@ -1960,8 +2027,8 @@ export function parseGradleDep(
|
|
|
1960
2027
|
adep.properties = [
|
|
1961
2028
|
{
|
|
1962
2029
|
name: "GradleProfileName",
|
|
1963
|
-
value: profileName
|
|
1964
|
-
}
|
|
2030
|
+
value: profileName,
|
|
2031
|
+
},
|
|
1965
2032
|
];
|
|
1966
2033
|
}
|
|
1967
2034
|
deps.push(adep);
|
|
@@ -2004,12 +2071,12 @@ export function parseGradleDep(
|
|
|
2004
2071
|
for (const lk of Object.keys(level_trees)) {
|
|
2005
2072
|
dependenciesList.push({
|
|
2006
2073
|
ref: lk,
|
|
2007
|
-
dependsOn: level_trees[lk]
|
|
2074
|
+
dependsOn: level_trees[lk],
|
|
2008
2075
|
});
|
|
2009
2076
|
}
|
|
2010
2077
|
return {
|
|
2011
2078
|
pkgList: deps,
|
|
2012
|
-
dependenciesList
|
|
2079
|
+
dependenciesList,
|
|
2013
2080
|
};
|
|
2014
2081
|
}
|
|
2015
2082
|
return {};
|
|
@@ -2044,7 +2111,7 @@ export function parseCljDep(rawOutput) {
|
|
|
2044
2111
|
deps.push({
|
|
2045
2112
|
group,
|
|
2046
2113
|
name,
|
|
2047
|
-
version
|
|
2114
|
+
version,
|
|
2048
2115
|
});
|
|
2049
2116
|
}
|
|
2050
2117
|
}
|
|
@@ -2144,7 +2211,7 @@ export function parseGradleProjects(rawOutput) {
|
|
|
2144
2211
|
}
|
|
2145
2212
|
return {
|
|
2146
2213
|
rootProject,
|
|
2147
|
-
projects: Array.from(projects)
|
|
2214
|
+
projects: Array.from(projects),
|
|
2148
2215
|
};
|
|
2149
2216
|
}
|
|
2150
2217
|
|
|
@@ -2187,7 +2254,7 @@ export function parseGradleProperties(rawOutput) {
|
|
|
2187
2254
|
return {
|
|
2188
2255
|
rootProject,
|
|
2189
2256
|
projects: Array.from(projects),
|
|
2190
|
-
metadata
|
|
2257
|
+
metadata,
|
|
2191
2258
|
};
|
|
2192
2259
|
}
|
|
2193
2260
|
|
|
@@ -2203,8 +2270,8 @@ export function executeGradleProperties(dir, rootPath, subProject) {
|
|
|
2203
2270
|
rootProject: subProject,
|
|
2204
2271
|
projects: [],
|
|
2205
2272
|
metadata: {
|
|
2206
|
-
version: "latest"
|
|
2207
|
-
}
|
|
2273
|
+
version: "latest",
|
|
2274
|
+
},
|
|
2208
2275
|
};
|
|
2209
2276
|
// To optimize performance and reduce errors do not query for properties
|
|
2210
2277
|
// beyond the first level
|
|
@@ -2216,7 +2283,7 @@ export function executeGradleProperties(dir, rootPath, subProject) {
|
|
|
2216
2283
|
"-q",
|
|
2217
2284
|
"--console",
|
|
2218
2285
|
"plain",
|
|
2219
|
-
"--build-cache"
|
|
2286
|
+
"--build-cache",
|
|
2220
2287
|
];
|
|
2221
2288
|
const gradleCmd = getGradleCommand(dir, rootPath);
|
|
2222
2289
|
// common gradle args, used for all tasks
|
|
@@ -2234,12 +2301,12 @@ export function executeGradleProperties(dir, rootPath, subProject) {
|
|
|
2234
2301
|
gradleCmd,
|
|
2235
2302
|
gradlePropertiesArgs.join(" "),
|
|
2236
2303
|
"in",
|
|
2237
|
-
dir
|
|
2304
|
+
dir,
|
|
2238
2305
|
);
|
|
2239
2306
|
const result = spawnSync(gradleCmd, gradlePropertiesArgs, {
|
|
2240
2307
|
cwd: dir,
|
|
2241
2308
|
encoding: "utf-8",
|
|
2242
|
-
shell: isWin
|
|
2309
|
+
shell: isWin,
|
|
2243
2310
|
});
|
|
2244
2311
|
if (result.status !== 0 || result.error) {
|
|
2245
2312
|
if (result.stderr) {
|
|
@@ -2248,12 +2315,12 @@ export function executeGradleProperties(dir, rootPath, subProject) {
|
|
|
2248
2315
|
} else {
|
|
2249
2316
|
console.error(result.stdout, result.stderr);
|
|
2250
2317
|
console.log(
|
|
2251
|
-
"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 21 with gradle 8 which might be incompatible."
|
|
2318
|
+
"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 21 with gradle 8 which might be incompatible.",
|
|
2252
2319
|
);
|
|
2253
2320
|
}
|
|
2254
2321
|
if (result.stderr.includes("not get unknown property")) {
|
|
2255
2322
|
console.log(
|
|
2256
|
-
"2. Check if the SBOM is generated for the correct root project for your application."
|
|
2323
|
+
"2. Check if the SBOM is generated for the correct root project for your application.",
|
|
2257
2324
|
);
|
|
2258
2325
|
}
|
|
2259
2326
|
}
|
|
@@ -2275,7 +2342,7 @@ export function parseBazelActionGraph(rawOutput) {
|
|
|
2275
2342
|
`^.*v1/https/[^/]*(?:${
|
|
2276
2343
|
process.env.BAZEL_STRIP_MAVEN_PREFIX || "/maven2/"
|
|
2277
2344
|
})?(.*)/(.*)/(.*)/(.*.jar)(?:"| \\\\)?$`,
|
|
2278
|
-
"g"
|
|
2345
|
+
"g",
|
|
2279
2346
|
);
|
|
2280
2347
|
|
|
2281
2348
|
if (typeof rawOutput === "string") {
|
|
@@ -2303,7 +2370,7 @@ export function parseBazelActionGraph(rawOutput) {
|
|
|
2303
2370
|
group,
|
|
2304
2371
|
name,
|
|
2305
2372
|
version,
|
|
2306
|
-
qualifiers: { type: "jar" }
|
|
2373
|
+
qualifiers: { type: "jar" },
|
|
2307
2374
|
});
|
|
2308
2375
|
}
|
|
2309
2376
|
}
|
|
@@ -2360,7 +2427,7 @@ export function parseBazelSkyframe(rawOutput) {
|
|
|
2360
2427
|
group,
|
|
2361
2428
|
name,
|
|
2362
2429
|
version,
|
|
2363
|
-
qualifiers: { type: "jar" }
|
|
2430
|
+
qualifiers: { type: "jar" },
|
|
2364
2431
|
});
|
|
2365
2432
|
}
|
|
2366
2433
|
}
|
|
@@ -2419,14 +2486,14 @@ export function parseKVDep(rawOutput) {
|
|
|
2419
2486
|
name,
|
|
2420
2487
|
version,
|
|
2421
2488
|
{ type: "jar" },
|
|
2422
|
-
null
|
|
2489
|
+
null,
|
|
2423
2490
|
).toString();
|
|
2424
2491
|
deps.push({
|
|
2425
2492
|
group,
|
|
2426
2493
|
name,
|
|
2427
2494
|
version,
|
|
2428
2495
|
purl: purlString,
|
|
2429
|
-
"bom-ref": decodeURIComponent(purlString)
|
|
2496
|
+
"bom-ref": decodeURIComponent(purlString),
|
|
2430
2497
|
});
|
|
2431
2498
|
});
|
|
2432
2499
|
return deps;
|
|
@@ -2500,10 +2567,10 @@ export async function getMvnMetadata(pkgList, jarNSMapping = {}) {
|
|
|
2500
2567
|
{
|
|
2501
2568
|
technique: "binary-analysis",
|
|
2502
2569
|
confidence: 0.8,
|
|
2503
|
-
value: jarNSMapping[p.purl].jarFile
|
|
2504
|
-
}
|
|
2505
|
-
]
|
|
2506
|
-
}
|
|
2570
|
+
value: jarNSMapping[p.purl].jarFile,
|
|
2571
|
+
},
|
|
2572
|
+
],
|
|
2573
|
+
},
|
|
2507
2574
|
};
|
|
2508
2575
|
}
|
|
2509
2576
|
if (
|
|
@@ -2515,7 +2582,7 @@ export async function getMvnMetadata(pkgList, jarNSMapping = {}) {
|
|
|
2515
2582
|
}
|
|
2516
2583
|
p.properties.push({
|
|
2517
2584
|
name: "Namespaces",
|
|
2518
|
-
value: jarNSMapping[p.purl].namespaces.join("\n")
|
|
2585
|
+
value: jarNSMapping[p.purl].namespaces.join("\n"),
|
|
2519
2586
|
});
|
|
2520
2587
|
}
|
|
2521
2588
|
}
|
|
@@ -2539,12 +2606,12 @@ export async function getMvnMetadata(pkgList, jarNSMapping = {}) {
|
|
|
2539
2606
|
urlPrefix: urlPrefix,
|
|
2540
2607
|
group: group,
|
|
2541
2608
|
name: p.name,
|
|
2542
|
-
version: p.version
|
|
2609
|
+
version: p.version,
|
|
2543
2610
|
};
|
|
2544
2611
|
try {
|
|
2545
2612
|
if (DEBUG_MODE) {
|
|
2546
2613
|
console.log(
|
|
2547
|
-
`Querying ${pomMetadata} from ${composePomXmlUrl(pomMetadata)}
|
|
2614
|
+
`Querying ${pomMetadata} from ${composePomXmlUrl(pomMetadata)}`,
|
|
2548
2615
|
);
|
|
2549
2616
|
}
|
|
2550
2617
|
const bodyJson = await fetchPomXmlAsJson(pomMetadata);
|
|
@@ -2564,7 +2631,7 @@ export async function getMvnMetadata(pkgList, jarNSMapping = {}) {
|
|
|
2564
2631
|
if (DEBUG_MODE) {
|
|
2565
2632
|
console.log(
|
|
2566
2633
|
`An error occurred when trying to fetch metadata ${pomMetadata}`,
|
|
2567
|
-
err
|
|
2634
|
+
err,
|
|
2568
2635
|
);
|
|
2569
2636
|
}
|
|
2570
2637
|
} finally {
|
|
@@ -2618,7 +2685,7 @@ export async function fetchPomXmlAsJson({ urlPrefix, group, name, version }) {
|
|
|
2618
2685
|
spaces: 4,
|
|
2619
2686
|
textKey: "_",
|
|
2620
2687
|
attributesKey: "$",
|
|
2621
|
-
commentKey: "value"
|
|
2688
|
+
commentKey: "value",
|
|
2622
2689
|
};
|
|
2623
2690
|
const pomJson = xml2js(pomXml, options).project;
|
|
2624
2691
|
if (pomJson?.parent) {
|
|
@@ -2626,7 +2693,7 @@ export async function fetchPomXmlAsJson({ urlPrefix, group, name, version }) {
|
|
|
2626
2693
|
urlPrefix,
|
|
2627
2694
|
group: pomJson.parent.groupId?._,
|
|
2628
2695
|
name: pomJson.parent.artifactId?._,
|
|
2629
|
-
version: pomJson.parent.version?._
|
|
2696
|
+
version: pomJson.parent.version?._,
|
|
2630
2697
|
});
|
|
2631
2698
|
const parentJson = xml2js(parentXml, options).project;
|
|
2632
2699
|
const result = { ...parentJson, ...pomJson };
|
|
@@ -2681,7 +2748,7 @@ export async function extractLicenseCommentFromPomXml({
|
|
|
2681
2748
|
urlPrefix,
|
|
2682
2749
|
group,
|
|
2683
2750
|
name,
|
|
2684
|
-
version
|
|
2751
|
+
version,
|
|
2685
2752
|
}) {
|
|
2686
2753
|
const pom_xml = await fetchPomXml({ urlPrefix, group, name, version });
|
|
2687
2754
|
const licenseRegex = /<!--([\s\S]*?)-->[\s\n]*<project/m;
|
|
@@ -2714,7 +2781,7 @@ export function parsePyRequiresDist(dist_string) {
|
|
|
2714
2781
|
}
|
|
2715
2782
|
return {
|
|
2716
2783
|
name,
|
|
2717
|
-
version
|
|
2784
|
+
version,
|
|
2718
2785
|
};
|
|
2719
2786
|
}
|
|
2720
2787
|
|
|
@@ -2774,12 +2841,12 @@ export async function getPyMetadata(pkgList, fetchDepsInfo) {
|
|
|
2774
2841
|
let res = undefined;
|
|
2775
2842
|
try {
|
|
2776
2843
|
res = await cdxgenAgent.get(PYPI_URL + p.name + "/json", {
|
|
2777
|
-
responseType: "json"
|
|
2844
|
+
responseType: "json",
|
|
2778
2845
|
});
|
|
2779
2846
|
} catch (err) {
|
|
2780
2847
|
// retry by prefixing django- to the package name
|
|
2781
2848
|
res = await cdxgenAgent.get(PYPI_URL + "django-" + p.name + "/json", {
|
|
2782
|
-
responseType: "json"
|
|
2849
|
+
responseType: "json",
|
|
2783
2850
|
});
|
|
2784
2851
|
p.name = "django-" + p.name;
|
|
2785
2852
|
}
|
|
@@ -2844,7 +2911,7 @@ export async function getPyMetadata(pkgList, fetchDepsInfo) {
|
|
|
2844
2911
|
if (versionSpecifiers) {
|
|
2845
2912
|
p.version = guessPypiMatchingVersion(
|
|
2846
2913
|
Object.keys(body.releases || {}),
|
|
2847
|
-
versionSpecifiers
|
|
2914
|
+
versionSpecifiers,
|
|
2848
2915
|
);
|
|
2849
2916
|
// Indicate the confidence with our guess
|
|
2850
2917
|
p.evidence = {
|
|
@@ -2855,10 +2922,10 @@ export async function getPyMetadata(pkgList, fetchDepsInfo) {
|
|
|
2855
2922
|
{
|
|
2856
2923
|
technique: "manifest-analysis",
|
|
2857
2924
|
confidence: 0.75,
|
|
2858
|
-
value: `Version specifiers: ${versionSpecifiers}
|
|
2859
|
-
}
|
|
2860
|
-
]
|
|
2861
|
-
}
|
|
2925
|
+
value: `Version specifiers: ${versionSpecifiers}`,
|
|
2926
|
+
},
|
|
2927
|
+
],
|
|
2928
|
+
},
|
|
2862
2929
|
};
|
|
2863
2930
|
}
|
|
2864
2931
|
// If we have reached here, it means we have not solved the version
|
|
@@ -2874,10 +2941,10 @@ export async function getPyMetadata(pkgList, fetchDepsInfo) {
|
|
|
2874
2941
|
{
|
|
2875
2942
|
technique: "source-code-analysis",
|
|
2876
2943
|
confidence: 0.5,
|
|
2877
|
-
value: `PyPI package: ${p.name}
|
|
2878
|
-
}
|
|
2879
|
-
]
|
|
2880
|
-
}
|
|
2944
|
+
value: `PyPI package: ${p.name}`,
|
|
2945
|
+
},
|
|
2946
|
+
],
|
|
2947
|
+
},
|
|
2881
2948
|
};
|
|
2882
2949
|
}
|
|
2883
2950
|
} else if (p.version !== body.info.version) {
|
|
@@ -2886,11 +2953,11 @@ export async function getPyMetadata(pkgList, fetchDepsInfo) {
|
|
|
2886
2953
|
}
|
|
2887
2954
|
p.properties.push({
|
|
2888
2955
|
name: "cdx:pypi:latest_version",
|
|
2889
|
-
value: body.info.version
|
|
2956
|
+
value: body.info.version,
|
|
2890
2957
|
});
|
|
2891
2958
|
p.properties.push({
|
|
2892
2959
|
name: "cdx:pypi:resolved_from",
|
|
2893
|
-
value: origName
|
|
2960
|
+
value: origName,
|
|
2894
2961
|
});
|
|
2895
2962
|
}
|
|
2896
2963
|
if (
|
|
@@ -2911,7 +2978,7 @@ export async function getPyMetadata(pkgList, fetchDepsInfo) {
|
|
|
2911
2978
|
p.name,
|
|
2912
2979
|
p.version,
|
|
2913
2980
|
null,
|
|
2914
|
-
null
|
|
2981
|
+
null,
|
|
2915
2982
|
).toString();
|
|
2916
2983
|
p.purl = purlString;
|
|
2917
2984
|
p["bom-ref"] = decodeURIComponent(purlString);
|
|
@@ -2920,16 +2987,16 @@ export async function getPyMetadata(pkgList, fetchDepsInfo) {
|
|
|
2920
2987
|
if (DEBUG_MODE) {
|
|
2921
2988
|
console.error(p.name, "is not found on PyPI.");
|
|
2922
2989
|
console.log(
|
|
2923
|
-
"If this package is available from PyPI or a registry, its name might be different from the module name. Raise a ticket at https://github.com/CycloneDX/cdxgen/issues so that this can be added to the mapping file pypi-pkg-aliases.json"
|
|
2990
|
+
"If this package is available from PyPI or a registry, its name might be different from the module name. Raise a ticket at https://github.com/CycloneDX/cdxgen/issues so that this can be added to the mapping file pypi-pkg-aliases.json",
|
|
2924
2991
|
);
|
|
2925
2992
|
console.log(
|
|
2926
|
-
"Alternatively, if this is a package that gets installed directly in your environment and offers a python binding, then track such packages manually."
|
|
2993
|
+
"Alternatively, if this is a package that gets installed directly in your environment and offers a python binding, then track such packages manually.",
|
|
2927
2994
|
);
|
|
2928
2995
|
}
|
|
2929
2996
|
if (!p.version) {
|
|
2930
2997
|
if (DEBUG_MODE) {
|
|
2931
2998
|
console.log(
|
|
2932
|
-
`Assuming the version as latest for the package ${p.name}
|
|
2999
|
+
`Assuming the version as latest for the package ${p.name}`,
|
|
2933
3000
|
);
|
|
2934
3001
|
}
|
|
2935
3002
|
p.version = "latest";
|
|
@@ -2942,10 +3009,10 @@ export async function getPyMetadata(pkgList, fetchDepsInfo) {
|
|
|
2942
3009
|
{
|
|
2943
3010
|
technique: "source-code-analysis",
|
|
2944
3011
|
confidence: 0,
|
|
2945
|
-
value: `Module ${p.name}
|
|
2946
|
-
}
|
|
2947
|
-
]
|
|
2948
|
-
}
|
|
3012
|
+
value: `Module ${p.name}`,
|
|
3013
|
+
},
|
|
3014
|
+
],
|
|
3015
|
+
},
|
|
2949
3016
|
};
|
|
2950
3017
|
}
|
|
2951
3018
|
const purlString = new PackageURL(
|
|
@@ -2954,7 +3021,7 @@ export async function getPyMetadata(pkgList, fetchDepsInfo) {
|
|
|
2954
3021
|
p.name,
|
|
2955
3022
|
p.version,
|
|
2956
3023
|
null,
|
|
2957
|
-
null
|
|
3024
|
+
null,
|
|
2958
3025
|
).toString();
|
|
2959
3026
|
p.purl = purlString;
|
|
2960
3027
|
p["bom-ref"] = decodeURIComponent(purlString);
|
|
@@ -3103,7 +3170,7 @@ export async function parsePoetrylockData(lockData, lockFile) {
|
|
|
3103
3170
|
pkg.name,
|
|
3104
3171
|
pkg.version,
|
|
3105
3172
|
null,
|
|
3106
|
-
null
|
|
3173
|
+
null,
|
|
3107
3174
|
).toString();
|
|
3108
3175
|
pkg.purl = purlString;
|
|
3109
3176
|
pkg["bom-ref"] = decodeURIComponent(purlString);
|
|
@@ -3115,10 +3182,10 @@ export async function parsePoetrylockData(lockData, lockFile) {
|
|
|
3115
3182
|
{
|
|
3116
3183
|
technique: "manifest-analysis",
|
|
3117
3184
|
confidence: 1,
|
|
3118
|
-
value: lockFile
|
|
3119
|
-
}
|
|
3120
|
-
]
|
|
3121
|
-
}
|
|
3185
|
+
value: lockFile,
|
|
3186
|
+
},
|
|
3187
|
+
],
|
|
3188
|
+
},
|
|
3122
3189
|
};
|
|
3123
3190
|
// This would help look
|
|
3124
3191
|
if (!existingPkgMap[pkg.name.toLowerCase()]) {
|
|
@@ -3177,13 +3244,13 @@ export async function parsePoetrylockData(lockData, lockFile) {
|
|
|
3177
3244
|
}
|
|
3178
3245
|
dependenciesList.push({
|
|
3179
3246
|
ref: key,
|
|
3180
|
-
dependsOn: dependsOnList
|
|
3247
|
+
dependsOn: dependsOnList,
|
|
3181
3248
|
});
|
|
3182
3249
|
}
|
|
3183
3250
|
return {
|
|
3184
3251
|
pkgList,
|
|
3185
3252
|
rootList: pkgList,
|
|
3186
|
-
dependenciesList
|
|
3253
|
+
dependenciesList,
|
|
3187
3254
|
};
|
|
3188
3255
|
}
|
|
3189
3256
|
|
|
@@ -3241,14 +3308,14 @@ export async function parseReqFile(reqData, fetchDepsInfo) {
|
|
|
3241
3308
|
const apkg = {
|
|
3242
3309
|
name,
|
|
3243
3310
|
version: versionStr,
|
|
3244
|
-
scope: compScope
|
|
3311
|
+
scope: compScope,
|
|
3245
3312
|
};
|
|
3246
3313
|
if (markers) {
|
|
3247
3314
|
apkg.properties = [
|
|
3248
3315
|
{
|
|
3249
3316
|
name: "cdx:pip:markers",
|
|
3250
|
-
value: markers
|
|
3251
|
-
}
|
|
3317
|
+
value: markers,
|
|
3318
|
+
},
|
|
3252
3319
|
];
|
|
3253
3320
|
}
|
|
3254
3321
|
pkgList.push(apkg);
|
|
@@ -3266,9 +3333,9 @@ export async function parseReqFile(reqData, fetchDepsInfo) {
|
|
|
3266
3333
|
properties: [
|
|
3267
3334
|
{
|
|
3268
3335
|
name: "cdx:pypi:versionSpecifiers",
|
|
3269
|
-
value: versionSpecifiers
|
|
3270
|
-
}
|
|
3271
|
-
]
|
|
3336
|
+
value: versionSpecifiers,
|
|
3337
|
+
},
|
|
3338
|
+
],
|
|
3272
3339
|
});
|
|
3273
3340
|
}
|
|
3274
3341
|
} else if (/[>|[|@]/.test(l)) {
|
|
@@ -3287,9 +3354,9 @@ export async function parseReqFile(reqData, fetchDepsInfo) {
|
|
|
3287
3354
|
properties: [
|
|
3288
3355
|
{
|
|
3289
3356
|
name: "cdx:pypi:versionSpecifiers",
|
|
3290
|
-
value: versionSpecifiers
|
|
3291
|
-
}
|
|
3292
|
-
]
|
|
3357
|
+
value: versionSpecifiers,
|
|
3358
|
+
},
|
|
3359
|
+
],
|
|
3293
3360
|
});
|
|
3294
3361
|
}
|
|
3295
3362
|
}
|
|
@@ -3310,9 +3377,9 @@ export async function parseReqFile(reqData, fetchDepsInfo) {
|
|
|
3310
3377
|
properties: [
|
|
3311
3378
|
{
|
|
3312
3379
|
name: "cdx:pypi:versionSpecifiers",
|
|
3313
|
-
value: versionSpecifiers
|
|
3314
|
-
}
|
|
3315
|
-
]
|
|
3380
|
+
value: versionSpecifiers,
|
|
3381
|
+
},
|
|
3382
|
+
],
|
|
3316
3383
|
});
|
|
3317
3384
|
}
|
|
3318
3385
|
} else if (!l.includes(" ")) {
|
|
@@ -3326,9 +3393,9 @@ export async function parseReqFile(reqData, fetchDepsInfo) {
|
|
|
3326
3393
|
properties: [
|
|
3327
3394
|
{
|
|
3328
3395
|
name: "cdx:pypi:versionSpecifiers",
|
|
3329
|
-
value: versionSpecifiers
|
|
3330
|
-
}
|
|
3331
|
-
]
|
|
3396
|
+
value: versionSpecifiers,
|
|
3397
|
+
},
|
|
3398
|
+
],
|
|
3332
3399
|
});
|
|
3333
3400
|
}
|
|
3334
3401
|
}
|
|
@@ -3350,7 +3417,7 @@ export async function getPyModules(src, epkgList, options) {
|
|
|
3350
3417
|
const dependenciesList = [];
|
|
3351
3418
|
let modList = [];
|
|
3352
3419
|
const slicesFile = resolve(
|
|
3353
|
-
options.depsSlicesFile || options.usagesSlicesFile
|
|
3420
|
+
options.depsSlicesFile || options.usagesSlicesFile,
|
|
3354
3421
|
);
|
|
3355
3422
|
// Issue: 615 fix. Reuse existing slices file
|
|
3356
3423
|
if (slicesFile && existsSync(slicesFile)) {
|
|
@@ -3368,7 +3435,7 @@ export async function getPyModules(src, epkgList, options) {
|
|
|
3368
3435
|
(x) =>
|
|
3369
3436
|
!pyDefaultModules.has(x.name.toLowerCase()) &&
|
|
3370
3437
|
!x.name.startsWith("_") &&
|
|
3371
|
-
!x.name.startsWith(".")
|
|
3438
|
+
!x.name.startsWith("."),
|
|
3372
3439
|
);
|
|
3373
3440
|
let pkgList = modList.map((p) => {
|
|
3374
3441
|
const apkg = {
|
|
@@ -3381,20 +3448,20 @@ export async function getPyModules(src, epkgList, options) {
|
|
|
3381
3448
|
properties: [
|
|
3382
3449
|
{
|
|
3383
3450
|
name: "cdx:pypi:versionSpecifiers",
|
|
3384
|
-
value: p.versionSpecifiers
|
|
3385
|
-
}
|
|
3386
|
-
]
|
|
3451
|
+
value: p.versionSpecifiers,
|
|
3452
|
+
},
|
|
3453
|
+
],
|
|
3387
3454
|
};
|
|
3388
3455
|
if (p.importedSymbols) {
|
|
3389
3456
|
apkg.properties.push({
|
|
3390
3457
|
name: "ImportedModules",
|
|
3391
|
-
value: p.importedSymbols
|
|
3458
|
+
value: p.importedSymbols,
|
|
3392
3459
|
});
|
|
3393
3460
|
}
|
|
3394
3461
|
return apkg;
|
|
3395
3462
|
});
|
|
3396
3463
|
pkgList = pkgList.filter(
|
|
3397
|
-
(obj, index) => pkgList.findIndex((i) => i.name === obj.name) === index
|
|
3464
|
+
(obj, index) => pkgList.findIndex((i) => i.name === obj.name) === index,
|
|
3398
3465
|
);
|
|
3399
3466
|
if (epkgList && epkgList.length) {
|
|
3400
3467
|
const pkgMaps = epkgList.map((p) => p.name);
|
|
@@ -3411,7 +3478,7 @@ export async function getPyModules(src, epkgList, options) {
|
|
|
3411
3478
|
if (p.version) {
|
|
3412
3479
|
dependenciesList.push({
|
|
3413
3480
|
ref: `pkg:pypi/${p.name.replace(/_/g, "-")}@${p.version}`.toLowerCase(),
|
|
3414
|
-
dependsOn: []
|
|
3481
|
+
dependsOn: [],
|
|
3415
3482
|
});
|
|
3416
3483
|
}
|
|
3417
3484
|
}
|
|
@@ -3496,7 +3563,7 @@ export function toGitHubApiUrl(repoUrl, repoMetadata) {
|
|
|
3496
3563
|
} else {
|
|
3497
3564
|
return repoMetadataToGitHubApiUrl({
|
|
3498
3565
|
group: parts[3],
|
|
3499
|
-
name: parts[4]
|
|
3566
|
+
name: parts[4],
|
|
3500
3567
|
});
|
|
3501
3568
|
}
|
|
3502
3569
|
}
|
|
@@ -3520,18 +3587,18 @@ export async function getRepoLicense(repoUrl, repoMetadata) {
|
|
|
3520
3587
|
try {
|
|
3521
3588
|
const res = await cdxgenAgent.get(licenseUrl, {
|
|
3522
3589
|
responseType: "json",
|
|
3523
|
-
headers: headers
|
|
3590
|
+
headers: headers,
|
|
3524
3591
|
});
|
|
3525
3592
|
if (res && res.body) {
|
|
3526
3593
|
const license = res.body.license;
|
|
3527
3594
|
let licenseId = license.spdx_id;
|
|
3528
3595
|
const licObj = {
|
|
3529
|
-
url: res.body.html_url
|
|
3596
|
+
url: res.body.html_url,
|
|
3530
3597
|
};
|
|
3531
3598
|
if (license.spdx_id === "NOASSERTION") {
|
|
3532
3599
|
if (res.body.content) {
|
|
3533
3600
|
const content = Buffer.from(res.body.content, "base64").toString(
|
|
3534
|
-
"ascii"
|
|
3601
|
+
"ascii",
|
|
3535
3602
|
);
|
|
3536
3603
|
licenseId = guessLicenseId(content);
|
|
3537
3604
|
}
|
|
@@ -3555,7 +3622,7 @@ export async function getRepoLicense(repoUrl, repoMetadata) {
|
|
|
3555
3622
|
console.log(
|
|
3556
3623
|
"Rate limit exceeded for REST API of github.com. " +
|
|
3557
3624
|
"Please ensure GITHUB_TOKEN is set as environment variable. " +
|
|
3558
|
-
"See: https://docs.github.com/en/rest/overview/rate-limits-for-the-rest-api"
|
|
3625
|
+
"See: https://docs.github.com/en/rest/overview/rate-limits-for-the-rest-api",
|
|
3559
3626
|
);
|
|
3560
3627
|
get_repo_license_errors++;
|
|
3561
3628
|
} else if (!err.message.includes("404")) {
|
|
@@ -3629,12 +3696,12 @@ export async function getGoPkgComponent(group, name, version, hash) {
|
|
|
3629
3696
|
if (FETCH_LICENSE) {
|
|
3630
3697
|
if (DEBUG_MODE) {
|
|
3631
3698
|
console.log(
|
|
3632
|
-
`About to fetch go package license information for ${group}:${name}
|
|
3699
|
+
`About to fetch go package license information for ${group}:${name}`,
|
|
3633
3700
|
);
|
|
3634
3701
|
}
|
|
3635
3702
|
license = await getGoPkgLicense({
|
|
3636
3703
|
group: group,
|
|
3637
|
-
name: name
|
|
3704
|
+
name: name,
|
|
3638
3705
|
});
|
|
3639
3706
|
}
|
|
3640
3707
|
// By replacing %2F with /, we make the purl compatible with the spec.
|
|
@@ -3648,7 +3715,7 @@ export async function getGoPkgComponent(group, name, version, hash) {
|
|
|
3648
3715
|
_integrity: hash,
|
|
3649
3716
|
license: license,
|
|
3650
3717
|
purl: purlString,
|
|
3651
|
-
"bom-ref": decodeURIComponent(purlString)
|
|
3718
|
+
"bom-ref": decodeURIComponent(purlString),
|
|
3652
3719
|
};
|
|
3653
3720
|
return pkg;
|
|
3654
3721
|
}
|
|
@@ -3702,7 +3769,7 @@ export async function parseGoModData(goModData, gosumMap) {
|
|
|
3702
3769
|
"",
|
|
3703
3770
|
tmpA[0],
|
|
3704
3771
|
version,
|
|
3705
|
-
gosumHash
|
|
3772
|
+
gosumHash,
|
|
3706
3773
|
);
|
|
3707
3774
|
pkgComponentsList.push(component);
|
|
3708
3775
|
} else {
|
|
@@ -3718,7 +3785,7 @@ export async function parseGoModData(goModData, gosumMap) {
|
|
|
3718
3785
|
"",
|
|
3719
3786
|
tmpA[2],
|
|
3720
3787
|
version,
|
|
3721
|
-
gosumHash
|
|
3788
|
+
gosumHash,
|
|
3722
3789
|
);
|
|
3723
3790
|
pkgComponentsList.push(component);
|
|
3724
3791
|
}
|
|
@@ -3741,7 +3808,7 @@ export async function parseGoListDep(rawOutput, gosumMap) {
|
|
|
3741
3808
|
const keys_cache = {};
|
|
3742
3809
|
const pkgs = rawOutput.split("\n");
|
|
3743
3810
|
for (const l of pkgs) {
|
|
3744
|
-
const verArr = l.trim().replace(
|
|
3811
|
+
const verArr = l.trim().replace(/[\"']/g, "").split(" ");
|
|
3745
3812
|
|
|
3746
3813
|
if (verArr && verArr.length >= 5) {
|
|
3747
3814
|
const key = verArr[0] + "-" + verArr[1];
|
|
@@ -3754,7 +3821,7 @@ export async function parseGoListDep(rawOutput, gosumMap) {
|
|
|
3754
3821
|
"",
|
|
3755
3822
|
verArr[0],
|
|
3756
3823
|
version,
|
|
3757
|
-
gosumHash
|
|
3824
|
+
gosumHash,
|
|
3758
3825
|
);
|
|
3759
3826
|
if (verArr[2] === "false") {
|
|
3760
3827
|
component.scope = "required";
|
|
@@ -3764,12 +3831,12 @@ export async function parseGoListDep(rawOutput, gosumMap) {
|
|
|
3764
3831
|
component.properties = [
|
|
3765
3832
|
{
|
|
3766
3833
|
name: "SrcGoMod",
|
|
3767
|
-
value: verArr[3] || ""
|
|
3834
|
+
value: verArr[3] || "",
|
|
3768
3835
|
},
|
|
3769
3836
|
{
|
|
3770
3837
|
name: "ModuleGoVersion",
|
|
3771
|
-
value: verArr[4] || ""
|
|
3772
|
-
}
|
|
3838
|
+
value: verArr[4] || "",
|
|
3839
|
+
},
|
|
3773
3840
|
];
|
|
3774
3841
|
if (verArr.length > 5 && verArr[5] === "true") {
|
|
3775
3842
|
parentComponent = component;
|
|
@@ -3782,7 +3849,7 @@ export async function parseGoListDep(rawOutput, gosumMap) {
|
|
|
3782
3849
|
}
|
|
3783
3850
|
return {
|
|
3784
3851
|
parentComponent,
|
|
3785
|
-
pkgList: deps
|
|
3852
|
+
pkgList: deps,
|
|
3786
3853
|
};
|
|
3787
3854
|
}
|
|
3788
3855
|
|
|
@@ -3795,17 +3862,17 @@ function _addGoComponentEvidence(component, goModFile) {
|
|
|
3795
3862
|
{
|
|
3796
3863
|
technique: "manifest-analysis",
|
|
3797
3864
|
confidence: 1,
|
|
3798
|
-
value: goModFile
|
|
3799
|
-
}
|
|
3800
|
-
]
|
|
3801
|
-
}
|
|
3865
|
+
value: goModFile,
|
|
3866
|
+
},
|
|
3867
|
+
],
|
|
3868
|
+
},
|
|
3802
3869
|
};
|
|
3803
3870
|
if (!component.properties) {
|
|
3804
3871
|
component.properties = [];
|
|
3805
3872
|
}
|
|
3806
3873
|
component.properties.push({
|
|
3807
3874
|
name: "SrcFile",
|
|
3808
|
-
value: goModFile
|
|
3875
|
+
value: goModFile,
|
|
3809
3876
|
});
|
|
3810
3877
|
return component;
|
|
3811
3878
|
}
|
|
@@ -3825,7 +3892,7 @@ export async function parseGoModGraph(
|
|
|
3825
3892
|
goModFile,
|
|
3826
3893
|
gosumMap,
|
|
3827
3894
|
epkgList = [],
|
|
3828
|
-
parentComponent = {}
|
|
3895
|
+
parentComponent = {},
|
|
3829
3896
|
) {
|
|
3830
3897
|
const pkgList = [];
|
|
3831
3898
|
const dependenciesList = [];
|
|
@@ -3870,7 +3937,7 @@ export async function parseGoModGraph(
|
|
|
3870
3937
|
sourcePurl.name
|
|
3871
3938
|
}`,
|
|
3872
3939
|
sourcePurl.version,
|
|
3873
|
-
gosumMap[tmpA[0]]
|
|
3940
|
+
gosumMap[tmpA[0]],
|
|
3874
3941
|
);
|
|
3875
3942
|
pkgList.push(_addGoComponentEvidence(component, goModFile));
|
|
3876
3943
|
addedPkgs[tmpA[0]] = true;
|
|
@@ -3882,7 +3949,7 @@ export async function parseGoModGraph(
|
|
|
3882
3949
|
dependsPurl.name
|
|
3883
3950
|
}`,
|
|
3884
3951
|
dependsPurl.version,
|
|
3885
|
-
gosumMap[tmpA[1]]
|
|
3952
|
+
gosumMap[tmpA[1]],
|
|
3886
3953
|
);
|
|
3887
3954
|
pkgList.push(component);
|
|
3888
3955
|
addedPkgs[tmpA[1]] = true;
|
|
@@ -3903,7 +3970,7 @@ export async function parseGoModGraph(
|
|
|
3903
3970
|
for (const adep of Object.keys(depsMap).sort()) {
|
|
3904
3971
|
dependenciesList.push({
|
|
3905
3972
|
ref: adep,
|
|
3906
|
-
dependsOn: Array.from(depsMap[adep]).sort()
|
|
3973
|
+
dependsOn: Array.from(depsMap[adep]).sort(),
|
|
3907
3974
|
});
|
|
3908
3975
|
}
|
|
3909
3976
|
return { pkgList, dependenciesList };
|
|
@@ -3951,12 +4018,12 @@ export async function parseGosumData(gosumData) {
|
|
|
3951
4018
|
if (FETCH_LICENSE) {
|
|
3952
4019
|
if (DEBUG_MODE) {
|
|
3953
4020
|
console.log(
|
|
3954
|
-
`About to fetch go package license information for ${name}
|
|
4021
|
+
`About to fetch go package license information for ${name}`,
|
|
3955
4022
|
);
|
|
3956
4023
|
}
|
|
3957
4024
|
license = await getGoPkgLicense({
|
|
3958
4025
|
group: "",
|
|
3959
|
-
name: name
|
|
4026
|
+
name: name,
|
|
3960
4027
|
});
|
|
3961
4028
|
}
|
|
3962
4029
|
pkgList.push({
|
|
@@ -3964,7 +4031,7 @@ export async function parseGosumData(gosumData) {
|
|
|
3964
4031
|
name: name,
|
|
3965
4032
|
version: version,
|
|
3966
4033
|
_integrity: hash,
|
|
3967
|
-
license: license
|
|
4034
|
+
license: license,
|
|
3968
4035
|
});
|
|
3969
4036
|
}
|
|
3970
4037
|
}
|
|
@@ -4003,7 +4070,7 @@ export async function parseGopkgData(gopkgData) {
|
|
|
4003
4070
|
if (FETCH_LICENSE) {
|
|
4004
4071
|
pkg.license = await getGoPkgLicense({
|
|
4005
4072
|
group: pkg.group,
|
|
4006
|
-
name: pkg.name
|
|
4073
|
+
name: pkg.name,
|
|
4007
4074
|
});
|
|
4008
4075
|
}
|
|
4009
4076
|
break;
|
|
@@ -4055,7 +4122,7 @@ export const RUBY_PLATFORM_PREFIXES = [
|
|
|
4055
4122
|
"-ruby",
|
|
4056
4123
|
"-universal",
|
|
4057
4124
|
"-java",
|
|
4058
|
-
"-truffle"
|
|
4125
|
+
"-truffle",
|
|
4059
4126
|
];
|
|
4060
4127
|
|
|
4061
4128
|
/**
|
|
@@ -4085,11 +4152,11 @@ export async function getRubyGemsMetadata(pkgList) {
|
|
|
4085
4152
|
process.env.RUBYGEMS_V1_URL || "https://rubygems.org/api/v1/gems/";
|
|
4086
4153
|
const rdepList = [];
|
|
4087
4154
|
const apiOptions = {
|
|
4088
|
-
responseType: "json"
|
|
4155
|
+
responseType: "json",
|
|
4089
4156
|
};
|
|
4090
4157
|
if (process.env.GEM_HOST_API_KEY) {
|
|
4091
4158
|
apiOptions.headers = {
|
|
4092
|
-
Authorization: process.env.GEM_HOST_API_KEY
|
|
4159
|
+
Authorization: process.env.GEM_HOST_API_KEY,
|
|
4093
4160
|
};
|
|
4094
4161
|
}
|
|
4095
4162
|
for (const p of pkgList) {
|
|
@@ -4099,7 +4166,7 @@ export async function getRubyGemsMetadata(pkgList) {
|
|
|
4099
4166
|
}
|
|
4100
4167
|
const fullUrl = p.version
|
|
4101
4168
|
? `${RUBYGEMS_V2_URL}${p.name}/versions/${simplifyRubyVersion(
|
|
4102
|
-
p.version
|
|
4169
|
+
p.version,
|
|
4103
4170
|
)}.json`
|
|
4104
4171
|
: `${RUBYGEMS_V1_URL}${p.name}.json`;
|
|
4105
4172
|
const res = await cdxgenAgent.get(fullUrl, apiOptions);
|
|
@@ -4137,31 +4204,31 @@ export async function getRubyGemsMetadata(pkgList) {
|
|
|
4137
4204
|
if (!platformPresent && body.platform && body.platform !== "ruby") {
|
|
4138
4205
|
p.properties.push({
|
|
4139
4206
|
name: "cdx:gem:platform",
|
|
4140
|
-
value: body.platform
|
|
4207
|
+
value: body.platform,
|
|
4141
4208
|
});
|
|
4142
4209
|
}
|
|
4143
4210
|
if (body.ruby_version) {
|
|
4144
4211
|
p.properties.push({
|
|
4145
4212
|
name: "cdx:gem:rubyVersionSpecifiers",
|
|
4146
|
-
value: body.ruby_version
|
|
4213
|
+
value: body.ruby_version,
|
|
4147
4214
|
});
|
|
4148
4215
|
}
|
|
4149
4216
|
if (body.gem_uri) {
|
|
4150
4217
|
p.properties.push({
|
|
4151
4218
|
name: "cdx:gem:gemUri",
|
|
4152
|
-
value: body.gem_uri
|
|
4219
|
+
value: body.gem_uri,
|
|
4153
4220
|
});
|
|
4154
4221
|
}
|
|
4155
4222
|
if (body.yanked) {
|
|
4156
4223
|
p.properties.push({
|
|
4157
4224
|
name: "cdx:gem:yanked",
|
|
4158
|
-
value: "" + body.yanked
|
|
4225
|
+
value: "" + body.yanked,
|
|
4159
4226
|
});
|
|
4160
4227
|
}
|
|
4161
4228
|
if (body.prerelease) {
|
|
4162
4229
|
p.properties.push({
|
|
4163
4230
|
name: "cdx:gem:prerelease",
|
|
4164
|
-
value: "" + body.prerelease
|
|
4231
|
+
value: "" + body.prerelease,
|
|
4165
4232
|
});
|
|
4166
4233
|
}
|
|
4167
4234
|
// Use the latest version if none specified
|
|
@@ -4378,7 +4445,7 @@ export async function parseGemfileLockData(gemLockData, lockFile) {
|
|
|
4378
4445
|
name,
|
|
4379
4446
|
version,
|
|
4380
4447
|
null,
|
|
4381
|
-
null
|
|
4448
|
+
null,
|
|
4382
4449
|
).toString();
|
|
4383
4450
|
const bomRef = decodeURIComponent(purlString);
|
|
4384
4451
|
if (level === 1) {
|
|
@@ -4388,37 +4455,37 @@ export async function parseGemfileLockData(gemLockData, lockFile) {
|
|
|
4388
4455
|
const properties = [
|
|
4389
4456
|
{
|
|
4390
4457
|
name: "SrcFile",
|
|
4391
|
-
value: lockFile
|
|
4392
|
-
}
|
|
4458
|
+
value: lockFile,
|
|
4459
|
+
},
|
|
4393
4460
|
];
|
|
4394
4461
|
if (lastRemote) {
|
|
4395
4462
|
properties.push({
|
|
4396
4463
|
name: "cdx:gem:remote",
|
|
4397
|
-
value: lastRemote
|
|
4464
|
+
value: lastRemote,
|
|
4398
4465
|
});
|
|
4399
4466
|
}
|
|
4400
4467
|
if (lastRevision) {
|
|
4401
4468
|
properties.push({
|
|
4402
4469
|
name: "cdx:gem:remoteRevision",
|
|
4403
|
-
value: lastRevision
|
|
4470
|
+
value: lastRevision,
|
|
4404
4471
|
});
|
|
4405
4472
|
}
|
|
4406
4473
|
if (lastBranch) {
|
|
4407
4474
|
properties.push({
|
|
4408
4475
|
name: "cdx:gem:remoteBranch",
|
|
4409
|
-
value: lastBranch
|
|
4476
|
+
value: lastBranch,
|
|
4410
4477
|
});
|
|
4411
4478
|
}
|
|
4412
4479
|
if (lastTag) {
|
|
4413
4480
|
properties.push({
|
|
4414
4481
|
name: "cdx:gem:remoteTag",
|
|
4415
|
-
value: lastTag
|
|
4482
|
+
value: lastTag,
|
|
4416
4483
|
});
|
|
4417
4484
|
}
|
|
4418
4485
|
if (lastParentPlatform) {
|
|
4419
4486
|
properties.push({
|
|
4420
4487
|
name: "cdx:gem:platform",
|
|
4421
|
-
value: lastParentPlatform
|
|
4488
|
+
value: lastParentPlatform,
|
|
4422
4489
|
});
|
|
4423
4490
|
}
|
|
4424
4491
|
const apkg = {
|
|
@@ -4435,11 +4502,11 @@ export async function parseGemfileLockData(gemLockData, lockFile) {
|
|
|
4435
4502
|
{
|
|
4436
4503
|
technique: "manifest-analysis",
|
|
4437
4504
|
confidence: 0.8,
|
|
4438
|
-
value: lockFile
|
|
4439
|
-
}
|
|
4440
|
-
]
|
|
4441
|
-
}
|
|
4442
|
-
}
|
|
4505
|
+
value: lockFile,
|
|
4506
|
+
},
|
|
4507
|
+
],
|
|
4508
|
+
},
|
|
4509
|
+
},
|
|
4443
4510
|
};
|
|
4444
4511
|
if (lastParent && lastParent !== bomRef) {
|
|
4445
4512
|
if (!dependenciesMap[lastParent]) {
|
|
@@ -4460,7 +4527,7 @@ export async function parseGemfileLockData(gemLockData, lockFile) {
|
|
|
4460
4527
|
for (const k of Object.keys(dependenciesMap)) {
|
|
4461
4528
|
dependenciesList.push({
|
|
4462
4529
|
ref: k,
|
|
4463
|
-
dependsOn: Array.from(dependenciesMap[k])
|
|
4530
|
+
dependsOn: Array.from(dependenciesMap[k]),
|
|
4464
4531
|
});
|
|
4465
4532
|
}
|
|
4466
4533
|
if (FETCH_LICENSE) {
|
|
@@ -4484,7 +4551,7 @@ export async function getCratesMetadata(pkgList) {
|
|
|
4484
4551
|
console.log(`Querying crates.io for ${p.name}`);
|
|
4485
4552
|
}
|
|
4486
4553
|
const res = await cdxgenAgent.get(CRATES_URL + p.name, {
|
|
4487
|
-
responseType: "json"
|
|
4554
|
+
responseType: "json",
|
|
4488
4555
|
});
|
|
4489
4556
|
const body = res.body.crate;
|
|
4490
4557
|
p.description = body.description;
|
|
@@ -4531,8 +4598,8 @@ export async function getDartMetadata(pkgList) {
|
|
|
4531
4598
|
const res = await cdxgenAgent.get(PUB_PACKAGES_URL + p.name, {
|
|
4532
4599
|
responseType: RESPONSE_TYPE,
|
|
4533
4600
|
headers: {
|
|
4534
|
-
Accept: HEADER_ACCEPT
|
|
4535
|
-
}
|
|
4601
|
+
Accept: HEADER_ACCEPT,
|
|
4602
|
+
},
|
|
4536
4603
|
});
|
|
4537
4604
|
if (res && res.body) {
|
|
4538
4605
|
const version = res.body.versions.find((v) => p.version === v.version);
|
|
@@ -4550,9 +4617,9 @@ export async function getDartMetadata(pkgList) {
|
|
|
4550
4617
|
{
|
|
4551
4618
|
responseType: RESPONSE_TYPE,
|
|
4552
4619
|
headers: {
|
|
4553
|
-
Accept: HEADER_ACCEPT
|
|
4554
|
-
}
|
|
4555
|
-
}
|
|
4620
|
+
Accept: HEADER_ACCEPT,
|
|
4621
|
+
},
|
|
4622
|
+
},
|
|
4556
4623
|
);
|
|
4557
4624
|
if (res2 && res2.body) {
|
|
4558
4625
|
const tags = res2.body.tags;
|
|
@@ -4561,7 +4628,7 @@ export async function getDartMetadata(pkgList) {
|
|
|
4561
4628
|
p.license = spdxLicenses.find(
|
|
4562
4629
|
(spdxLicense) =>
|
|
4563
4630
|
spdxLicense.toLowerCase() ===
|
|
4564
|
-
license.replace(PUB_LICENSE_REGEX, "").toLowerCase()
|
|
4631
|
+
license.replace(PUB_LICENSE_REGEX, "").toLowerCase(),
|
|
4565
4632
|
);
|
|
4566
4633
|
}
|
|
4567
4634
|
}
|
|
@@ -4606,8 +4673,8 @@ export async function parseCargoTomlData(cargoTomlFile, simple = false) {
|
|
|
4606
4673
|
pkg.properties = [
|
|
4607
4674
|
{
|
|
4608
4675
|
name: "SrcFile",
|
|
4609
|
-
value: cargoTomlFile
|
|
4610
|
-
}
|
|
4676
|
+
value: cargoTomlFile,
|
|
4677
|
+
},
|
|
4611
4678
|
];
|
|
4612
4679
|
pkg.evidence = {
|
|
4613
4680
|
identity: {
|
|
@@ -4617,10 +4684,10 @@ export async function parseCargoTomlData(cargoTomlFile, simple = false) {
|
|
|
4617
4684
|
{
|
|
4618
4685
|
technique: "manifest-analysis",
|
|
4619
4686
|
confidence: 0.5,
|
|
4620
|
-
value: cargoTomlFile
|
|
4621
|
-
}
|
|
4622
|
-
]
|
|
4623
|
-
}
|
|
4687
|
+
value: cargoTomlFile,
|
|
4688
|
+
},
|
|
4689
|
+
],
|
|
4690
|
+
},
|
|
4624
4691
|
};
|
|
4625
4692
|
}
|
|
4626
4693
|
const ppurl = new PackageURL(
|
|
@@ -4629,7 +4696,7 @@ export async function parseCargoTomlData(cargoTomlFile, simple = false) {
|
|
|
4629
4696
|
pkg.name,
|
|
4630
4697
|
pkg.version,
|
|
4631
4698
|
null,
|
|
4632
|
-
null
|
|
4699
|
+
null,
|
|
4633
4700
|
).toString();
|
|
4634
4701
|
pkg.purl = ppurl;
|
|
4635
4702
|
pkg["bom-ref"] = decodeURIComponent(ppurl);
|
|
@@ -4675,7 +4742,7 @@ export async function parseCargoTomlData(cargoTomlFile, simple = false) {
|
|
|
4675
4742
|
// component unreliable.
|
|
4676
4743
|
if (l.startsWith("[workspace]") && DEBUG_MODE) {
|
|
4677
4744
|
console.log(
|
|
4678
|
-
`Found [workspace] section in ${cargoTomlFile}. Workspaces are currently not fully supported. Verify that the parent component is correct
|
|
4745
|
+
`Found [workspace] section in ${cargoTomlFile}. Workspaces are currently not fully supported. Verify that the parent component is correct.`,
|
|
4679
4746
|
);
|
|
4680
4747
|
}
|
|
4681
4748
|
|
|
@@ -4742,8 +4809,8 @@ export async function parseCargoTomlData(cargoTomlFile, simple = false) {
|
|
|
4742
4809
|
version = tmpA[1];
|
|
4743
4810
|
}
|
|
4744
4811
|
if (name && version) {
|
|
4745
|
-
name = name.replace(
|
|
4746
|
-
version = version.replace(
|
|
4812
|
+
name = name.replace(/[\"']/g, "");
|
|
4813
|
+
version = version.replace(/[\"']/g, "");
|
|
4747
4814
|
const apkg = { name, version };
|
|
4748
4815
|
addPackageToList(pkgList, apkg, { packageMode, simple });
|
|
4749
4816
|
}
|
|
@@ -4779,7 +4846,7 @@ export async function parseCargoData(cargoLockFile, simple = false) {
|
|
|
4779
4846
|
newPackage.name,
|
|
4780
4847
|
newPackage.version,
|
|
4781
4848
|
null,
|
|
4782
|
-
null
|
|
4849
|
+
null,
|
|
4783
4850
|
).toString();
|
|
4784
4851
|
const component = {
|
|
4785
4852
|
type: "library",
|
|
@@ -4787,15 +4854,15 @@ export async function parseCargoData(cargoLockFile, simple = false) {
|
|
|
4787
4854
|
"bom-ref": purl,
|
|
4788
4855
|
purl: purl,
|
|
4789
4856
|
name: newPackage.name,
|
|
4790
|
-
version: newPackage.version
|
|
4857
|
+
version: newPackage.version,
|
|
4791
4858
|
};
|
|
4792
4859
|
|
|
4793
4860
|
if (newPackage._integrity) {
|
|
4794
4861
|
component.hashes = [
|
|
4795
4862
|
{
|
|
4796
4863
|
alg: "SHA-384",
|
|
4797
|
-
content: pkg._integrity
|
|
4798
|
-
}
|
|
4864
|
+
content: pkg._integrity,
|
|
4865
|
+
},
|
|
4799
4866
|
];
|
|
4800
4867
|
}
|
|
4801
4868
|
|
|
@@ -4815,18 +4882,18 @@ export async function parseCargoData(cargoLockFile, simple = false) {
|
|
|
4815
4882
|
{
|
|
4816
4883
|
technique: "manifest-analysis",
|
|
4817
4884
|
confidence: 0.6,
|
|
4818
|
-
value: cargoLockFile
|
|
4819
|
-
}
|
|
4820
|
-
]
|
|
4821
|
-
}
|
|
4885
|
+
value: cargoLockFile,
|
|
4886
|
+
},
|
|
4887
|
+
],
|
|
4888
|
+
},
|
|
4822
4889
|
};
|
|
4823
4890
|
|
|
4824
4891
|
// Evidence information for CyclondDX specification version < 1.5.
|
|
4825
4892
|
component.properties = [
|
|
4826
4893
|
{
|
|
4827
4894
|
name: "SrcFile",
|
|
4828
|
-
value: cargoLockFile
|
|
4829
|
-
}
|
|
4895
|
+
value: cargoLockFile,
|
|
4896
|
+
},
|
|
4830
4897
|
];
|
|
4831
4898
|
}
|
|
4832
4899
|
packageList.push(component);
|
|
@@ -4910,7 +4977,7 @@ export function parseCargoDependencyData(cargoLockData) {
|
|
|
4910
4977
|
|
|
4911
4978
|
const purlFromPackageInfo = (pkg) =>
|
|
4912
4979
|
decodeURIComponent(
|
|
4913
|
-
new PackageURL("cargo", "", pkg.name, pkg.version, null, null).toString()
|
|
4980
|
+
new PackageURL("cargo", "", pkg.name, pkg.version, null, null).toString(),
|
|
4914
4981
|
);
|
|
4915
4982
|
|
|
4916
4983
|
// The dependency list may appear as a single-line list:
|
|
@@ -4950,7 +5017,7 @@ export function parseCargoDependencyData(cargoLockData) {
|
|
|
4950
5017
|
const [name, version] = dependencyName.split(" ");
|
|
4951
5018
|
return {
|
|
4952
5019
|
name,
|
|
4953
|
-
version
|
|
5020
|
+
version,
|
|
4954
5021
|
};
|
|
4955
5022
|
})
|
|
4956
5023
|
);
|
|
@@ -4991,7 +5058,7 @@ export function parseCargoDependencyData(cargoLockData) {
|
|
|
4991
5058
|
if (!pkg.dependencies) {
|
|
4992
5059
|
return {
|
|
4993
5060
|
ref: purlFromPackageInfo(pkg),
|
|
4994
|
-
dependsOn: []
|
|
5061
|
+
dependsOn: [],
|
|
4995
5062
|
};
|
|
4996
5063
|
}
|
|
4997
5064
|
return {
|
|
@@ -5013,7 +5080,7 @@ export function parseCargoDependencyData(cargoLockData) {
|
|
|
5013
5080
|
// and continue.
|
|
5014
5081
|
if (DEBUG_MODE) {
|
|
5015
5082
|
console.warn(
|
|
5016
|
-
`The package "${dependency.name}" appears as a dependency to "${pkg.name}" but is not itself listed in the Cargo.lock-file. The Cargo.lock-file is invalid! The produced SBOM will not list ${dependency.name} as a dependency
|
|
5083
|
+
`The package "${dependency.name}" appears as a dependency to "${pkg.name}" but is not itself listed in the Cargo.lock-file. The Cargo.lock-file is invalid! The produced SBOM will not list ${dependency.name} as a dependency.`,
|
|
5017
5084
|
);
|
|
5018
5085
|
}
|
|
5019
5086
|
return undefined;
|
|
@@ -5023,7 +5090,7 @@ export function parseCargoDependencyData(cargoLockData) {
|
|
|
5023
5090
|
// version known from the package table.
|
|
5024
5091
|
return purlFromPackageInfo(lockfileInventory[dependency.name]);
|
|
5025
5092
|
})
|
|
5026
|
-
.filter((pkg) => pkg) // Filter undefined entries, which should only happen when packages listed as a dependency are not defined as packages.
|
|
5093
|
+
.filter((pkg) => pkg), // Filter undefined entries, which should only happen when packages listed as a dependency are not defined as packages.
|
|
5027
5094
|
};
|
|
5028
5095
|
});
|
|
5029
5096
|
}
|
|
@@ -5046,7 +5113,7 @@ export async function parseCargoAuditableData(cargoData) {
|
|
|
5046
5113
|
pkgList.push({
|
|
5047
5114
|
group,
|
|
5048
5115
|
name,
|
|
5049
|
-
version
|
|
5116
|
+
version,
|
|
5050
5117
|
});
|
|
5051
5118
|
}
|
|
5052
5119
|
});
|
|
@@ -5072,7 +5139,7 @@ export async function parsePubLockData(pubLockData) {
|
|
|
5072
5139
|
}
|
|
5073
5140
|
if (l.startsWith(" ") && !l.startsWith(" ")) {
|
|
5074
5141
|
pkg = {
|
|
5075
|
-
name: l.trim().replace(":", "")
|
|
5142
|
+
name: l.trim().replace(":", ""),
|
|
5076
5143
|
};
|
|
5077
5144
|
}
|
|
5078
5145
|
if (l.startsWith(" ")) {
|
|
@@ -5112,7 +5179,7 @@ export function parsePubYamlData(pubYamlData) {
|
|
|
5112
5179
|
name: yamlObj.name,
|
|
5113
5180
|
description: yamlObj.description,
|
|
5114
5181
|
version: yamlObj.version,
|
|
5115
|
-
homepage: { url: yamlObj.homepage }
|
|
5182
|
+
homepage: { url: yamlObj.homepage },
|
|
5116
5183
|
});
|
|
5117
5184
|
return pkgList;
|
|
5118
5185
|
}
|
|
@@ -5132,7 +5199,7 @@ export function parseHelmYamlData(helmData) {
|
|
|
5132
5199
|
const pkg = {
|
|
5133
5200
|
name: yamlObj.name,
|
|
5134
5201
|
description: yamlObj.description || "",
|
|
5135
|
-
version: yamlObj.version
|
|
5202
|
+
version: yamlObj.version,
|
|
5136
5203
|
};
|
|
5137
5204
|
if (yamlObj.home) {
|
|
5138
5205
|
pkg["homepage"] = { url: yamlObj.home };
|
|
@@ -5143,7 +5210,7 @@ export function parseHelmYamlData(helmData) {
|
|
|
5143
5210
|
for (const hd of yamlObj.dependencies) {
|
|
5144
5211
|
const pkg = {
|
|
5145
5212
|
name: hd.name,
|
|
5146
|
-
version: hd.version // This could have * so not precise
|
|
5213
|
+
version: hd.version, // This could have * so not precise
|
|
5147
5214
|
};
|
|
5148
5215
|
if (hd.repository) {
|
|
5149
5216
|
pkg["repository"] = { url: hd.repository };
|
|
@@ -5159,7 +5226,7 @@ export function parseHelmYamlData(helmData) {
|
|
|
5159
5226
|
const pkg = {
|
|
5160
5227
|
name: hd.name,
|
|
5161
5228
|
version: hd.version,
|
|
5162
|
-
description: hd.description || ""
|
|
5229
|
+
description: hd.description || "",
|
|
5163
5230
|
};
|
|
5164
5231
|
if (hd.sources && Array.isArray(hd.sources) && hd.sources.length) {
|
|
5165
5232
|
pkg["repository"] = { url: hd.sources[0] };
|
|
@@ -5202,7 +5269,12 @@ export function recurseImageNameLookup(keyValueObj, pkgList, imgList) {
|
|
|
5202
5269
|
keyValueObj.packImage ||
|
|
5203
5270
|
keyValueObj.koImage ||
|
|
5204
5271
|
keyValueObj.kanikoImage;
|
|
5205
|
-
if (
|
|
5272
|
+
if (
|
|
5273
|
+
!imageLike &&
|
|
5274
|
+
keyValueObj.name &&
|
|
5275
|
+
typeof keyValueObj.name === "string" &&
|
|
5276
|
+
keyValueObj.name.includes("/")
|
|
5277
|
+
) {
|
|
5206
5278
|
imageLike = keyValueObj.name;
|
|
5207
5279
|
}
|
|
5208
5280
|
if (
|
|
@@ -5265,14 +5337,14 @@ export function parseContainerFile(fileContents) {
|
|
|
5265
5337
|
if (buildStageNames.includes(imageStatement)) {
|
|
5266
5338
|
if (DEBUG_MODE) {
|
|
5267
5339
|
console.log(
|
|
5268
|
-
`Skipping image ${imageStatement} which uses previously seen build stage name
|
|
5340
|
+
`Skipping image ${imageStatement} which uses previously seen build stage name.`,
|
|
5269
5341
|
);
|
|
5270
5342
|
}
|
|
5271
5343
|
continue;
|
|
5272
5344
|
}
|
|
5273
5345
|
|
|
5274
5346
|
imgList.push({
|
|
5275
|
-
image: imageStatement
|
|
5347
|
+
image: imageStatement,
|
|
5276
5348
|
});
|
|
5277
5349
|
|
|
5278
5350
|
if (buildStageName) {
|
|
@@ -5300,7 +5372,7 @@ export function parseBitbucketPipelinesFile(fileContents) {
|
|
|
5300
5372
|
const imageName = line.split("name:").pop().trim();
|
|
5301
5373
|
|
|
5302
5374
|
imgList.push({
|
|
5303
|
-
image: imageName
|
|
5375
|
+
image: imageName,
|
|
5304
5376
|
});
|
|
5305
5377
|
|
|
5306
5378
|
privateImageBlockFound = false;
|
|
@@ -5324,7 +5396,7 @@ export function parseBitbucketPipelinesFile(fileContents) {
|
|
|
5324
5396
|
*/
|
|
5325
5397
|
|
|
5326
5398
|
imgList.push({
|
|
5327
|
-
image: imageName
|
|
5399
|
+
image: imageName,
|
|
5328
5400
|
});
|
|
5329
5401
|
}
|
|
5330
5402
|
}
|
|
@@ -5338,7 +5410,7 @@ export function parseBitbucketPipelinesFile(fileContents) {
|
|
|
5338
5410
|
}
|
|
5339
5411
|
|
|
5340
5412
|
imgList.push({
|
|
5341
|
-
image: pipeName
|
|
5413
|
+
image: pipeName,
|
|
5342
5414
|
});
|
|
5343
5415
|
}
|
|
5344
5416
|
}
|
|
@@ -5369,23 +5441,23 @@ export function parseContainerSpecData(dcData) {
|
|
|
5369
5441
|
if (yamlObj.services) {
|
|
5370
5442
|
for (const serv of Object.keys(yamlObj.services)) {
|
|
5371
5443
|
pkgList.push({
|
|
5372
|
-
service: serv
|
|
5444
|
+
service: serv,
|
|
5373
5445
|
});
|
|
5374
5446
|
const aservice = yamlObj.services[serv];
|
|
5375
5447
|
// Track locally built images
|
|
5376
5448
|
if (aservice.build) {
|
|
5377
5449
|
if (Object.keys(aservice.build).length && aservice.build.dockerfile) {
|
|
5378
5450
|
pkgList.push({
|
|
5379
|
-
ociSpec: aservice.build.dockerfile
|
|
5451
|
+
ociSpec: aservice.build.dockerfile,
|
|
5380
5452
|
});
|
|
5381
5453
|
} else {
|
|
5382
5454
|
if (aservice.build === "." || aservice.build === "./") {
|
|
5383
5455
|
pkgList.push({
|
|
5384
|
-
ociSpec: "Dockerfile"
|
|
5456
|
+
ociSpec: "Dockerfile",
|
|
5385
5457
|
});
|
|
5386
5458
|
} else {
|
|
5387
5459
|
pkgList.push({
|
|
5388
|
-
ociSpec: aservice.build
|
|
5460
|
+
ociSpec: aservice.build,
|
|
5389
5461
|
});
|
|
5390
5462
|
}
|
|
5391
5463
|
}
|
|
@@ -5398,7 +5470,7 @@ export function parseContainerSpecData(dcData) {
|
|
|
5398
5470
|
.replace("}", "");
|
|
5399
5471
|
}
|
|
5400
5472
|
pkgList.push({
|
|
5401
|
-
image: imgFullName
|
|
5473
|
+
image: imgFullName,
|
|
5402
5474
|
});
|
|
5403
5475
|
imgList.push(imgFullName);
|
|
5404
5476
|
}
|
|
@@ -5433,7 +5505,7 @@ function convertProcessing(processing_list) {
|
|
|
5433
5505
|
for (const p of processing_list) {
|
|
5434
5506
|
data_list.push({
|
|
5435
5507
|
classification: p.sourceId || p.sinkId,
|
|
5436
|
-
flow: identifyFlow(p)
|
|
5508
|
+
flow: identifyFlow(p),
|
|
5437
5509
|
});
|
|
5438
5510
|
}
|
|
5439
5511
|
return data_list;
|
|
@@ -5450,42 +5522,42 @@ export function parsePrivadoFile(f) {
|
|
|
5450
5522
|
"x-trust-boundary": false,
|
|
5451
5523
|
properties: [],
|
|
5452
5524
|
data: [],
|
|
5453
|
-
endpoints: []
|
|
5525
|
+
endpoints: [],
|
|
5454
5526
|
};
|
|
5455
5527
|
if (jsonData.repoName) {
|
|
5456
5528
|
aservice.name = jsonData.repoName;
|
|
5457
5529
|
aservice.properties = [
|
|
5458
5530
|
{
|
|
5459
5531
|
name: "SrcFile",
|
|
5460
|
-
value: f
|
|
5461
|
-
}
|
|
5532
|
+
value: f,
|
|
5533
|
+
},
|
|
5462
5534
|
];
|
|
5463
5535
|
// Capture git metadata info
|
|
5464
5536
|
if (jsonData.gitMetadata) {
|
|
5465
5537
|
aservice.version = jsonData.gitMetadata.commitId || "";
|
|
5466
5538
|
aservice.properties.push({
|
|
5467
5539
|
name: "privadoCoreVersion",
|
|
5468
|
-
value: jsonData.privadoCoreVersion || ""
|
|
5540
|
+
value: jsonData.privadoCoreVersion || "",
|
|
5469
5541
|
});
|
|
5470
5542
|
aservice.properties.push({
|
|
5471
5543
|
name: "privadoCLIVersion",
|
|
5472
|
-
value: jsonData.privadoCLIVersion || ""
|
|
5544
|
+
value: jsonData.privadoCLIVersion || "",
|
|
5473
5545
|
});
|
|
5474
5546
|
aservice.properties.push({
|
|
5475
5547
|
name: "localScanPath",
|
|
5476
|
-
value: jsonData.localScanPath || ""
|
|
5548
|
+
value: jsonData.localScanPath || "",
|
|
5477
5549
|
});
|
|
5478
5550
|
}
|
|
5479
5551
|
// Capture processing
|
|
5480
5552
|
if (jsonData.processing && jsonData.processing.length) {
|
|
5481
5553
|
aservice.data = aservice.data.concat(
|
|
5482
|
-
convertProcessing(jsonData.processing)
|
|
5554
|
+
convertProcessing(jsonData.processing),
|
|
5483
5555
|
);
|
|
5484
5556
|
}
|
|
5485
5557
|
// Capture sink processing
|
|
5486
5558
|
if (jsonData.sinkProcessing && jsonData.sinkProcessing.length) {
|
|
5487
5559
|
aservice.data = aservice.data.concat(
|
|
5488
|
-
convertProcessing(jsonData.sinkProcessing)
|
|
5560
|
+
convertProcessing(jsonData.sinkProcessing),
|
|
5489
5561
|
);
|
|
5490
5562
|
}
|
|
5491
5563
|
// Find endpoints
|
|
@@ -5507,7 +5579,7 @@ export function parsePrivadoFile(f) {
|
|
|
5507
5579
|
for (const v of jsonData.violations) {
|
|
5508
5580
|
aservice.properties.push({
|
|
5509
5581
|
name: "privado_violations",
|
|
5510
|
-
value: v.policyId
|
|
5582
|
+
value: v.policyId,
|
|
5511
5583
|
});
|
|
5512
5584
|
}
|
|
5513
5585
|
}
|
|
@@ -5549,7 +5621,7 @@ export function parseOpenapiSpecData(oaData) {
|
|
|
5549
5621
|
"bom-ref": `urn:service:${name}:${version}`,
|
|
5550
5622
|
name,
|
|
5551
5623
|
description: oaData.description || "",
|
|
5552
|
-
version
|
|
5624
|
+
version,
|
|
5553
5625
|
};
|
|
5554
5626
|
let serverName = [];
|
|
5555
5627
|
if (oaData.servers && oaData.servers.length && oaData.servers[0].url) {
|
|
@@ -5598,7 +5670,7 @@ export function parseCabalData(cabalData) {
|
|
|
5598
5670
|
if (name && version) {
|
|
5599
5671
|
pkgList.push({
|
|
5600
5672
|
name,
|
|
5601
|
-
version
|
|
5673
|
+
version,
|
|
5602
5674
|
});
|
|
5603
5675
|
}
|
|
5604
5676
|
}
|
|
@@ -5624,7 +5696,7 @@ export function parseMixLockData(mixData) {
|
|
|
5624
5696
|
if (name && version) {
|
|
5625
5697
|
pkgList.push({
|
|
5626
5698
|
name,
|
|
5627
|
-
version
|
|
5699
|
+
version,
|
|
5628
5700
|
});
|
|
5629
5701
|
}
|
|
5630
5702
|
}
|
|
@@ -5664,7 +5736,7 @@ export function parseGitHubWorkflowData(ghwData) {
|
|
|
5664
5736
|
pkgList.push({
|
|
5665
5737
|
group,
|
|
5666
5738
|
name,
|
|
5667
|
-
version
|
|
5739
|
+
version,
|
|
5668
5740
|
});
|
|
5669
5741
|
}
|
|
5670
5742
|
}
|
|
@@ -5702,7 +5774,7 @@ export function parseCloudBuildData(cbwData) {
|
|
|
5702
5774
|
pkgList.push({
|
|
5703
5775
|
group,
|
|
5704
5776
|
name,
|
|
5705
|
-
version
|
|
5777
|
+
version,
|
|
5706
5778
|
});
|
|
5707
5779
|
}
|
|
5708
5780
|
}
|
|
@@ -5738,13 +5810,13 @@ export function parseConanLockData(conanLockData) {
|
|
|
5738
5810
|
tmpA[0],
|
|
5739
5811
|
version,
|
|
5740
5812
|
null,
|
|
5741
|
-
null
|
|
5813
|
+
null,
|
|
5742
5814
|
).toString();
|
|
5743
5815
|
pkgList.push({
|
|
5744
5816
|
name: tmpA[0],
|
|
5745
5817
|
version,
|
|
5746
5818
|
purl: purlString,
|
|
5747
|
-
"bom-ref": decodeURIComponent(purlString)
|
|
5819
|
+
"bom-ref": decodeURIComponent(purlString),
|
|
5748
5820
|
});
|
|
5749
5821
|
}
|
|
5750
5822
|
}
|
|
@@ -5792,14 +5864,14 @@ export function parseConanData(conanData) {
|
|
|
5792
5864
|
tmpA[0],
|
|
5793
5865
|
version,
|
|
5794
5866
|
qualifiers,
|
|
5795
|
-
null
|
|
5867
|
+
null,
|
|
5796
5868
|
).toString();
|
|
5797
5869
|
pkgList.push({
|
|
5798
5870
|
name: tmpA[0],
|
|
5799
5871
|
version,
|
|
5800
5872
|
purl: purlString,
|
|
5801
5873
|
"bom-ref": decodeURIComponent(purlString),
|
|
5802
|
-
scope
|
|
5874
|
+
scope,
|
|
5803
5875
|
});
|
|
5804
5876
|
}
|
|
5805
5877
|
}
|
|
@@ -5915,7 +5987,7 @@ export function parseNuspecData(nupkgFile, nuspecData) {
|
|
|
5915
5987
|
spaces: 4,
|
|
5916
5988
|
textKey: "_",
|
|
5917
5989
|
attributesKey: "$",
|
|
5918
|
-
commentKey: "value"
|
|
5990
|
+
commentKey: "value",
|
|
5919
5991
|
}).package;
|
|
5920
5992
|
} catch (e) {
|
|
5921
5993
|
// If we are parsing with invalid encoding, unicode replacement character is used
|
|
@@ -5923,7 +5995,7 @@ export function parseNuspecData(nupkgFile, nuspecData) {
|
|
|
5923
5995
|
console.log(`Unable to parse ${nupkgFile} in utf-8 mode`);
|
|
5924
5996
|
} else {
|
|
5925
5997
|
console.log(
|
|
5926
|
-
"Unable to parse this package. Tried utf-8 and ucs2 encoding."
|
|
5998
|
+
"Unable to parse this package. Tried utf-8 and ucs2 encoding.",
|
|
5927
5999
|
);
|
|
5928
6000
|
}
|
|
5929
6001
|
}
|
|
@@ -5937,8 +6009,8 @@ export function parseNuspecData(nupkgFile, nuspecData) {
|
|
|
5937
6009
|
pkg.properties = [
|
|
5938
6010
|
{
|
|
5939
6011
|
name: "SrcFile",
|
|
5940
|
-
value: nupkgFile
|
|
5941
|
-
}
|
|
6012
|
+
value: nupkgFile,
|
|
6013
|
+
},
|
|
5942
6014
|
];
|
|
5943
6015
|
pkg.evidence = {
|
|
5944
6016
|
identity: {
|
|
@@ -5948,10 +6020,10 @@ export function parseNuspecData(nupkgFile, nuspecData) {
|
|
|
5948
6020
|
{
|
|
5949
6021
|
technique: "binary-analysis",
|
|
5950
6022
|
confidence: 1,
|
|
5951
|
-
value: nupkgFile
|
|
5952
|
-
}
|
|
5953
|
-
]
|
|
5954
|
-
}
|
|
6023
|
+
value: nupkgFile,
|
|
6024
|
+
},
|
|
6025
|
+
],
|
|
6026
|
+
},
|
|
5955
6027
|
};
|
|
5956
6028
|
pkgList.push(pkg);
|
|
5957
6029
|
return pkgList;
|
|
@@ -5968,7 +6040,7 @@ export function parseCsPkgData(pkgData) {
|
|
|
5968
6040
|
spaces: 4,
|
|
5969
6041
|
textKey: "_",
|
|
5970
6042
|
attributesKey: "$",
|
|
5971
|
-
commentKey: "value"
|
|
6043
|
+
commentKey: "value",
|
|
5972
6044
|
}).packages;
|
|
5973
6045
|
if (!packages || packages.length == 0) {
|
|
5974
6046
|
return pkgList;
|
|
@@ -5995,7 +6067,7 @@ export function parseCsProjData(csProjData, projFile) {
|
|
|
5995
6067
|
spaces: 4,
|
|
5996
6068
|
textKey: "_",
|
|
5997
6069
|
attributesKey: "$",
|
|
5998
|
-
commentKey: "value"
|
|
6070
|
+
commentKey: "value",
|
|
5999
6071
|
}).Project;
|
|
6000
6072
|
if (!projects || projects.length == 0) {
|
|
6001
6073
|
return pkgList;
|
|
@@ -6017,8 +6089,8 @@ export function parseCsProjData(csProjData, projFile) {
|
|
|
6017
6089
|
pkg.properties = [
|
|
6018
6090
|
{
|
|
6019
6091
|
name: "SrcFile",
|
|
6020
|
-
value: projFile
|
|
6021
|
-
}
|
|
6092
|
+
value: projFile,
|
|
6093
|
+
},
|
|
6022
6094
|
];
|
|
6023
6095
|
pkg.evidence = {
|
|
6024
6096
|
identity: {
|
|
@@ -6028,10 +6100,10 @@ export function parseCsProjData(csProjData, projFile) {
|
|
|
6028
6100
|
{
|
|
6029
6101
|
technique: "manifest-analysis",
|
|
6030
6102
|
confidence: 0.7,
|
|
6031
|
-
value: projFile
|
|
6032
|
-
}
|
|
6033
|
-
]
|
|
6034
|
-
}
|
|
6103
|
+
value: projFile,
|
|
6104
|
+
},
|
|
6105
|
+
],
|
|
6106
|
+
},
|
|
6035
6107
|
};
|
|
6036
6108
|
}
|
|
6037
6109
|
pkgList.push(pkg);
|
|
@@ -6052,8 +6124,8 @@ export function parseCsProjData(csProjData, projFile) {
|
|
|
6052
6124
|
pkg.properties = [
|
|
6053
6125
|
{
|
|
6054
6126
|
name: "SrcFile",
|
|
6055
|
-
value: projFile
|
|
6056
|
-
}
|
|
6127
|
+
value: projFile,
|
|
6128
|
+
},
|
|
6057
6129
|
];
|
|
6058
6130
|
pkg.evidence = {
|
|
6059
6131
|
identity: {
|
|
@@ -6063,10 +6135,10 @@ export function parseCsProjData(csProjData, projFile) {
|
|
|
6063
6135
|
{
|
|
6064
6136
|
technique: "manifest-analysis",
|
|
6065
6137
|
confidence: 0.7,
|
|
6066
|
-
value: projFile
|
|
6067
|
-
}
|
|
6068
|
-
]
|
|
6069
|
-
}
|
|
6138
|
+
value: projFile,
|
|
6139
|
+
},
|
|
6140
|
+
],
|
|
6141
|
+
},
|
|
6070
6142
|
};
|
|
6071
6143
|
}
|
|
6072
6144
|
pkgList.push(pkg);
|
|
@@ -6087,7 +6159,7 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6087
6159
|
return {
|
|
6088
6160
|
name: match[1],
|
|
6089
6161
|
operator: match[2],
|
|
6090
|
-
version: match[3]
|
|
6162
|
+
version: match[3],
|
|
6091
6163
|
};
|
|
6092
6164
|
} else {
|
|
6093
6165
|
return null;
|
|
@@ -6111,7 +6183,7 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6111
6183
|
csProjData.project.restore.projectName,
|
|
6112
6184
|
csProjData.project.version || "latest",
|
|
6113
6185
|
null,
|
|
6114
|
-
null
|
|
6186
|
+
null,
|
|
6115
6187
|
).toString();
|
|
6116
6188
|
rootPkg = {
|
|
6117
6189
|
group: "",
|
|
@@ -6119,7 +6191,7 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6119
6191
|
version: csProjData.project.version || "latest",
|
|
6120
6192
|
type: "application",
|
|
6121
6193
|
purl: purlString,
|
|
6122
|
-
"bom-ref": decodeURIComponent(purlString)
|
|
6194
|
+
"bom-ref": decodeURIComponent(purlString),
|
|
6123
6195
|
};
|
|
6124
6196
|
pkgList.push(rootPkg);
|
|
6125
6197
|
const rootPkgDeps = new Set();
|
|
@@ -6148,8 +6220,8 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6148
6220
|
nameOperatorVersion.name,
|
|
6149
6221
|
nameOperatorVersion.version,
|
|
6150
6222
|
null,
|
|
6151
|
-
null
|
|
6152
|
-
).toString()
|
|
6223
|
+
null,
|
|
6224
|
+
).toString(),
|
|
6153
6225
|
);
|
|
6154
6226
|
rootPkgDeps.add(dpurl);
|
|
6155
6227
|
}
|
|
@@ -6157,7 +6229,7 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6157
6229
|
|
|
6158
6230
|
dependenciesList.push({
|
|
6159
6231
|
ref: purlString,
|
|
6160
|
-
dependsOn: Array.from(rootPkgDeps)
|
|
6232
|
+
dependsOn: Array.from(rootPkgDeps),
|
|
6161
6233
|
});
|
|
6162
6234
|
}
|
|
6163
6235
|
|
|
@@ -6176,7 +6248,7 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6176
6248
|
name,
|
|
6177
6249
|
version,
|
|
6178
6250
|
null,
|
|
6179
|
-
null
|
|
6251
|
+
null,
|
|
6180
6252
|
).toString();
|
|
6181
6253
|
const pkg = {
|
|
6182
6254
|
group: "",
|
|
@@ -6185,7 +6257,7 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6185
6257
|
description: "",
|
|
6186
6258
|
type: csProjData.targets[framework][rootDep].type,
|
|
6187
6259
|
purl: dpurl,
|
|
6188
|
-
"bom-ref": decodeURIComponent(dpurl)
|
|
6260
|
+
"bom-ref": decodeURIComponent(dpurl),
|
|
6189
6261
|
};
|
|
6190
6262
|
if (lib[rootDep]) {
|
|
6191
6263
|
if (lib[rootDep].sha512) {
|
|
@@ -6207,12 +6279,12 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6207
6279
|
pkg.properties = [
|
|
6208
6280
|
{
|
|
6209
6281
|
name: "SrcFile",
|
|
6210
|
-
value: assetsJsonFile
|
|
6282
|
+
value: assetsJsonFile,
|
|
6211
6283
|
},
|
|
6212
6284
|
{
|
|
6213
6285
|
name: "PackageFiles",
|
|
6214
|
-
value: Array.from(dllFiles).join(", ")
|
|
6215
|
-
}
|
|
6286
|
+
value: Array.from(dllFiles).join(", "),
|
|
6287
|
+
},
|
|
6216
6288
|
];
|
|
6217
6289
|
}
|
|
6218
6290
|
}
|
|
@@ -6225,10 +6297,10 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6225
6297
|
{
|
|
6226
6298
|
technique: "manifest-analysis",
|
|
6227
6299
|
confidence: 1,
|
|
6228
|
-
value: assetsJsonFile
|
|
6229
|
-
}
|
|
6230
|
-
]
|
|
6231
|
-
}
|
|
6300
|
+
value: assetsJsonFile,
|
|
6301
|
+
},
|
|
6302
|
+
],
|
|
6303
|
+
},
|
|
6232
6304
|
};
|
|
6233
6305
|
}
|
|
6234
6306
|
pkgList.push(pkg);
|
|
@@ -6242,7 +6314,7 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6242
6314
|
const depList = new Set();
|
|
6243
6315
|
const [name, version] = rootDep.split("/");
|
|
6244
6316
|
const dpurl = decodeURIComponent(
|
|
6245
|
-
new PackageURL("nuget", "", name, version, null, null).toString()
|
|
6317
|
+
new PackageURL("nuget", "", name, version, null, null).toString(),
|
|
6246
6318
|
);
|
|
6247
6319
|
const dependencies =
|
|
6248
6320
|
csProjData.targets[framework][rootDep].dependencies;
|
|
@@ -6259,7 +6331,7 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6259
6331
|
p,
|
|
6260
6332
|
dversion,
|
|
6261
6333
|
null,
|
|
6262
|
-
null
|
|
6334
|
+
null,
|
|
6263
6335
|
).toString();
|
|
6264
6336
|
depList.add(ipurl);
|
|
6265
6337
|
if (!pkgAddedMap[p]) {
|
|
@@ -6269,7 +6341,7 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6269
6341
|
version: dversion,
|
|
6270
6342
|
description: "",
|
|
6271
6343
|
purl: ipurl,
|
|
6272
|
-
"bom-ref": decodeURIComponent(ipurl)
|
|
6344
|
+
"bom-ref": decodeURIComponent(ipurl),
|
|
6273
6345
|
});
|
|
6274
6346
|
pkgAddedMap[p] = true;
|
|
6275
6347
|
}
|
|
@@ -6277,14 +6349,14 @@ export function parseCsProjAssetsData(csProjData, assetsJsonFile) {
|
|
|
6277
6349
|
}
|
|
6278
6350
|
dependenciesList.push({
|
|
6279
6351
|
ref: dpurl,
|
|
6280
|
-
dependsOn: Array.from(depList)
|
|
6352
|
+
dependsOn: Array.from(depList),
|
|
6281
6353
|
});
|
|
6282
6354
|
}
|
|
6283
6355
|
}
|
|
6284
6356
|
}
|
|
6285
6357
|
return {
|
|
6286
6358
|
pkgList,
|
|
6287
|
-
dependenciesList
|
|
6359
|
+
dependenciesList,
|
|
6288
6360
|
};
|
|
6289
6361
|
}
|
|
6290
6362
|
|
|
@@ -6297,7 +6369,7 @@ export function parseCsPkgLockData(csLockData, pkgLockFile) {
|
|
|
6297
6369
|
return {
|
|
6298
6370
|
pkgList,
|
|
6299
6371
|
dependenciesList,
|
|
6300
|
-
rootList
|
|
6372
|
+
rootList,
|
|
6301
6373
|
};
|
|
6302
6374
|
}
|
|
6303
6375
|
const assetData = JSON.parse(csLockData);
|
|
@@ -6305,7 +6377,7 @@ export function parseCsPkgLockData(csLockData, pkgLockFile) {
|
|
|
6305
6377
|
return {
|
|
6306
6378
|
pkgList,
|
|
6307
6379
|
dependenciesList,
|
|
6308
|
-
rootList
|
|
6380
|
+
rootList,
|
|
6309
6381
|
};
|
|
6310
6382
|
}
|
|
6311
6383
|
for (const aversion of Object.keys(assetData.dependencies)) {
|
|
@@ -6317,7 +6389,7 @@ export function parseCsPkgLockData(csLockData, pkgLockFile) {
|
|
|
6317
6389
|
alib,
|
|
6318
6390
|
libData.resolved,
|
|
6319
6391
|
null,
|
|
6320
|
-
null
|
|
6392
|
+
null,
|
|
6321
6393
|
).toString();
|
|
6322
6394
|
pkg = {
|
|
6323
6395
|
group: "",
|
|
@@ -6331,8 +6403,8 @@ export function parseCsPkgLockData(csLockData, pkgLockFile) {
|
|
|
6331
6403
|
properties: [
|
|
6332
6404
|
{
|
|
6333
6405
|
name: "SrcFile",
|
|
6334
|
-
value: pkgLockFile
|
|
6335
|
-
}
|
|
6406
|
+
value: pkgLockFile,
|
|
6407
|
+
},
|
|
6336
6408
|
],
|
|
6337
6409
|
evidence: {
|
|
6338
6410
|
identity: {
|
|
@@ -6342,11 +6414,11 @@ export function parseCsPkgLockData(csLockData, pkgLockFile) {
|
|
|
6342
6414
|
{
|
|
6343
6415
|
technique: "manifest-analysis",
|
|
6344
6416
|
confidence: 1,
|
|
6345
|
-
value: pkgLockFile
|
|
6346
|
-
}
|
|
6347
|
-
]
|
|
6348
|
-
}
|
|
6349
|
-
}
|
|
6417
|
+
value: pkgLockFile,
|
|
6418
|
+
},
|
|
6419
|
+
],
|
|
6420
|
+
},
|
|
6421
|
+
},
|
|
6350
6422
|
};
|
|
6351
6423
|
pkgList.push(pkg);
|
|
6352
6424
|
if (["Direct", "Project"].includes(libData.type)) {
|
|
@@ -6387,7 +6459,7 @@ export function parseCsPkgLockData(csLockData, pkgLockFile) {
|
|
|
6387
6459
|
adep = adep.toLowerCase();
|
|
6388
6460
|
} else if (DEBUG_MODE) {
|
|
6389
6461
|
console.warn(
|
|
6390
|
-
`Unable to find the resolved version for ${adep} ${aversion}. Using ${adepResolvedVersion} which may be incorrect
|
|
6462
|
+
`Unable to find the resolved version for ${adep} ${aversion}. Using ${adepResolvedVersion} which may be incorrect.`,
|
|
6391
6463
|
);
|
|
6392
6464
|
}
|
|
6393
6465
|
const adpurl = new PackageURL(
|
|
@@ -6396,21 +6468,21 @@ export function parseCsPkgLockData(csLockData, pkgLockFile) {
|
|
|
6396
6468
|
adep,
|
|
6397
6469
|
adepResolvedVersion,
|
|
6398
6470
|
null,
|
|
6399
|
-
null
|
|
6471
|
+
null,
|
|
6400
6472
|
).toString();
|
|
6401
6473
|
dependsOn.push(decodeURIComponent(adpurl));
|
|
6402
6474
|
}
|
|
6403
6475
|
}
|
|
6404
6476
|
dependenciesList.push({
|
|
6405
6477
|
ref: decodeURIComponent(purl),
|
|
6406
|
-
dependsOn
|
|
6478
|
+
dependsOn,
|
|
6407
6479
|
});
|
|
6408
6480
|
}
|
|
6409
6481
|
}
|
|
6410
6482
|
return {
|
|
6411
6483
|
pkgList,
|
|
6412
6484
|
dependenciesList,
|
|
6413
|
-
rootList
|
|
6485
|
+
rootList,
|
|
6414
6486
|
};
|
|
6415
6487
|
}
|
|
6416
6488
|
|
|
@@ -6448,7 +6520,7 @@ export function parsePaketLockData(paketLockData, pkgLockFile) {
|
|
|
6448
6520
|
name,
|
|
6449
6521
|
version,
|
|
6450
6522
|
null,
|
|
6451
|
-
null
|
|
6523
|
+
null,
|
|
6452
6524
|
).toString();
|
|
6453
6525
|
pkg = {
|
|
6454
6526
|
group: "",
|
|
@@ -6459,8 +6531,8 @@ export function parsePaketLockData(paketLockData, pkgLockFile) {
|
|
|
6459
6531
|
properties: [
|
|
6460
6532
|
{
|
|
6461
6533
|
name: "SrcFile",
|
|
6462
|
-
value: pkgLockFile
|
|
6463
|
-
}
|
|
6534
|
+
value: pkgLockFile,
|
|
6535
|
+
},
|
|
6464
6536
|
],
|
|
6465
6537
|
evidence: {
|
|
6466
6538
|
identity: {
|
|
@@ -6470,11 +6542,11 @@ export function parsePaketLockData(paketLockData, pkgLockFile) {
|
|
|
6470
6542
|
{
|
|
6471
6543
|
technique: "manifest-analysis",
|
|
6472
6544
|
confidence: 1,
|
|
6473
|
-
value: pkgLockFile
|
|
6474
|
-
}
|
|
6475
|
-
]
|
|
6476
|
-
}
|
|
6477
|
-
}
|
|
6545
|
+
value: pkgLockFile,
|
|
6546
|
+
},
|
|
6547
|
+
],
|
|
6548
|
+
},
|
|
6549
|
+
},
|
|
6478
6550
|
};
|
|
6479
6551
|
pkgList.push(pkg);
|
|
6480
6552
|
dependenciesMap[purl] = new Set();
|
|
@@ -6498,7 +6570,7 @@ export function parsePaketLockData(paketLockData, pkgLockFile) {
|
|
|
6498
6570
|
const pkgName = match[1];
|
|
6499
6571
|
const pkgVersion = match[2];
|
|
6500
6572
|
purl = decodeURIComponent(
|
|
6501
|
-
new PackageURL("nuget", "", pkgName, pkgVersion, null, null).toString()
|
|
6573
|
+
new PackageURL("nuget", "", pkgName, pkgVersion, null, null).toString(),
|
|
6502
6574
|
);
|
|
6503
6575
|
return;
|
|
6504
6576
|
}
|
|
@@ -6508,7 +6580,7 @@ export function parsePaketLockData(paketLockData, pkgLockFile) {
|
|
|
6508
6580
|
const depName = match[1];
|
|
6509
6581
|
const depVersion = pkgNameVersionMap[depName + group];
|
|
6510
6582
|
const dpurl = decodeURIComponent(
|
|
6511
|
-
new PackageURL("nuget", "", depName, depVersion, null, null).toString()
|
|
6583
|
+
new PackageURL("nuget", "", depName, depVersion, null, null).toString(),
|
|
6512
6584
|
);
|
|
6513
6585
|
dependenciesMap[purl].add(dpurl);
|
|
6514
6586
|
}
|
|
@@ -6517,13 +6589,13 @@ export function parsePaketLockData(paketLockData, pkgLockFile) {
|
|
|
6517
6589
|
for (const ref in dependenciesMap) {
|
|
6518
6590
|
dependenciesList.push({
|
|
6519
6591
|
ref: ref,
|
|
6520
|
-
dependsOn: Array.from(dependenciesMap[ref])
|
|
6592
|
+
dependsOn: Array.from(dependenciesMap[ref]),
|
|
6521
6593
|
});
|
|
6522
6594
|
}
|
|
6523
6595
|
|
|
6524
6596
|
return {
|
|
6525
6597
|
pkgList,
|
|
6526
|
-
dependenciesList
|
|
6598
|
+
dependenciesList,
|
|
6527
6599
|
};
|
|
6528
6600
|
}
|
|
6529
6601
|
|
|
@@ -6581,7 +6653,7 @@ export function parseComposerLock(pkgLockFile, rootRequires) {
|
|
|
6581
6653
|
name,
|
|
6582
6654
|
pkg.version,
|
|
6583
6655
|
null,
|
|
6584
|
-
null
|
|
6656
|
+
null,
|
|
6585
6657
|
).toString();
|
|
6586
6658
|
const apkg = {
|
|
6587
6659
|
group: group,
|
|
@@ -6596,8 +6668,8 @@ export function parseComposerLock(pkgLockFile, rootRequires) {
|
|
|
6596
6668
|
properties: [
|
|
6597
6669
|
{
|
|
6598
6670
|
name: "SrcFile",
|
|
6599
|
-
value: pkgLockFile
|
|
6600
|
-
}
|
|
6671
|
+
value: pkgLockFile,
|
|
6672
|
+
},
|
|
6601
6673
|
],
|
|
6602
6674
|
evidence: {
|
|
6603
6675
|
identity: {
|
|
@@ -6607,11 +6679,11 @@ export function parseComposerLock(pkgLockFile, rootRequires) {
|
|
|
6607
6679
|
{
|
|
6608
6680
|
technique: "manifest-analysis",
|
|
6609
6681
|
confidence: 1,
|
|
6610
|
-
value: pkgLockFile
|
|
6611
|
-
}
|
|
6612
|
-
]
|
|
6613
|
-
}
|
|
6614
|
-
}
|
|
6682
|
+
value: pkgLockFile,
|
|
6683
|
+
},
|
|
6684
|
+
],
|
|
6685
|
+
},
|
|
6686
|
+
},
|
|
6615
6687
|
};
|
|
6616
6688
|
if (pkg.autoload && Object.keys(pkg.autoload).length) {
|
|
6617
6689
|
const namespaces = [];
|
|
@@ -6625,7 +6697,7 @@ export function parseComposerLock(pkgLockFile, rootRequires) {
|
|
|
6625
6697
|
if (namespaces.length) {
|
|
6626
6698
|
apkg.properties.push({
|
|
6627
6699
|
name: "Namespaces",
|
|
6628
|
-
value: namespaces.join(", ")
|
|
6700
|
+
value: namespaces.join(", "),
|
|
6629
6701
|
});
|
|
6630
6702
|
}
|
|
6631
6703
|
}
|
|
@@ -6661,13 +6733,13 @@ export function parseComposerLock(pkgLockFile, rootRequires) {
|
|
|
6661
6733
|
for (const ref in dependenciesMap) {
|
|
6662
6734
|
dependenciesList.push({
|
|
6663
6735
|
ref: ref,
|
|
6664
|
-
dependsOn: Array.from(dependenciesMap[ref])
|
|
6736
|
+
dependsOn: Array.from(dependenciesMap[ref]),
|
|
6665
6737
|
});
|
|
6666
6738
|
}
|
|
6667
6739
|
return {
|
|
6668
6740
|
pkgList,
|
|
6669
6741
|
dependenciesList,
|
|
6670
|
-
rootList
|
|
6742
|
+
rootList,
|
|
6671
6743
|
};
|
|
6672
6744
|
}
|
|
6673
6745
|
|
|
@@ -6726,7 +6798,7 @@ export function parseSbtTree(sbtTreeFile) {
|
|
|
6726
6798
|
name,
|
|
6727
6799
|
version,
|
|
6728
6800
|
{ type: "jar" },
|
|
6729
|
-
null
|
|
6801
|
+
null,
|
|
6730
6802
|
).toString();
|
|
6731
6803
|
// Filter duplicates
|
|
6732
6804
|
if (!keys_cache[purlString]) {
|
|
@@ -6744,11 +6816,11 @@ export function parseSbtTree(sbtTreeFile) {
|
|
|
6744
6816
|
{
|
|
6745
6817
|
technique: "manifest-analysis",
|
|
6746
6818
|
confidence: 1,
|
|
6747
|
-
value: sbtTreeFile
|
|
6748
|
-
}
|
|
6749
|
-
]
|
|
6750
|
-
}
|
|
6751
|
-
}
|
|
6819
|
+
value: sbtTreeFile,
|
|
6820
|
+
},
|
|
6821
|
+
],
|
|
6822
|
+
},
|
|
6823
|
+
},
|
|
6752
6824
|
};
|
|
6753
6825
|
if (isLibrary) {
|
|
6754
6826
|
adep["type"] = "library";
|
|
@@ -6794,7 +6866,7 @@ export function parseSbtTree(sbtTreeFile) {
|
|
|
6794
6866
|
for (const lk of Object.keys(level_trees)) {
|
|
6795
6867
|
dependenciesList.push({
|
|
6796
6868
|
ref: lk,
|
|
6797
|
-
dependsOn: level_trees[lk]
|
|
6869
|
+
dependsOn: level_trees[lk],
|
|
6798
6870
|
});
|
|
6799
6871
|
}
|
|
6800
6872
|
return { pkgList, dependenciesList };
|
|
@@ -6809,7 +6881,7 @@ export function parseSbtLock(pkgLockFile) {
|
|
|
6809
6881
|
const pkgList = [];
|
|
6810
6882
|
if (existsSync(pkgLockFile)) {
|
|
6811
6883
|
const lockData = JSON.parse(
|
|
6812
|
-
readFileSync(pkgLockFile, { encoding: "utf-8" })
|
|
6884
|
+
readFileSync(pkgLockFile, { encoding: "utf-8" }),
|
|
6813
6885
|
);
|
|
6814
6886
|
if (lockData && lockData.dependencies) {
|
|
6815
6887
|
for (const pkg of lockData.dependencies) {
|
|
@@ -6835,8 +6907,8 @@ export function parseSbtLock(pkgLockFile) {
|
|
|
6835
6907
|
properties: [
|
|
6836
6908
|
{
|
|
6837
6909
|
name: "SrcFile",
|
|
6838
|
-
value: pkgLockFile
|
|
6839
|
-
}
|
|
6910
|
+
value: pkgLockFile,
|
|
6911
|
+
},
|
|
6840
6912
|
],
|
|
6841
6913
|
evidence: {
|
|
6842
6914
|
identity: {
|
|
@@ -6846,11 +6918,11 @@ export function parseSbtLock(pkgLockFile) {
|
|
|
6846
6918
|
{
|
|
6847
6919
|
technique: "manifest-analysis",
|
|
6848
6920
|
confidence: 1,
|
|
6849
|
-
value: pkgLockFile
|
|
6850
|
-
}
|
|
6851
|
-
]
|
|
6852
|
-
}
|
|
6853
|
-
}
|
|
6921
|
+
value: pkgLockFile,
|
|
6922
|
+
},
|
|
6923
|
+
],
|
|
6924
|
+
},
|
|
6925
|
+
},
|
|
6854
6926
|
});
|
|
6855
6927
|
}
|
|
6856
6928
|
}
|
|
@@ -6883,7 +6955,7 @@ function convertStdoutToList(result) {
|
|
|
6883
6955
|
*/
|
|
6884
6956
|
export function executeDpkgList(pkgName) {
|
|
6885
6957
|
const result = spawnSync("dpkg", ["--listfiles", "--no-pager", pkgName], {
|
|
6886
|
-
encoding: "utf-8"
|
|
6958
|
+
encoding: "utf-8",
|
|
6887
6959
|
});
|
|
6888
6960
|
return convertStdoutToList(result);
|
|
6889
6961
|
}
|
|
@@ -6896,12 +6968,12 @@ export function executeDpkgList(pkgName) {
|
|
|
6896
6968
|
*/
|
|
6897
6969
|
export function executeRpmList(pkgName) {
|
|
6898
6970
|
let result = spawnSync("dnf", ["repoquery", "-l", pkgName], {
|
|
6899
|
-
encoding: "utf-8"
|
|
6971
|
+
encoding: "utf-8",
|
|
6900
6972
|
});
|
|
6901
6973
|
// Fallback to rpm
|
|
6902
6974
|
if (result.status !== 0 || result.error) {
|
|
6903
6975
|
result = spawnSync("rpm", ["-ql", pkgName], {
|
|
6904
|
-
encoding: "utf-8"
|
|
6976
|
+
encoding: "utf-8",
|
|
6905
6977
|
});
|
|
6906
6978
|
}
|
|
6907
6979
|
return convertStdoutToList(result);
|
|
@@ -6915,7 +6987,7 @@ export function executeRpmList(pkgName) {
|
|
|
6915
6987
|
*/
|
|
6916
6988
|
export function executeApkList(pkgName) {
|
|
6917
6989
|
const result = spawnSync("apk", ["-L", "info", pkgName], {
|
|
6918
|
-
encoding: "utf-8"
|
|
6990
|
+
encoding: "utf-8",
|
|
6919
6991
|
});
|
|
6920
6992
|
return convertStdoutToList(result);
|
|
6921
6993
|
}
|
|
@@ -6928,7 +7000,7 @@ export function executeApkList(pkgName) {
|
|
|
6928
7000
|
*/
|
|
6929
7001
|
export function executeAlpmList(pkgName) {
|
|
6930
7002
|
const result = spawnSync("pacman", ["-Ql", pkgName], {
|
|
6931
|
-
encoding: "utf-8"
|
|
7003
|
+
encoding: "utf-8",
|
|
6932
7004
|
});
|
|
6933
7005
|
return convertStdoutToList(result);
|
|
6934
7006
|
}
|
|
@@ -6941,7 +7013,7 @@ export function executeAlpmList(pkgName) {
|
|
|
6941
7013
|
*/
|
|
6942
7014
|
export function executeEqueryList(pkgName) {
|
|
6943
7015
|
const result = spawnSync("equery", ["files", pkgName], {
|
|
6944
|
-
encoding: "utf-8"
|
|
7016
|
+
encoding: "utf-8",
|
|
6945
7017
|
});
|
|
6946
7018
|
return convertStdoutToList(result);
|
|
6947
7019
|
}
|
|
@@ -6958,7 +7030,7 @@ export function convertOSQueryResults(
|
|
|
6958
7030
|
queryCategory,
|
|
6959
7031
|
queryObj,
|
|
6960
7032
|
results,
|
|
6961
|
-
enhance = false
|
|
7033
|
+
enhance = false,
|
|
6962
7034
|
) {
|
|
6963
7035
|
const pkgList = [];
|
|
6964
7036
|
if (results && results.length) {
|
|
@@ -7018,7 +7090,7 @@ export function convertOSQueryResults(
|
|
|
7018
7090
|
let qualifiers = undefined;
|
|
7019
7091
|
if (res.identifying_number && res.identifying_number.length) {
|
|
7020
7092
|
qualifiers = {
|
|
7021
|
-
tag_id: res.identifying_number.replace("{", "").replace("}", "")
|
|
7093
|
+
tag_id: res.identifying_number.replace("{", "").replace("}", ""),
|
|
7022
7094
|
};
|
|
7023
7095
|
}
|
|
7024
7096
|
if (name) {
|
|
@@ -7038,7 +7110,7 @@ export function convertOSQueryResults(
|
|
|
7038
7110
|
name,
|
|
7039
7111
|
version || "",
|
|
7040
7112
|
qualifiers,
|
|
7041
|
-
subpath
|
|
7113
|
+
subpath,
|
|
7042
7114
|
).toString();
|
|
7043
7115
|
const props = [{ name: "cdx:osquery:category", value: queryCategory }];
|
|
7044
7116
|
let providesList = undefined;
|
|
@@ -7075,15 +7147,15 @@ export function convertOSQueryResults(
|
|
|
7075
7147
|
"bom-ref": decodeURIComponent(purl),
|
|
7076
7148
|
purl,
|
|
7077
7149
|
scope,
|
|
7078
|
-
type: queryObj.componentType
|
|
7150
|
+
type: queryObj.componentType,
|
|
7079
7151
|
};
|
|
7080
7152
|
for (const k of Object.keys(res).filter(
|
|
7081
|
-
(p) => !["name", "version", "description", "publisher"].includes(p)
|
|
7153
|
+
(p) => !["name", "version", "description", "publisher"].includes(p),
|
|
7082
7154
|
)) {
|
|
7083
7155
|
if (res[k] && res[k] !== "null") {
|
|
7084
7156
|
props.push({
|
|
7085
7157
|
name: k,
|
|
7086
|
-
value: res[k]
|
|
7158
|
+
value: res[k],
|
|
7087
7159
|
});
|
|
7088
7160
|
}
|
|
7089
7161
|
}
|
|
@@ -7145,7 +7217,7 @@ export function parseSwiftJsonTreeObject(
|
|
|
7145
7217
|
pkgList,
|
|
7146
7218
|
dependenciesList,
|
|
7147
7219
|
jsonObject,
|
|
7148
|
-
pkgFile
|
|
7220
|
+
pkgFile,
|
|
7149
7221
|
) {
|
|
7150
7222
|
const urlOrPath = jsonObject.url || jsonObject.path;
|
|
7151
7223
|
const version = jsonObject.version;
|
|
@@ -7156,7 +7228,7 @@ export function parseSwiftJsonTreeObject(
|
|
|
7156
7228
|
group: purl.namespace,
|
|
7157
7229
|
version: purl.version,
|
|
7158
7230
|
purl: purlString,
|
|
7159
|
-
"bom-ref": purlString
|
|
7231
|
+
"bom-ref": purlString,
|
|
7160
7232
|
};
|
|
7161
7233
|
if (urlOrPath) {
|
|
7162
7234
|
if (urlOrPath.startsWith("http")) {
|
|
@@ -7165,12 +7237,12 @@ export function parseSwiftJsonTreeObject(
|
|
|
7165
7237
|
const properties = [];
|
|
7166
7238
|
properties.push({
|
|
7167
7239
|
name: "SrcPath",
|
|
7168
|
-
value: urlOrPath
|
|
7240
|
+
value: urlOrPath,
|
|
7169
7241
|
});
|
|
7170
7242
|
if (pkgFile) {
|
|
7171
7243
|
properties.push({
|
|
7172
7244
|
name: "SrcFile",
|
|
7173
|
-
value: pkgFile
|
|
7245
|
+
value: pkgFile,
|
|
7174
7246
|
});
|
|
7175
7247
|
}
|
|
7176
7248
|
rootPkg.properties = properties;
|
|
@@ -7184,14 +7256,14 @@ export function parseSwiftJsonTreeObject(
|
|
|
7184
7256
|
pkgList,
|
|
7185
7257
|
dependenciesList,
|
|
7186
7258
|
dependency,
|
|
7187
|
-
pkgFile
|
|
7259
|
+
pkgFile,
|
|
7188
7260
|
);
|
|
7189
7261
|
depList.push(res);
|
|
7190
7262
|
}
|
|
7191
7263
|
}
|
|
7192
7264
|
dependenciesList.push({
|
|
7193
7265
|
ref: purlString,
|
|
7194
|
-
dependsOn: depList
|
|
7266
|
+
dependsOn: depList,
|
|
7195
7267
|
});
|
|
7196
7268
|
return purlString;
|
|
7197
7269
|
}
|
|
@@ -7218,7 +7290,7 @@ export function parseSwiftJsonTree(rawOutput, pkgFile) {
|
|
|
7218
7290
|
}
|
|
7219
7291
|
return {
|
|
7220
7292
|
pkgList,
|
|
7221
|
-
dependenciesList
|
|
7293
|
+
dependenciesList,
|
|
7222
7294
|
};
|
|
7223
7295
|
}
|
|
7224
7296
|
|
|
@@ -7231,7 +7303,7 @@ export function parseSwiftResolved(resolvedFile) {
|
|
|
7231
7303
|
if (existsSync(resolvedFile)) {
|
|
7232
7304
|
try {
|
|
7233
7305
|
const pkgData = JSON.parse(
|
|
7234
|
-
readFileSync(resolvedFile, { encoding: "utf-8" })
|
|
7306
|
+
readFileSync(resolvedFile, { encoding: "utf-8" }),
|
|
7235
7307
|
);
|
|
7236
7308
|
let resolvedList = [];
|
|
7237
7309
|
if (pkgData.pins) {
|
|
@@ -7253,8 +7325,8 @@ export function parseSwiftResolved(resolvedFile) {
|
|
|
7253
7325
|
properties: [
|
|
7254
7326
|
{
|
|
7255
7327
|
name: "SrcFile",
|
|
7256
|
-
value: resolvedFile
|
|
7257
|
-
}
|
|
7328
|
+
value: resolvedFile,
|
|
7329
|
+
},
|
|
7258
7330
|
],
|
|
7259
7331
|
evidence: {
|
|
7260
7332
|
identity: {
|
|
@@ -7264,11 +7336,11 @@ export function parseSwiftResolved(resolvedFile) {
|
|
|
7264
7336
|
{
|
|
7265
7337
|
technique: "manifest-analysis",
|
|
7266
7338
|
confidence: 1,
|
|
7267
|
-
value: resolvedFile
|
|
7268
|
-
}
|
|
7269
|
-
]
|
|
7270
|
-
}
|
|
7271
|
-
}
|
|
7339
|
+
value: resolvedFile,
|
|
7340
|
+
},
|
|
7341
|
+
],
|
|
7342
|
+
},
|
|
7343
|
+
},
|
|
7272
7344
|
};
|
|
7273
7345
|
if (locationOrUrl) {
|
|
7274
7346
|
rootPkg.repository = { url: locationOrUrl };
|
|
@@ -7294,7 +7366,7 @@ export async function collectMvnDependencies(
|
|
|
7294
7366
|
mavenCmd,
|
|
7295
7367
|
basePath,
|
|
7296
7368
|
cleanup = true,
|
|
7297
|
-
includeCacheDir = false
|
|
7369
|
+
includeCacheDir = false,
|
|
7298
7370
|
) {
|
|
7299
7371
|
let jarNSMapping = {};
|
|
7300
7372
|
const MAVEN_CACHE_DIR =
|
|
@@ -7308,7 +7380,7 @@ export async function collectMvnDependencies(
|
|
|
7308
7380
|
"-Dmdep.useRepositoryLayout=true",
|
|
7309
7381
|
"-Dmdep.includeScope=compile",
|
|
7310
7382
|
"-Dmdep.prependGroupId=" + (process.env.MAVEN_PREPEND_GROUP || "false"),
|
|
7311
|
-
"-Dmdep.stripVersion=" + (process.env.MAVEN_STRIP_VERSION || "false")
|
|
7383
|
+
"-Dmdep.stripVersion=" + (process.env.MAVEN_STRIP_VERSION || "false"),
|
|
7312
7384
|
];
|
|
7313
7385
|
if (process.env.MVN_ARGS) {
|
|
7314
7386
|
const addArgs = process.env.MVN_ARGS.split(" ");
|
|
@@ -7319,21 +7391,21 @@ export async function collectMvnDependencies(
|
|
|
7319
7391
|
const result = spawnSync(mavenCmd, copyArgs, {
|
|
7320
7392
|
cwd: basePath,
|
|
7321
7393
|
encoding: "utf-8",
|
|
7322
|
-
shell: isWin
|
|
7394
|
+
shell: isWin,
|
|
7323
7395
|
});
|
|
7324
7396
|
if (result.status !== 0 || result.error) {
|
|
7325
7397
|
console.error(result.stdout, result.stderr);
|
|
7326
7398
|
console.log(
|
|
7327
|
-
"Resolve the above maven error. You can try the following remediation tips:\n"
|
|
7399
|
+
"Resolve the above maven error. You can try the following remediation tips:\n",
|
|
7328
7400
|
);
|
|
7329
7401
|
console.log(
|
|
7330
|
-
"1. Check if the correct version of maven is installed and available in the PATH."
|
|
7402
|
+
"1. Check if the correct version of maven is installed and available in the PATH.",
|
|
7331
7403
|
);
|
|
7332
7404
|
console.log(
|
|
7333
|
-
"2. Perform 'mvn compile package' before invoking this command. Fix any errors found during this invocation."
|
|
7405
|
+
"2. Perform 'mvn compile package' before invoking this command. Fix any errors found during this invocation.",
|
|
7334
7406
|
);
|
|
7335
7407
|
console.log(
|
|
7336
|
-
"3. Ensure the temporary directory is available and has sufficient disk space to copy all the artifacts."
|
|
7408
|
+
"3. Ensure the temporary directory is available and has sufficient disk space to copy all the artifacts.",
|
|
7337
7409
|
);
|
|
7338
7410
|
} else {
|
|
7339
7411
|
jarNSMapping = await collectJarNS(tempDir);
|
|
@@ -7355,7 +7427,7 @@ export async function collectGradleDependencies(
|
|
|
7355
7427
|
gradleCmd,
|
|
7356
7428
|
basePath,
|
|
7357
7429
|
cleanup = true, // eslint-disable-line no-unused-vars
|
|
7358
|
-
includeCacheDir = false // eslint-disable-line no-unused-vars
|
|
7430
|
+
includeCacheDir = false, // eslint-disable-line no-unused-vars
|
|
7359
7431
|
) {
|
|
7360
7432
|
// HELP WANTED: We need an init script that mimics maven copy-dependencies that only collects the project specific jars and poms
|
|
7361
7433
|
// Construct gradle cache directory
|
|
@@ -7367,13 +7439,13 @@ export async function collectGradleDependencies(
|
|
|
7367
7439
|
process.env.GRADLE_USER_HOME,
|
|
7368
7440
|
"caches",
|
|
7369
7441
|
"modules-2",
|
|
7370
|
-
"files-2.1"
|
|
7442
|
+
"files-2.1",
|
|
7371
7443
|
);
|
|
7372
7444
|
}
|
|
7373
7445
|
if (DEBUG_MODE) {
|
|
7374
7446
|
console.log("Collecting jars from", GRADLE_CACHE_DIR);
|
|
7375
7447
|
console.log(
|
|
7376
|
-
"To improve performance, ensure only the project dependencies are present in this cache location."
|
|
7448
|
+
"To improve performance, ensure only the project dependencies are present in this cache location.",
|
|
7377
7449
|
);
|
|
7378
7450
|
}
|
|
7379
7451
|
const pomPathMap = {};
|
|
@@ -7396,16 +7468,16 @@ export async function collectGradleDependencies(
|
|
|
7396
7468
|
export async function collectJarNS(jarPath, pomPathMap = {}) {
|
|
7397
7469
|
const jarNSMapping = {};
|
|
7398
7470
|
console.log(
|
|
7399
|
-
`About to identify class names for all jars in the path ${jarPath}
|
|
7471
|
+
`About to identify class names for all jars in the path ${jarPath}`,
|
|
7400
7472
|
);
|
|
7401
7473
|
const env = {
|
|
7402
|
-
...process.env
|
|
7474
|
+
...process.env,
|
|
7403
7475
|
};
|
|
7404
7476
|
// jar command usually would not be available in the PATH for windows
|
|
7405
7477
|
if (isWin && env.JAVA_HOME) {
|
|
7406
7478
|
env.PATH = `${env.PATH || env.Path}${_delimiter}${join(
|
|
7407
7479
|
env.JAVA_HOME,
|
|
7408
|
-
"bin"
|
|
7480
|
+
"bin",
|
|
7409
7481
|
)}`;
|
|
7410
7482
|
}
|
|
7411
7483
|
// Parse jar files to get class names
|
|
@@ -7440,7 +7512,7 @@ export async function collectJarNS(jarPath, pomPathMap = {}) {
|
|
|
7440
7512
|
pomData.artifactId,
|
|
7441
7513
|
pomData.version,
|
|
7442
7514
|
{ type: "jar" },
|
|
7443
|
-
null
|
|
7515
|
+
null,
|
|
7444
7516
|
);
|
|
7445
7517
|
purl = purlObj.toString();
|
|
7446
7518
|
}
|
|
@@ -7486,7 +7558,7 @@ export async function collectJarNS(jarPath, pomPathMap = {}) {
|
|
|
7486
7558
|
jarFileName.replace(`-${jarVersion}`, ""),
|
|
7487
7559
|
jarVersion,
|
|
7488
7560
|
{ type: qualifierType },
|
|
7489
|
-
null
|
|
7561
|
+
null,
|
|
7490
7562
|
);
|
|
7491
7563
|
purl = purlObj.toString();
|
|
7492
7564
|
}
|
|
@@ -7515,7 +7587,7 @@ export async function collectJarNS(jarPath, pomPathMap = {}) {
|
|
|
7515
7587
|
pkgName,
|
|
7516
7588
|
jarVersion,
|
|
7517
7589
|
{ type: "jar" },
|
|
7518
|
-
null
|
|
7590
|
+
null,
|
|
7519
7591
|
);
|
|
7520
7592
|
purl = purlObj.toString();
|
|
7521
7593
|
}
|
|
@@ -7531,7 +7603,7 @@ export async function collectJarNS(jarPath, pomPathMap = {}) {
|
|
|
7531
7603
|
jarNSMapping[purl || jf] = {
|
|
7532
7604
|
jarFile: jf,
|
|
7533
7605
|
pom: pomData,
|
|
7534
|
-
namespaces: nsList
|
|
7606
|
+
namespaces: nsList,
|
|
7535
7607
|
};
|
|
7536
7608
|
// Retain in the global cache to speed up future lookups
|
|
7537
7609
|
if (purl) {
|
|
@@ -7565,7 +7637,7 @@ export function convertJarNSToPackages(jarNSMapping) {
|
|
|
7565
7637
|
const name = pom.artifactId || purlObj.name;
|
|
7566
7638
|
if (!name) {
|
|
7567
7639
|
console.warn(
|
|
7568
|
-
`Unable to identify the metadata for ${purl}. This will be skipped
|
|
7640
|
+
`Unable to identify the metadata for ${purl}. This will be skipped.`,
|
|
7569
7641
|
);
|
|
7570
7642
|
continue;
|
|
7571
7643
|
}
|
|
@@ -7584,21 +7656,21 @@ export function convertJarNSToPackages(jarNSMapping) {
|
|
|
7584
7656
|
{
|
|
7585
7657
|
technique: "filename",
|
|
7586
7658
|
confidence: 1,
|
|
7587
|
-
value: jarFile
|
|
7588
|
-
}
|
|
7589
|
-
]
|
|
7590
|
-
}
|
|
7659
|
+
value: jarFile,
|
|
7660
|
+
},
|
|
7661
|
+
],
|
|
7662
|
+
},
|
|
7591
7663
|
},
|
|
7592
7664
|
properties: [
|
|
7593
7665
|
{
|
|
7594
7666
|
name: "SrcFile",
|
|
7595
|
-
value: jarFile
|
|
7667
|
+
value: jarFile,
|
|
7596
7668
|
},
|
|
7597
7669
|
{
|
|
7598
7670
|
name: "Namespaces",
|
|
7599
|
-
value: namespaces.join("\n")
|
|
7600
|
-
}
|
|
7601
|
-
]
|
|
7671
|
+
value: namespaces.join("\n"),
|
|
7672
|
+
},
|
|
7673
|
+
],
|
|
7602
7674
|
};
|
|
7603
7675
|
if (pom.url) {
|
|
7604
7676
|
apackage["homepage"] = { url: pom.url };
|
|
@@ -7620,7 +7692,7 @@ export function parsePomXml(pomXmlData) {
|
|
|
7620
7692
|
spaces: 4,
|
|
7621
7693
|
textKey: "_",
|
|
7622
7694
|
attributesKey: "$",
|
|
7623
|
-
commentKey: "value"
|
|
7695
|
+
commentKey: "value",
|
|
7624
7696
|
}).project;
|
|
7625
7697
|
if (project) {
|
|
7626
7698
|
let version = project.version ? project.version._ : undefined;
|
|
@@ -7637,7 +7709,7 @@ export function parsePomXml(pomXmlData) {
|
|
|
7637
7709
|
version,
|
|
7638
7710
|
description: project.description ? project.description._ : "",
|
|
7639
7711
|
url: project.url ? project.url._ : "",
|
|
7640
|
-
scm: project.scm && project.scm.url ? project.scm.url._ : ""
|
|
7712
|
+
scm: project.scm && project.scm.url ? project.scm.url._ : "",
|
|
7641
7713
|
};
|
|
7642
7714
|
}
|
|
7643
7715
|
return undefined;
|
|
@@ -7696,7 +7768,7 @@ export function getPomPropertiesFromMavenDir(mavenDir) {
|
|
|
7696
7768
|
const pomPropertiesFiles = getAllFiles(mavenDir, "**/pom.properties");
|
|
7697
7769
|
if (pomPropertiesFiles && pomPropertiesFiles.length) {
|
|
7698
7770
|
const pomPropertiesString = readFileSync(pomPropertiesFiles[0], {
|
|
7699
|
-
encoding: "utf-8"
|
|
7771
|
+
encoding: "utf-8",
|
|
7700
7772
|
});
|
|
7701
7773
|
pomProperties = parsePomProperties(pomPropertiesString);
|
|
7702
7774
|
}
|
|
@@ -7758,13 +7830,13 @@ export async function extractJarArchive(jarFile, tempDir, jarNSMapping = {}) {
|
|
|
7758
7830
|
copyFileSync(jarFile, join(tempDir, fname), constants.COPYFILE_FICLONE);
|
|
7759
7831
|
}
|
|
7760
7832
|
const env = {
|
|
7761
|
-
...process.env
|
|
7833
|
+
...process.env,
|
|
7762
7834
|
};
|
|
7763
7835
|
// jar command usually would not be available in the PATH for windows
|
|
7764
7836
|
if (isWin && env.JAVA_HOME) {
|
|
7765
7837
|
env.PATH = `${env.PATH || env.Path}${_delimiter}${join(
|
|
7766
7838
|
env.JAVA_HOME,
|
|
7767
|
-
"bin"
|
|
7839
|
+
"bin",
|
|
7768
7840
|
)}`;
|
|
7769
7841
|
}
|
|
7770
7842
|
if (
|
|
@@ -7824,7 +7896,7 @@ export async function extractJarArchive(jarFile, tempDir, jarNSMapping = {}) {
|
|
|
7824
7896
|
const manifestFile = join(manifestDir, "MANIFEST.MF");
|
|
7825
7897
|
const mavenDir = join(manifestDir, "maven");
|
|
7826
7898
|
let jarResult = {
|
|
7827
|
-
status: 1
|
|
7899
|
+
status: 1,
|
|
7828
7900
|
};
|
|
7829
7901
|
if (existsSync(pomname)) {
|
|
7830
7902
|
jarResult = { status: 0 };
|
|
@@ -7871,8 +7943,8 @@ export async function extractJarArchive(jarFile, tempDir, jarNSMapping = {}) {
|
|
|
7871
7943
|
secureConnect: 5000,
|
|
7872
7944
|
socket: 1000,
|
|
7873
7945
|
send: 10000,
|
|
7874
|
-
response: 1000
|
|
7875
|
-
}
|
|
7946
|
+
response: 1000,
|
|
7947
|
+
},
|
|
7876
7948
|
});
|
|
7877
7949
|
const data = res && res.body ? res.body["response"] : undefined;
|
|
7878
7950
|
if (data && data["numFound"] == 1) {
|
|
@@ -7886,7 +7958,7 @@ export async function extractJarArchive(jarFile, tempDir, jarNSMapping = {}) {
|
|
|
7886
7958
|
if (err && err.message && !err.message.includes("404")) {
|
|
7887
7959
|
if (err.message.includes("Timeout")) {
|
|
7888
7960
|
console.log(
|
|
7889
|
-
"Maven search appears to be unavailable. Search will be skipped for all remaining packages."
|
|
7961
|
+
"Maven search appears to be unavailable. Search will be skipped for all remaining packages.",
|
|
7890
7962
|
);
|
|
7891
7963
|
} else if (DEBUG_MODE) {
|
|
7892
7964
|
console.log(err);
|
|
@@ -7899,8 +7971,8 @@ export async function extractJarArchive(jarFile, tempDir, jarNSMapping = {}) {
|
|
|
7899
7971
|
confidence = 0.8;
|
|
7900
7972
|
const jarMetadata = parseJarManifest(
|
|
7901
7973
|
readFileSync(manifestFile, {
|
|
7902
|
-
encoding: "utf-8"
|
|
7903
|
-
})
|
|
7974
|
+
encoding: "utf-8",
|
|
7975
|
+
}),
|
|
7904
7976
|
);
|
|
7905
7977
|
group =
|
|
7906
7978
|
group ||
|
|
@@ -7954,12 +8026,12 @@ export async function extractJarArchive(jarFile, tempDir, jarNSMapping = {}) {
|
|
|
7954
8026
|
if (group.includes("." + name.toLowerCase().replace(/-/g, "."))) {
|
|
7955
8027
|
group = group.replace(
|
|
7956
8028
|
new RegExp("." + name.toLowerCase().replace(/-/g, ".") + "$"),
|
|
7957
|
-
""
|
|
8029
|
+
"",
|
|
7958
8030
|
);
|
|
7959
8031
|
} else if (group.includes("." + name.toLowerCase())) {
|
|
7960
8032
|
group = group.replace(
|
|
7961
8033
|
new RegExp("." + name.toLowerCase() + "$"),
|
|
7962
|
-
""
|
|
8034
|
+
"",
|
|
7963
8035
|
);
|
|
7964
8036
|
}
|
|
7965
8037
|
}
|
|
@@ -7984,7 +8056,7 @@ export async function extractJarArchive(jarFile, tempDir, jarNSMapping = {}) {
|
|
|
7984
8056
|
name,
|
|
7985
8057
|
version,
|
|
7986
8058
|
{ type: "jar" },
|
|
7987
|
-
null
|
|
8059
|
+
null,
|
|
7988
8060
|
).toString(),
|
|
7989
8061
|
evidence: {
|
|
7990
8062
|
identity: {
|
|
@@ -7994,17 +8066,17 @@ export async function extractJarArchive(jarFile, tempDir, jarNSMapping = {}) {
|
|
|
7994
8066
|
{
|
|
7995
8067
|
technique: technique,
|
|
7996
8068
|
confidence: confidence,
|
|
7997
|
-
value: jarname
|
|
7998
|
-
}
|
|
7999
|
-
]
|
|
8000
|
-
}
|
|
8069
|
+
value: jarname,
|
|
8070
|
+
},
|
|
8071
|
+
],
|
|
8072
|
+
},
|
|
8001
8073
|
},
|
|
8002
8074
|
properties: [
|
|
8003
8075
|
{
|
|
8004
8076
|
name: "SrcFile",
|
|
8005
|
-
value: jarname
|
|
8006
|
-
}
|
|
8007
|
-
]
|
|
8077
|
+
value: jarname,
|
|
8078
|
+
},
|
|
8079
|
+
],
|
|
8008
8080
|
};
|
|
8009
8081
|
if (
|
|
8010
8082
|
jarNSMapping &&
|
|
@@ -8013,7 +8085,7 @@ export async function extractJarArchive(jarFile, tempDir, jarNSMapping = {}) {
|
|
|
8013
8085
|
) {
|
|
8014
8086
|
apkg.properties.push({
|
|
8015
8087
|
name: "Namespaces",
|
|
8016
|
-
value: jarNSMapping[apkg.purl].namespaces.join("\n")
|
|
8088
|
+
value: jarNSMapping[apkg.purl].namespaces.join("\n"),
|
|
8017
8089
|
});
|
|
8018
8090
|
}
|
|
8019
8091
|
pkgList.push(apkg);
|
|
@@ -8028,7 +8100,7 @@ export async function extractJarArchive(jarFile, tempDir, jarNSMapping = {}) {
|
|
|
8028
8100
|
// Clean up META-INF
|
|
8029
8101
|
rmSync(join(tempDir, "META-INF"), {
|
|
8030
8102
|
recursive: true,
|
|
8031
|
-
force: true
|
|
8103
|
+
force: true,
|
|
8032
8104
|
});
|
|
8033
8105
|
}
|
|
8034
8106
|
} catch (err) {
|
|
@@ -8108,7 +8180,7 @@ export function cleanupPlugin(projectPath, originalPluginsFile) {
|
|
|
8108
8180
|
copyFileSync(
|
|
8109
8181
|
originalPluginsFile,
|
|
8110
8182
|
pluginsFile,
|
|
8111
|
-
constants.COPYFILE_FICLONE
|
|
8183
|
+
constants.COPYFILE_FICLONE,
|
|
8112
8184
|
);
|
|
8113
8185
|
unlinkSync(originalPluginsFile);
|
|
8114
8186
|
return true;
|
|
@@ -8139,7 +8211,7 @@ export function sbtPluginsPath(projectPath) {
|
|
|
8139
8211
|
export async function readZipEntry(
|
|
8140
8212
|
zipFile,
|
|
8141
8213
|
filePattern,
|
|
8142
|
-
contentEncoding = "utf-8"
|
|
8214
|
+
contentEncoding = "utf-8",
|
|
8143
8215
|
) {
|
|
8144
8216
|
let retData = undefined;
|
|
8145
8217
|
try {
|
|
@@ -8200,7 +8272,7 @@ export async function getJarClasses(jarFile) {
|
|
|
8200
8272
|
.replace("\r", "")
|
|
8201
8273
|
.replace(/.(class|java|kt|scala|groovy)/g, "")
|
|
8202
8274
|
.replace(/\/$/, "")
|
|
8203
|
-
.replace(/\//g, ".")
|
|
8275
|
+
.replace(/\//g, "."),
|
|
8204
8276
|
);
|
|
8205
8277
|
}
|
|
8206
8278
|
}
|
|
@@ -8298,14 +8370,14 @@ export function getMavenCommand(srcPath, rootPath) {
|
|
|
8298
8370
|
if (isWrapperFound) {
|
|
8299
8371
|
if (DEBUG_MODE) {
|
|
8300
8372
|
console.log(
|
|
8301
|
-
"Testing the wrapper script by invoking wrapper:wrapper task"
|
|
8373
|
+
"Testing the wrapper script by invoking wrapper:wrapper task",
|
|
8302
8374
|
);
|
|
8303
8375
|
}
|
|
8304
8376
|
const result = spawnSync(mavenWrapperCmd, ["wrapper:wrapper"], {
|
|
8305
8377
|
encoding: "utf-8",
|
|
8306
8378
|
cwd: rootPath,
|
|
8307
8379
|
timeout: TIMEOUT_MS,
|
|
8308
|
-
shell: isWin
|
|
8380
|
+
shell: isWin,
|
|
8309
8381
|
});
|
|
8310
8382
|
if (!result.error && !result.status) {
|
|
8311
8383
|
isWrapperReady = true;
|
|
@@ -8313,7 +8385,7 @@ export function getMavenCommand(srcPath, rootPath) {
|
|
|
8313
8385
|
} else {
|
|
8314
8386
|
if (DEBUG_MODE) {
|
|
8315
8387
|
console.log(
|
|
8316
|
-
"Maven wrapper script test has failed. Will use the installed version of maven."
|
|
8388
|
+
"Maven wrapper script test has failed. Will use the installed version of maven.",
|
|
8317
8389
|
);
|
|
8318
8390
|
}
|
|
8319
8391
|
}
|
|
@@ -8344,7 +8416,7 @@ export function getAtomCommand() {
|
|
|
8344
8416
|
"node_modules",
|
|
8345
8417
|
"@appthreat",
|
|
8346
8418
|
"atom",
|
|
8347
|
-
"index.js"
|
|
8419
|
+
"index.js",
|
|
8348
8420
|
);
|
|
8349
8421
|
if (existsSync(localAtom)) {
|
|
8350
8422
|
return `${NODE_CMD} ${localAtom}`;
|
|
@@ -8368,20 +8440,20 @@ export function executeAtom(src, args) {
|
|
|
8368
8440
|
console.log("Executing", ATOM_BIN, args.join(" "));
|
|
8369
8441
|
}
|
|
8370
8442
|
const env = {
|
|
8371
|
-
...process.env
|
|
8443
|
+
...process.env,
|
|
8372
8444
|
};
|
|
8373
8445
|
|
|
8374
8446
|
if (isWin) {
|
|
8375
8447
|
env.PATH = `${env.PATH || env.Path}${_delimiter}${join(
|
|
8376
8448
|
dirNameStr,
|
|
8377
8449
|
"node_modules",
|
|
8378
|
-
".bin"
|
|
8450
|
+
".bin",
|
|
8379
8451
|
)}`;
|
|
8380
8452
|
} else {
|
|
8381
8453
|
env.PATH = `${env.PATH}${_delimiter}${join(
|
|
8382
8454
|
dirNameStr,
|
|
8383
8455
|
"node_modules",
|
|
8384
|
-
".bin"
|
|
8456
|
+
".bin",
|
|
8385
8457
|
)}`;
|
|
8386
8458
|
}
|
|
8387
8459
|
const result = spawnSync(ATOM_BIN, args, {
|
|
@@ -8391,22 +8463,22 @@ export function executeAtom(src, args) {
|
|
|
8391
8463
|
detached: !isWin && !process.env.CI,
|
|
8392
8464
|
shell: isWin,
|
|
8393
8465
|
killSignal: "SIGKILL",
|
|
8394
|
-
env
|
|
8466
|
+
env,
|
|
8395
8467
|
});
|
|
8396
8468
|
if (result.stderr) {
|
|
8397
8469
|
if (
|
|
8398
8470
|
result.stderr.includes(
|
|
8399
|
-
"has been compiled by a more recent version of the Java Runtime"
|
|
8471
|
+
"has been compiled by a more recent version of the Java Runtime",
|
|
8400
8472
|
) ||
|
|
8401
8473
|
result.stderr.includes("Error: Could not create the Java Virtual Machine")
|
|
8402
8474
|
) {
|
|
8403
8475
|
console.log(
|
|
8404
|
-
"Atom requires Java 21 or above. To improve the SBOM accuracy, please install a suitable version, set the JAVA_HOME environment variable, and re-run cdxgen.\nAlternatively, use the cdxgen container image."
|
|
8476
|
+
"Atom requires Java 21 or above. To improve the SBOM accuracy, please install a suitable version, set the JAVA_HOME environment variable, and re-run cdxgen.\nAlternatively, use the cdxgen container image.",
|
|
8405
8477
|
);
|
|
8406
8478
|
console.log(`Current JAVA_HOME: ${env["JAVA_HOME"] || ""}`);
|
|
8407
8479
|
} else if (result.stderr.includes("astgen")) {
|
|
8408
8480
|
console.warn(
|
|
8409
|
-
"WARN: Unable to locate astgen command. Install atom globally using sudo npm install -g @appthreat/atom to resolve this issue."
|
|
8481
|
+
"WARN: Unable to locate astgen command. Install atom globally using sudo npm install -g @appthreat/atom to resolve this issue.",
|
|
8410
8482
|
);
|
|
8411
8483
|
}
|
|
8412
8484
|
}
|
|
@@ -8440,7 +8512,7 @@ export function findAppModules(
|
|
|
8440
8512
|
src,
|
|
8441
8513
|
language,
|
|
8442
8514
|
methodology = "usages",
|
|
8443
|
-
slicesFile = undefined
|
|
8515
|
+
slicesFile = undefined,
|
|
8444
8516
|
) {
|
|
8445
8517
|
const tempDir = mkdtempSync(join(tmpdir(), "atom-deps-"));
|
|
8446
8518
|
const atomFile = join(tempDir, "app.atom");
|
|
@@ -8456,12 +8528,12 @@ export function findAppModules(
|
|
|
8456
8528
|
resolve(atomFile),
|
|
8457
8529
|
"--slice-outfile",
|
|
8458
8530
|
resolve(slicesFile),
|
|
8459
|
-
resolve(src)
|
|
8531
|
+
resolve(src),
|
|
8460
8532
|
];
|
|
8461
8533
|
executeAtom(src, args);
|
|
8462
8534
|
if (existsSync(slicesFile)) {
|
|
8463
8535
|
const slicesData = JSON.parse(readFileSync(slicesFile, "utf-8"), {
|
|
8464
|
-
encoding: "utf-8"
|
|
8536
|
+
encoding: "utf-8",
|
|
8465
8537
|
});
|
|
8466
8538
|
if (slicesData && Object.keys(slicesData) && slicesData.modules) {
|
|
8467
8539
|
retList = slicesData.modules;
|
|
@@ -8470,10 +8542,10 @@ export function findAppModules(
|
|
|
8470
8542
|
}
|
|
8471
8543
|
} else {
|
|
8472
8544
|
console.log(
|
|
8473
|
-
"Slicing was not successful. For large projects (> 1 million lines of code), try running atom cli externally in Java mode. Please refer to the instructions in https://github.com/CycloneDX/cdxgen/blob/master/ADVANCED.md."
|
|
8545
|
+
"Slicing was not successful. For large projects (> 1 million lines of code), try running atom cli externally in Java mode. Please refer to the instructions in https://github.com/CycloneDX/cdxgen/blob/master/ADVANCED.md.",
|
|
8474
8546
|
);
|
|
8475
8547
|
console.log(
|
|
8476
|
-
"NOTE: Atom is in detached mode and will continue to run in the background with max CPU and memory unless it's killed."
|
|
8548
|
+
"NOTE: Atom is in detached mode and will continue to run in the background with max CPU and memory unless it's killed.",
|
|
8477
8549
|
);
|
|
8478
8550
|
}
|
|
8479
8551
|
// Clean up
|
|
@@ -8502,7 +8574,7 @@ function flattenDeps(dependenciesMap, pkgList, reqOrSetupFile, t) {
|
|
|
8502
8574
|
d.name,
|
|
8503
8575
|
d.version,
|
|
8504
8576
|
null,
|
|
8505
|
-
null
|
|
8577
|
+
null,
|
|
8506
8578
|
).toString();
|
|
8507
8579
|
pkgList.push({
|
|
8508
8580
|
name: d.name,
|
|
@@ -8512,8 +8584,8 @@ function flattenDeps(dependenciesMap, pkgList, reqOrSetupFile, t) {
|
|
|
8512
8584
|
properties: [
|
|
8513
8585
|
{
|
|
8514
8586
|
name: "SrcFile",
|
|
8515
|
-
value: reqOrSetupFile
|
|
8516
|
-
}
|
|
8587
|
+
value: reqOrSetupFile,
|
|
8588
|
+
},
|
|
8517
8589
|
],
|
|
8518
8590
|
evidence: {
|
|
8519
8591
|
identity: {
|
|
@@ -8523,11 +8595,11 @@ function flattenDeps(dependenciesMap, pkgList, reqOrSetupFile, t) {
|
|
|
8523
8595
|
{
|
|
8524
8596
|
technique: "manifest-analysis",
|
|
8525
8597
|
confidence: 0.8,
|
|
8526
|
-
value: reqOrSetupFile
|
|
8527
|
-
}
|
|
8528
|
-
]
|
|
8529
|
-
}
|
|
8530
|
-
}
|
|
8598
|
+
value: reqOrSetupFile,
|
|
8599
|
+
},
|
|
8600
|
+
],
|
|
8601
|
+
},
|
|
8602
|
+
},
|
|
8531
8603
|
});
|
|
8532
8604
|
// Recurse and flatten
|
|
8533
8605
|
if (d.dependencies && d.dependencies) {
|
|
@@ -8554,7 +8626,7 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8554
8626
|
let result = undefined;
|
|
8555
8627
|
let frozen = true;
|
|
8556
8628
|
const env = {
|
|
8557
|
-
...process.env
|
|
8629
|
+
...process.env,
|
|
8558
8630
|
};
|
|
8559
8631
|
/**
|
|
8560
8632
|
* Let's start with an attempt to create a new temporary virtual environment in case we aren't in one
|
|
@@ -8569,7 +8641,7 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8569
8641
|
) {
|
|
8570
8642
|
result = spawnSync(PYTHON_CMD, ["-m", "venv", tempVenvDir], {
|
|
8571
8643
|
encoding: "utf-8",
|
|
8572
|
-
shell: isWin
|
|
8644
|
+
shell: isWin,
|
|
8573
8645
|
});
|
|
8574
8646
|
if (result.status !== 0 || result.error) {
|
|
8575
8647
|
frozen = false;
|
|
@@ -8580,12 +8652,12 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8580
8652
|
result.stderr.includes("spawnSync python ENOENT")
|
|
8581
8653
|
) {
|
|
8582
8654
|
console.log(
|
|
8583
|
-
"Install suitable version of python or set the environment variable PYTHON_CMD."
|
|
8655
|
+
"Install suitable version of python or set the environment variable PYTHON_CMD.",
|
|
8584
8656
|
);
|
|
8585
8657
|
}
|
|
8586
8658
|
if (!result.stderr) {
|
|
8587
8659
|
console.log(
|
|
8588
|
-
"Ensure the virtualenv package is installed using pip. `python -m pip install virtualenv`"
|
|
8660
|
+
"Ensure the virtualenv package is installed using pip. `python -m pip install virtualenv`",
|
|
8589
8661
|
);
|
|
8590
8662
|
}
|
|
8591
8663
|
}
|
|
@@ -8596,7 +8668,7 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8596
8668
|
env.VIRTUAL_ENV = tempVenvDir;
|
|
8597
8669
|
env.PATH = `${join(
|
|
8598
8670
|
tempVenvDir,
|
|
8599
|
-
platform() === "win32" ? "Scripts" : "bin"
|
|
8671
|
+
platform() === "win32" ? "Scripts" : "bin",
|
|
8600
8672
|
)}${_delimiter}${process.env.PATH || ""}`;
|
|
8601
8673
|
}
|
|
8602
8674
|
}
|
|
@@ -8617,13 +8689,13 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8617
8689
|
"config",
|
|
8618
8690
|
"virtualenvs.options.no-setuptools",
|
|
8619
8691
|
"true",
|
|
8620
|
-
"--local"
|
|
8692
|
+
"--local",
|
|
8621
8693
|
];
|
|
8622
8694
|
result = spawnSync(PYTHON_CMD, poetryConfigArgs, {
|
|
8623
8695
|
cwd: basePath,
|
|
8624
8696
|
encoding: "utf-8",
|
|
8625
8697
|
timeout: TIMEOUT_MS,
|
|
8626
|
-
shell: isWin
|
|
8698
|
+
shell: isWin,
|
|
8627
8699
|
});
|
|
8628
8700
|
let poetryInstallArgs = ["-m", "poetry", "install", "-n", "--no-root"];
|
|
8629
8701
|
// Attempt to perform poetry install
|
|
@@ -8631,7 +8703,7 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8631
8703
|
cwd: basePath,
|
|
8632
8704
|
encoding: "utf-8",
|
|
8633
8705
|
timeout: TIMEOUT_MS,
|
|
8634
|
-
shell: isWin
|
|
8706
|
+
shell: isWin,
|
|
8635
8707
|
});
|
|
8636
8708
|
if (result.status !== 0 || result.error) {
|
|
8637
8709
|
if (result.stderr && result.stderr.includes("No module named poetry")) {
|
|
@@ -8642,7 +8714,7 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8642
8714
|
encoding: "utf-8",
|
|
8643
8715
|
timeout: TIMEOUT_MS,
|
|
8644
8716
|
shell: isWin,
|
|
8645
|
-
env
|
|
8717
|
+
env,
|
|
8646
8718
|
});
|
|
8647
8719
|
if (result.status !== 0 || result.error) {
|
|
8648
8720
|
frozen = false;
|
|
@@ -8651,19 +8723,19 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8651
8723
|
}
|
|
8652
8724
|
console.log("poetry install has failed.");
|
|
8653
8725
|
console.log(
|
|
8654
|
-
"1. Install the poetry command using python -m pip install poetry."
|
|
8726
|
+
"1. Install the poetry command using python -m pip install poetry.",
|
|
8655
8727
|
);
|
|
8656
8728
|
console.log(
|
|
8657
|
-
"2. Check the version of python supported by the project. Poetry is strict about the version used."
|
|
8729
|
+
"2. Check the version of python supported by the project. Poetry is strict about the version used.",
|
|
8658
8730
|
);
|
|
8659
8731
|
console.log(
|
|
8660
|
-
"3. Setup and activate the poetry virtual environment and re-run cdxgen."
|
|
8732
|
+
"3. Setup and activate the poetry virtual environment and re-run cdxgen.",
|
|
8661
8733
|
);
|
|
8662
8734
|
}
|
|
8663
8735
|
} else {
|
|
8664
8736
|
frozen = false;
|
|
8665
8737
|
console.log(
|
|
8666
|
-
"Poetry install has failed. Setup and activate the poetry virtual environment and re-run cdxgen."
|
|
8738
|
+
"Poetry install has failed. Setup and activate the poetry virtual environment and re-run cdxgen.",
|
|
8667
8739
|
);
|
|
8668
8740
|
if (DEBUG_MODE) {
|
|
8669
8741
|
if (result.error) {
|
|
@@ -8681,14 +8753,14 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8681
8753
|
encoding: "utf-8",
|
|
8682
8754
|
timeout: TIMEOUT_MS,
|
|
8683
8755
|
shell: isWin,
|
|
8684
|
-
env
|
|
8756
|
+
env,
|
|
8685
8757
|
});
|
|
8686
8758
|
tempVenvDir = result.stdout.replaceAll(/[\r\n]+/g, "");
|
|
8687
8759
|
if (tempVenvDir && tempVenvDir.length) {
|
|
8688
8760
|
env.VIRTUAL_ENV = tempVenvDir;
|
|
8689
8761
|
env.PATH = `${join(
|
|
8690
8762
|
tempVenvDir,
|
|
8691
|
-
platform() === "win32" ? "Scripts" : "bin"
|
|
8763
|
+
platform() === "win32" ? "Scripts" : "bin",
|
|
8692
8764
|
)}${_delimiter}${process.env.PATH || ""}`;
|
|
8693
8765
|
}
|
|
8694
8766
|
}
|
|
@@ -8697,7 +8769,7 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8697
8769
|
"-m",
|
|
8698
8770
|
"pip",
|
|
8699
8771
|
"install",
|
|
8700
|
-
"--disable-pip-version-check"
|
|
8772
|
+
"--disable-pip-version-check",
|
|
8701
8773
|
];
|
|
8702
8774
|
// Requirements.txt could be called with any name so best to check for not setup.py and not pyproject.toml
|
|
8703
8775
|
if (
|
|
@@ -8715,7 +8787,7 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8715
8787
|
encoding: "utf-8",
|
|
8716
8788
|
timeout: TIMEOUT_MS,
|
|
8717
8789
|
shell: isWin,
|
|
8718
|
-
env
|
|
8790
|
+
env,
|
|
8719
8791
|
});
|
|
8720
8792
|
if (result.status !== 0 || result.error) {
|
|
8721
8793
|
frozen = false;
|
|
@@ -8723,13 +8795,13 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8723
8795
|
if (
|
|
8724
8796
|
result.stderr &&
|
|
8725
8797
|
(result.stderr.includes(
|
|
8726
|
-
"Could not find a version that satisfies the requirement"
|
|
8798
|
+
"Could not find a version that satisfies the requirement",
|
|
8727
8799
|
) ||
|
|
8728
8800
|
result.stderr.includes("No matching distribution found for"))
|
|
8729
8801
|
) {
|
|
8730
8802
|
versionRelatedError = true;
|
|
8731
8803
|
console.log(
|
|
8732
|
-
"The version or the version specifiers used for a dependency is invalid. Resolve the below error to improve SBOM accuracy."
|
|
8804
|
+
"The version or the version specifiers used for a dependency is invalid. Resolve the below error to improve SBOM accuracy.",
|
|
8733
8805
|
);
|
|
8734
8806
|
console.log(result.stderr);
|
|
8735
8807
|
}
|
|
@@ -8740,29 +8812,29 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8740
8812
|
console.log(result.stderr);
|
|
8741
8813
|
}
|
|
8742
8814
|
console.log(
|
|
8743
|
-
"Possible build errors detected. The resulting list in the SBOM would therefore be incomplete.\nTry installing any missing build tools or development libraries to improve the accuracy."
|
|
8815
|
+
"Possible build errors detected. The resulting list in the SBOM would therefore be incomplete.\nTry installing any missing build tools or development libraries to improve the accuracy.",
|
|
8744
8816
|
);
|
|
8745
8817
|
if (platform() === "win32") {
|
|
8746
8818
|
console.log(
|
|
8747
|
-
"- Install the appropriate compilers and build tools on Windows by following this documentation - https://wiki.python.org/moin/WindowsCompilers"
|
|
8819
|
+
"- Install the appropriate compilers and build tools on Windows by following this documentation - https://wiki.python.org/moin/WindowsCompilers",
|
|
8748
8820
|
);
|
|
8749
8821
|
} else {
|
|
8750
8822
|
console.log(
|
|
8751
|
-
"- For example, you may have to install gcc, gcc-c++ compiler, make tools and additional development libraries using apt-get or yum package manager."
|
|
8823
|
+
"- For example, you may have to install gcc, gcc-c++ compiler, make tools and additional development libraries using apt-get or yum package manager.",
|
|
8752
8824
|
);
|
|
8753
8825
|
}
|
|
8754
8826
|
console.log(
|
|
8755
|
-
"- Certain projects would only build with specific versions of python and OS. Data science and ML related projects might require a conda/anaconda distribution."
|
|
8827
|
+
"- Certain projects would only build with specific versions of python and OS. Data science and ML related projects might require a conda/anaconda distribution.",
|
|
8756
8828
|
);
|
|
8757
8829
|
console.log(
|
|
8758
|
-
"- Check if any git submodules have to be initialized."
|
|
8830
|
+
"- Check if any git submodules have to be initialized.",
|
|
8759
8831
|
);
|
|
8760
8832
|
console.log(
|
|
8761
|
-
"- If the application has its own Dockerfile, look for additional clues in there. You can also run cdxgen npm package during the container build step."
|
|
8833
|
+
"- If the application has its own Dockerfile, look for additional clues in there. You can also run cdxgen npm package during the container build step.",
|
|
8762
8834
|
);
|
|
8763
8835
|
} else {
|
|
8764
8836
|
console.log(
|
|
8765
|
-
"Possible build errors detected. Set the environment variable CDXGEN_DEBUG_MODE=debug to troubleshoot."
|
|
8837
|
+
"Possible build errors detected. Set the environment variable CDXGEN_DEBUG_MODE=debug to troubleshoot.",
|
|
8766
8838
|
);
|
|
8767
8839
|
}
|
|
8768
8840
|
}
|
|
@@ -8780,14 +8852,14 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8780
8852
|
*/
|
|
8781
8853
|
if (DEBUG_MODE) {
|
|
8782
8854
|
console.log(
|
|
8783
|
-
"About to construct the pip dependency tree. Please wait ..."
|
|
8855
|
+
"About to construct the pip dependency tree. Please wait ...",
|
|
8784
8856
|
);
|
|
8785
8857
|
}
|
|
8786
8858
|
// This is a slow step that ideally needs to be invoked only once per venv
|
|
8787
8859
|
const tree = getTreeWithPlugin(env, PYTHON_CMD, basePath);
|
|
8788
8860
|
if (DEBUG_MODE && !tree.length) {
|
|
8789
8861
|
console.log(
|
|
8790
|
-
"Dependency tree generation has failed. Please check for any errors or version incompatibilities reported in the logs."
|
|
8862
|
+
"Dependency tree generation has failed. Please check for any errors or version incompatibilities reported in the logs.",
|
|
8791
8863
|
);
|
|
8792
8864
|
}
|
|
8793
8865
|
const dependenciesMap = {};
|
|
@@ -8809,7 +8881,7 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8809
8881
|
name,
|
|
8810
8882
|
version,
|
|
8811
8883
|
null,
|
|
8812
|
-
null
|
|
8884
|
+
null,
|
|
8813
8885
|
).toString();
|
|
8814
8886
|
pkgList.push({
|
|
8815
8887
|
name,
|
|
@@ -8824,15 +8896,15 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8824
8896
|
{
|
|
8825
8897
|
technique: "instrumentation",
|
|
8826
8898
|
confidence: 1,
|
|
8827
|
-
value: env.VIRTUAL_ENV || env.CONDA_PREFIX
|
|
8828
|
-
}
|
|
8829
|
-
]
|
|
8830
|
-
}
|
|
8831
|
-
}
|
|
8899
|
+
value: env.VIRTUAL_ENV || env.CONDA_PREFIX,
|
|
8900
|
+
},
|
|
8901
|
+
],
|
|
8902
|
+
},
|
|
8903
|
+
},
|
|
8832
8904
|
});
|
|
8833
8905
|
rootList.push({
|
|
8834
8906
|
name,
|
|
8835
|
-
version
|
|
8907
|
+
version,
|
|
8836
8908
|
});
|
|
8837
8909
|
flattenDeps(dependenciesMap, pkgList, reqOrSetupFile, t);
|
|
8838
8910
|
}
|
|
@@ -8845,7 +8917,7 @@ export function getPipFrozenTree(basePath, reqOrSetupFile, tempVenvDir) {
|
|
|
8845
8917
|
pkgList,
|
|
8846
8918
|
rootList,
|
|
8847
8919
|
dependenciesList,
|
|
8848
|
-
frozen
|
|
8920
|
+
frozen,
|
|
8849
8921
|
};
|
|
8850
8922
|
}
|
|
8851
8923
|
|
|
@@ -8856,10 +8928,10 @@ export function parsePackageJsonName(name) {
|
|
|
8856
8928
|
scope: null,
|
|
8857
8929
|
fullName: "",
|
|
8858
8930
|
projectName: "",
|
|
8859
|
-
moduleName: ""
|
|
8931
|
+
moduleName: "",
|
|
8860
8932
|
};
|
|
8861
8933
|
const match = (typeof name === "object" ? name.name || "" : name || "").match(
|
|
8862
|
-
nameRegExp
|
|
8934
|
+
nameRegExp,
|
|
8863
8935
|
);
|
|
8864
8936
|
if (match) {
|
|
8865
8937
|
returnObject.scope =
|
|
@@ -8882,7 +8954,7 @@ export async function addEvidenceForImports(
|
|
|
8882
8954
|
pkgList,
|
|
8883
8955
|
allImports,
|
|
8884
8956
|
allExports,
|
|
8885
|
-
deep
|
|
8957
|
+
deep,
|
|
8886
8958
|
) {
|
|
8887
8959
|
const impPkgs = Object.keys(allImports);
|
|
8888
8960
|
const exportedPkgs = Object.keys(allExports);
|
|
@@ -8904,10 +8976,10 @@ export async function addEvidenceForImports(
|
|
|
8904
8976
|
const all_includes = impPkgs.filter(
|
|
8905
8977
|
(find_pkg) =>
|
|
8906
8978
|
find_pkg.startsWith(alias) &&
|
|
8907
|
-
(find_pkg.length === alias.length || find_pkg[alias.length] === "/")
|
|
8979
|
+
(find_pkg.length === alias.length || find_pkg[alias.length] === "/"),
|
|
8908
8980
|
);
|
|
8909
8981
|
const all_exports = exportedPkgs.filter((find_pkg) =>
|
|
8910
|
-
find_pkg.startsWith(alias)
|
|
8982
|
+
find_pkg.startsWith(alias),
|
|
8911
8983
|
);
|
|
8912
8984
|
if (all_exports && all_exports.length) {
|
|
8913
8985
|
let exportedModules = new Set(all_exports);
|
|
@@ -8930,7 +9002,7 @@ export async function addEvidenceForImports(
|
|
|
8930
9002
|
exportedModules.add(aexpsubm);
|
|
8931
9003
|
}
|
|
8932
9004
|
exportedModules.add(
|
|
8933
|
-
`${evidence.importedAs.replace("./", "")}/${aexpsubm}
|
|
9005
|
+
`${evidence.importedAs.replace("./", "")}/${aexpsubm}`,
|
|
8934
9006
|
);
|
|
8935
9007
|
}
|
|
8936
9008
|
}
|
|
@@ -8942,7 +9014,7 @@ export async function addEvidenceForImports(
|
|
|
8942
9014
|
if (exportedModules.length) {
|
|
8943
9015
|
pkg.properties.push({
|
|
8944
9016
|
name: "ExportedModules",
|
|
8945
|
-
value: exportedModules.join(",")
|
|
9017
|
+
value: exportedModules.join(","),
|
|
8946
9018
|
});
|
|
8947
9019
|
}
|
|
8948
9020
|
}
|
|
@@ -8959,7 +9031,7 @@ export async function addEvidenceForImports(
|
|
|
8959
9031
|
pkg.evidence.occurrences.push({
|
|
8960
9032
|
location: `${evidence.fileName}${
|
|
8961
9033
|
evidence.lineNumber ? "#" + evidence.lineNumber : ""
|
|
8962
|
-
}
|
|
9034
|
+
}`,
|
|
8963
9035
|
});
|
|
8964
9036
|
importedModules.add(evidence.importedAs);
|
|
8965
9037
|
for (const importedSm of evidence.importedModules || []) {
|
|
@@ -8980,7 +9052,7 @@ export async function addEvidenceForImports(
|
|
|
8980
9052
|
pkg.properties = pkg.properties || [];
|
|
8981
9053
|
pkg.properties.push({
|
|
8982
9054
|
name: "ImportedModules",
|
|
8983
|
-
value: importedModules.join(",")
|
|
9055
|
+
value: importedModules.join(","),
|
|
8984
9056
|
});
|
|
8985
9057
|
}
|
|
8986
9058
|
break;
|
|
@@ -9011,7 +9083,7 @@ export async function addEvidenceForImports(
|
|
|
9011
9083
|
} // for alias
|
|
9012
9084
|
// Trim the properties
|
|
9013
9085
|
pkg.properties = pkg.properties.filter(
|
|
9014
|
-
(p) => p.name !== "LocalNodeModulesPath"
|
|
9086
|
+
(p) => p.name !== "LocalNodeModulesPath",
|
|
9015
9087
|
);
|
|
9016
9088
|
} // for pkg
|
|
9017
9089
|
return pkgList;
|
|
@@ -9093,7 +9165,7 @@ export function parseCmakeDotFile(dotFile, pkgType, options = {}) {
|
|
|
9093
9165
|
group: options.projectGroup || "",
|
|
9094
9166
|
name: options.projectName || name,
|
|
9095
9167
|
version: options.projectVersion || "",
|
|
9096
|
-
type: "application"
|
|
9168
|
+
type: "application",
|
|
9097
9169
|
};
|
|
9098
9170
|
parentComponent["purl"] = new PackageURL(
|
|
9099
9171
|
pkgType,
|
|
@@ -9101,7 +9173,7 @@ export function parseCmakeDotFile(dotFile, pkgType, options = {}) {
|
|
|
9101
9173
|
parentComponent.name,
|
|
9102
9174
|
parentComponent.version,
|
|
9103
9175
|
null,
|
|
9104
|
-
path
|
|
9176
|
+
path,
|
|
9105
9177
|
).toString();
|
|
9106
9178
|
parentComponent["bom-ref"] = decodeURIComponent(parentComponent["purl"]);
|
|
9107
9179
|
} else if (name) {
|
|
@@ -9114,8 +9186,8 @@ export function parseCmakeDotFile(dotFile, pkgType, options = {}) {
|
|
|
9114
9186
|
name,
|
|
9115
9187
|
version,
|
|
9116
9188
|
null,
|
|
9117
|
-
path
|
|
9118
|
-
).toString()
|
|
9189
|
+
path,
|
|
9190
|
+
).toString(),
|
|
9119
9191
|
};
|
|
9120
9192
|
apkg["bom-ref"] = decodeURIComponent(apkg["purl"]);
|
|
9121
9193
|
pkgList.push(apkg);
|
|
@@ -9127,13 +9199,13 @@ export function parseCmakeDotFile(dotFile, pkgType, options = {}) {
|
|
|
9127
9199
|
const dependsOn = Array.from(dependenciesMap[pk] || []);
|
|
9128
9200
|
dependenciesList.push({
|
|
9129
9201
|
ref: pk,
|
|
9130
|
-
dependsOn
|
|
9202
|
+
dependsOn,
|
|
9131
9203
|
});
|
|
9132
9204
|
}
|
|
9133
9205
|
return {
|
|
9134
9206
|
parentComponent,
|
|
9135
9207
|
pkgList,
|
|
9136
|
-
dependenciesList
|
|
9208
|
+
dependenciesList,
|
|
9137
9209
|
};
|
|
9138
9210
|
}
|
|
9139
9211
|
|
|
@@ -9195,7 +9267,7 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
|
|
|
9195
9267
|
group: options.projectGroup || "",
|
|
9196
9268
|
name: parentName,
|
|
9197
9269
|
version: parentVersion || options.projectVersion || "",
|
|
9198
|
-
type: "application"
|
|
9270
|
+
type: "application",
|
|
9199
9271
|
};
|
|
9200
9272
|
parentComponent["purl"] = new PackageURL(
|
|
9201
9273
|
pkgType,
|
|
@@ -9203,10 +9275,10 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
|
|
|
9203
9275
|
parentComponent.name,
|
|
9204
9276
|
parentComponent.version,
|
|
9205
9277
|
null,
|
|
9206
|
-
path
|
|
9278
|
+
path,
|
|
9207
9279
|
).toString();
|
|
9208
9280
|
parentComponent["bom-ref"] = decodeURIComponent(
|
|
9209
|
-
parentComponent["purl"]
|
|
9281
|
+
parentComponent["purl"],
|
|
9210
9282
|
);
|
|
9211
9283
|
}
|
|
9212
9284
|
}
|
|
@@ -9217,7 +9289,7 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
|
|
|
9217
9289
|
"find_library(",
|
|
9218
9290
|
"find_dependency(",
|
|
9219
9291
|
"find_file(",
|
|
9220
|
-
"FetchContent_MakeAvailable("
|
|
9292
|
+
"FetchContent_MakeAvailable(",
|
|
9221
9293
|
]) {
|
|
9222
9294
|
if (l.startsWith(fm)) {
|
|
9223
9295
|
tmpA = l.split(fm);
|
|
@@ -9236,12 +9308,12 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
|
|
|
9236
9308
|
"PATHS",
|
|
9237
9309
|
"ENV",
|
|
9238
9310
|
"NO_MODULE",
|
|
9239
|
-
"NO_DEFAULT_PATH"
|
|
9311
|
+
"NO_DEFAULT_PATH",
|
|
9240
9312
|
].includes(v) &&
|
|
9241
9313
|
!v.includes("$") &&
|
|
9242
9314
|
!v.includes("LIB") &&
|
|
9243
9315
|
!v.startsWith("CMAKE_") &&
|
|
9244
|
-
v.length
|
|
9316
|
+
v.length,
|
|
9245
9317
|
);
|
|
9246
9318
|
// find_package(Catch2)
|
|
9247
9319
|
// find_package(GTest REQUIRED)
|
|
@@ -9338,7 +9410,7 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
|
|
|
9338
9410
|
name: eprop,
|
|
9339
9411
|
value: Array.isArray(awrap[eprop])
|
|
9340
9412
|
? awrap[eprop].join(", ")
|
|
9341
|
-
: awrap[eprop]
|
|
9413
|
+
: awrap[eprop],
|
|
9342
9414
|
});
|
|
9343
9415
|
}
|
|
9344
9416
|
// Our confidence has improved from 0 since there is a matching wrap so we know the correct name
|
|
@@ -9350,7 +9422,7 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
|
|
|
9350
9422
|
if (versionSpecifiersMap[n]) {
|
|
9351
9423
|
props.push({
|
|
9352
9424
|
name: "cdx:build:versionSpecifiers",
|
|
9353
|
-
value: versionSpecifiersMap[n]
|
|
9425
|
+
value: versionSpecifiersMap[n],
|
|
9354
9426
|
});
|
|
9355
9427
|
}
|
|
9356
9428
|
const apkg = {
|
|
@@ -9363,7 +9435,7 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
|
|
|
9363
9435
|
n,
|
|
9364
9436
|
versionsMap[n] || "",
|
|
9365
9437
|
null,
|
|
9366
|
-
path
|
|
9438
|
+
path,
|
|
9367
9439
|
).toString(),
|
|
9368
9440
|
evidence: {
|
|
9369
9441
|
identity: {
|
|
@@ -9373,12 +9445,12 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
|
|
|
9373
9445
|
{
|
|
9374
9446
|
technique: "source-code-analysis",
|
|
9375
9447
|
confidence: 0.5,
|
|
9376
|
-
value: `Filename ${cmakeListFile}
|
|
9377
|
-
}
|
|
9378
|
-
]
|
|
9379
|
-
}
|
|
9448
|
+
value: `Filename ${cmakeListFile}`,
|
|
9449
|
+
},
|
|
9450
|
+
],
|
|
9451
|
+
},
|
|
9380
9452
|
},
|
|
9381
|
-
properties: props
|
|
9453
|
+
properties: props,
|
|
9382
9454
|
};
|
|
9383
9455
|
apkg["bom-ref"] = decodeURIComponent(apkg["purl"]);
|
|
9384
9456
|
pkgList.push(apkg);
|
|
@@ -9388,7 +9460,7 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
|
|
|
9388
9460
|
});
|
|
9389
9461
|
return {
|
|
9390
9462
|
parentComponent,
|
|
9391
|
-
pkgList
|
|
9463
|
+
pkgList,
|
|
9392
9464
|
};
|
|
9393
9465
|
}
|
|
9394
9466
|
|
|
@@ -9411,10 +9483,10 @@ export function getOSPackageForFile(afile, osPkgsList) {
|
|
|
9411
9483
|
{
|
|
9412
9484
|
technique: "filename",
|
|
9413
9485
|
confidence: 0.8,
|
|
9414
|
-
value: `PkgProvides ${afile}
|
|
9415
|
-
}
|
|
9416
|
-
]
|
|
9417
|
-
}
|
|
9486
|
+
value: `PkgProvides ${afile}`,
|
|
9487
|
+
},
|
|
9488
|
+
],
|
|
9489
|
+
},
|
|
9418
9490
|
};
|
|
9419
9491
|
return ospkg;
|
|
9420
9492
|
}
|
|
@@ -9447,7 +9519,7 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9447
9519
|
// users can use this file to give us a clue even if they do not use vcpkg library manager
|
|
9448
9520
|
if (existsSync(join(src, "vcpkg.json"))) {
|
|
9449
9521
|
const vcPkgData = JSON.parse(
|
|
9450
|
-
readFileSync(join(src, "vcpkg.json"), { encoding: "utf-8" })
|
|
9522
|
+
readFileSync(join(src, "vcpkg.json"), { encoding: "utf-8" }),
|
|
9451
9523
|
);
|
|
9452
9524
|
if (vcPkgData && Object.keys(vcPkgData).length && vcPkgData.name) {
|
|
9453
9525
|
const parentPurl = new PackageURL(
|
|
@@ -9456,7 +9528,7 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9456
9528
|
vcPkgData.name,
|
|
9457
9529
|
vcPkgData.version || "",
|
|
9458
9530
|
null,
|
|
9459
|
-
null
|
|
9531
|
+
null,
|
|
9460
9532
|
).toString();
|
|
9461
9533
|
parentComponent = {
|
|
9462
9534
|
name: vcPkgData.name,
|
|
@@ -9465,7 +9537,7 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9465
9537
|
license: vcPkgData.license,
|
|
9466
9538
|
purl: parentPurl,
|
|
9467
9539
|
type: "application",
|
|
9468
|
-
"bom-ref": decodeURIComponent(parentPurl)
|
|
9540
|
+
"bom-ref": decodeURIComponent(parentPurl),
|
|
9469
9541
|
};
|
|
9470
9542
|
if (vcPkgData.homepage) {
|
|
9471
9543
|
parentComponent.homepage = { url: vcPkgData.homepage };
|
|
@@ -9496,7 +9568,7 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9496
9568
|
avcpkgName,
|
|
9497
9569
|
"",
|
|
9498
9570
|
null,
|
|
9499
|
-
null
|
|
9571
|
+
null,
|
|
9500
9572
|
).toString();
|
|
9501
9573
|
const apkg = {
|
|
9502
9574
|
group: "",
|
|
@@ -9514,11 +9586,11 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9514
9586
|
{
|
|
9515
9587
|
technique: "source-code-analysis",
|
|
9516
9588
|
confidence: 0.5,
|
|
9517
|
-
value: `Filename ${join(src, "vcpkg.json")}
|
|
9518
|
-
}
|
|
9519
|
-
]
|
|
9520
|
-
}
|
|
9521
|
-
}
|
|
9589
|
+
value: `Filename ${join(src, "vcpkg.json")}`,
|
|
9590
|
+
},
|
|
9591
|
+
],
|
|
9592
|
+
},
|
|
9593
|
+
},
|
|
9522
9594
|
};
|
|
9523
9595
|
if (!pkgAddedMap[avcpkgName]) {
|
|
9524
9596
|
pkgList.push(apkg);
|
|
@@ -9539,7 +9611,7 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9539
9611
|
group: options.projectGroup || "",
|
|
9540
9612
|
name: options.projectName || "",
|
|
9541
9613
|
version: "" + options.projectVersion || "latest",
|
|
9542
|
-
type: "application"
|
|
9614
|
+
type: "application",
|
|
9543
9615
|
};
|
|
9544
9616
|
const parentPurl = new PackageURL(
|
|
9545
9617
|
pkgType,
|
|
@@ -9547,14 +9619,14 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9547
9619
|
parentComponent.name,
|
|
9548
9620
|
parentComponent.version,
|
|
9549
9621
|
null,
|
|
9550
|
-
null
|
|
9622
|
+
null,
|
|
9551
9623
|
).toString();
|
|
9552
9624
|
parentComponent.purl = parentPurl;
|
|
9553
9625
|
parentComponent["bom-ref"] = decodeURIComponent(parentPurl);
|
|
9554
9626
|
}
|
|
9555
9627
|
if (options.usagesSlicesFile && existsSync(options.usagesSlicesFile)) {
|
|
9556
9628
|
sliceData = JSON.parse(
|
|
9557
|
-
readFileSync(options.usagesSlicesFile, { encoding: "utf-8" })
|
|
9629
|
+
readFileSync(options.usagesSlicesFile, { encoding: "utf-8" }),
|
|
9558
9630
|
);
|
|
9559
9631
|
if (DEBUG_MODE) {
|
|
9560
9632
|
console.log("Re-using existing slices file", options.usagesSlicesFile);
|
|
@@ -9564,7 +9636,7 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9564
9636
|
src,
|
|
9565
9637
|
options.deep ? "c" : "h",
|
|
9566
9638
|
"usages",
|
|
9567
|
-
options.usagesSlicesFile
|
|
9639
|
+
options.usagesSlicesFile,
|
|
9568
9640
|
);
|
|
9569
9641
|
}
|
|
9570
9642
|
const usageData = parseCUsageSlice(sliceData);
|
|
@@ -9593,7 +9665,7 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9593
9665
|
name,
|
|
9594
9666
|
group,
|
|
9595
9667
|
version: "",
|
|
9596
|
-
type: pkgType
|
|
9668
|
+
type: pkgType,
|
|
9597
9669
|
};
|
|
9598
9670
|
// If this is a relative file, there is a good chance we can reuse the project group
|
|
9599
9671
|
if (!afile.startsWith(_sep) && !group.length) {
|
|
@@ -9606,7 +9678,7 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9606
9678
|
name,
|
|
9607
9679
|
version,
|
|
9608
9680
|
null,
|
|
9609
|
-
afile
|
|
9681
|
+
afile,
|
|
9610
9682
|
).toString();
|
|
9611
9683
|
apkg.evidence = {
|
|
9612
9684
|
identity: {
|
|
@@ -9616,10 +9688,10 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9616
9688
|
{
|
|
9617
9689
|
technique: "source-code-analysis",
|
|
9618
9690
|
confidence: 0,
|
|
9619
|
-
value: `Filename ${afile}
|
|
9620
|
-
}
|
|
9621
|
-
]
|
|
9622
|
-
}
|
|
9691
|
+
value: `Filename ${afile}`,
|
|
9692
|
+
},
|
|
9693
|
+
],
|
|
9694
|
+
},
|
|
9623
9695
|
};
|
|
9624
9696
|
apkg["bom-ref"] = decodeURIComponent(apkg["purl"]);
|
|
9625
9697
|
}
|
|
@@ -9631,12 +9703,12 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9631
9703
|
!v.startsWith("__") &&
|
|
9632
9704
|
v !== "main" &&
|
|
9633
9705
|
!v.includes("anonymous_") &&
|
|
9634
|
-
!v.includes(afile)
|
|
9706
|
+
!v.includes(afile),
|
|
9635
9707
|
)
|
|
9636
9708
|
.sort();
|
|
9637
9709
|
if (!apkg["properties"] && usymbols.length) {
|
|
9638
9710
|
apkg["properties"] = [
|
|
9639
|
-
{ name: "ImportedSymbols", value: usymbols.join(", ") }
|
|
9711
|
+
{ name: "ImportedSymbols", value: usymbols.join(", ") },
|
|
9640
9712
|
];
|
|
9641
9713
|
} else {
|
|
9642
9714
|
apkg["properties"] = [];
|
|
@@ -9655,7 +9727,7 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9655
9727
|
if (!symbolsPropertyFound && usymbols.length) {
|
|
9656
9728
|
apkg["properties"].push({
|
|
9657
9729
|
name: "ImportedSymbols",
|
|
9658
|
-
value: usymbols.join(", ")
|
|
9730
|
+
value: usymbols.join(", "),
|
|
9659
9731
|
});
|
|
9660
9732
|
}
|
|
9661
9733
|
apkg["properties"] = newProps;
|
|
@@ -9674,14 +9746,14 @@ export function getCppModules(src, options, osPkgsList, epkgList) {
|
|
|
9674
9746
|
? [
|
|
9675
9747
|
{
|
|
9676
9748
|
ref: parentComponent["bom-ref"],
|
|
9677
|
-
dependsOn
|
|
9678
|
-
}
|
|
9749
|
+
dependsOn,
|
|
9750
|
+
},
|
|
9679
9751
|
]
|
|
9680
9752
|
: [];
|
|
9681
9753
|
return {
|
|
9682
9754
|
parentComponent,
|
|
9683
9755
|
pkgList: pkgList.sort((a, b) => a.purl.localeCompare(b.purl)),
|
|
9684
|
-
dependenciesList
|
|
9756
|
+
dependenciesList,
|
|
9685
9757
|
};
|
|
9686
9758
|
}
|
|
9687
9759
|
|
|
@@ -9743,7 +9815,7 @@ export function parseCUsageSlice(sliceData) {
|
|
|
9743
9815
|
async function getNugetUrl() {
|
|
9744
9816
|
const req = "https://api.nuget.org/v3/index.json";
|
|
9745
9817
|
const res = await cdxgenAgent.get(req, {
|
|
9746
|
-
responseType: "json"
|
|
9818
|
+
responseType: "json",
|
|
9747
9819
|
});
|
|
9748
9820
|
const urls = res.body.resources;
|
|
9749
9821
|
for (const resource of urls) {
|
|
@@ -9801,7 +9873,7 @@ async function queryNuget(p, NUGET_URL) {
|
|
|
9801
9873
|
const newBody = [];
|
|
9802
9874
|
let res = await cdxgenAgent.get(
|
|
9803
9875
|
NUGET_URL + np.name.toLowerCase() + "/index.json",
|
|
9804
|
-
{ responseType: "json" }
|
|
9876
|
+
{ responseType: "json" },
|
|
9805
9877
|
);
|
|
9806
9878
|
const items = res.body.items;
|
|
9807
9879
|
if (!items || !items[0]) {
|
|
@@ -9890,8 +9962,8 @@ export async function getNugetMetadata(pkgList, dependencies = undefined) {
|
|
|
9890
9962
|
np.name,
|
|
9891
9963
|
np.version,
|
|
9892
9964
|
null,
|
|
9893
|
-
null
|
|
9894
|
-
).toString()
|
|
9965
|
+
null,
|
|
9966
|
+
).toString(),
|
|
9895
9967
|
);
|
|
9896
9968
|
depRepList[oldRef] = p["bom-ref"];
|
|
9897
9969
|
p.version = np.version;
|
|
@@ -9932,7 +10004,7 @@ export async function getNugetMetadata(pkgList, dependencies = undefined) {
|
|
|
9932
10004
|
p.name +
|
|
9933
10005
|
"/" +
|
|
9934
10006
|
p.version +
|
|
9935
|
-
"/"
|
|
10007
|
+
"/",
|
|
9936
10008
|
};
|
|
9937
10009
|
if (
|
|
9938
10010
|
(!p.license || typeof p.license === "string") &&
|
|
@@ -9978,7 +10050,7 @@ export async function getNugetMetadata(pkgList, dependencies = undefined) {
|
|
|
9978
10050
|
}
|
|
9979
10051
|
return {
|
|
9980
10052
|
pkgList: cdepList,
|
|
9981
|
-
dependencies: newDependencies
|
|
10053
|
+
dependencies: newDependencies,
|
|
9982
10054
|
};
|
|
9983
10055
|
}
|
|
9984
10056
|
|
|
@@ -10044,7 +10116,7 @@ export function addEvidenceForDotnet(pkgList, slicesFile) {
|
|
|
10044
10116
|
purlMethodsMap[modPurl] = new Set();
|
|
10045
10117
|
}
|
|
10046
10118
|
purlLocationMap[modPurl].add(
|
|
10047
|
-
`${amethodCall.Path}#${amethodCall.LineNumber}
|
|
10119
|
+
`${amethodCall.Path}#${amethodCall.LineNumber}`,
|
|
10048
10120
|
);
|
|
10049
10121
|
purlModulesMap[modPurl].add(amethodCall.ClassName);
|
|
10050
10122
|
purlMethodsMap[modPurl].add(amethodCall.CalledMethod);
|
|
@@ -10056,25 +10128,25 @@ export function addEvidenceForDotnet(pkgList, slicesFile) {
|
|
|
10056
10128
|
for (const apkg of pkgList) {
|
|
10057
10129
|
if (purlLocationMap[apkg.purl]) {
|
|
10058
10130
|
const locationOccurrences = Array.from(
|
|
10059
|
-
purlLocationMap[apkg.purl]
|
|
10131
|
+
purlLocationMap[apkg.purl],
|
|
10060
10132
|
).sort();
|
|
10061
10133
|
// Add the occurrences evidence
|
|
10062
10134
|
apkg.evidence.occurrences = locationOccurrences.map((l) => ({
|
|
10063
|
-
location: l
|
|
10135
|
+
location: l,
|
|
10064
10136
|
}));
|
|
10065
10137
|
}
|
|
10066
10138
|
// Add the imported modules to properties
|
|
10067
10139
|
if (purlModulesMap[apkg.purl]) {
|
|
10068
10140
|
apkg.properties.push({
|
|
10069
10141
|
name: "ImportedModules",
|
|
10070
|
-
value: Array.from(purlModulesMap[apkg.purl]).sort().join(", ")
|
|
10142
|
+
value: Array.from(purlModulesMap[apkg.purl]).sort().join(", "),
|
|
10071
10143
|
});
|
|
10072
10144
|
}
|
|
10073
10145
|
// Add the called methods to properties
|
|
10074
10146
|
if (purlMethodsMap[apkg.purl]) {
|
|
10075
10147
|
apkg.properties.push({
|
|
10076
10148
|
name: "CalledMethods",
|
|
10077
|
-
value: Array.from(purlMethodsMap[apkg.purl]).sort().join(", ")
|
|
10149
|
+
value: Array.from(purlMethodsMap[apkg.purl]).sort().join(", "),
|
|
10078
10150
|
});
|
|
10079
10151
|
}
|
|
10080
10152
|
}
|