@cyclonedx/cdxgen 10.9.10 → 10.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/bin/cdxgen.js +10 -10
- package/bin/evinse.js +8 -4
- package/bin/repl.js +3 -3
- package/bin/verify.js +2 -1
- package/{index.js → lib/cli/index.js} +123 -215
- package/{evinser.js → lib/evinser/evinser.js} +3 -3
- package/{cbomutils.js → lib/helpers/cbomutils.js} +1 -1
- package/{envcontext.js → lib/helpers/envcontext.js} +1 -0
- package/{utils.js → lib/helpers/utils.js} +348 -118
- package/{utils.test.js → lib/helpers/utils.test.js} +96 -16
- package/{validator.js → lib/helpers/validator.js} +5 -3
- package/{binary.js → lib/managers/binary.js} +3 -2
- package/{docker.js → lib/managers/docker.js} +1 -1
- package/lib/server/openapi.yaml +366 -0
- package/{server.js → lib/server/server.js} +2 -2
- package/{postgen.js → lib/stages/postgen/postgen.js} +5 -1
- package/{pregen.js → lib/stages/pregen/pregen.js} +2 -2
- package/package.json +9 -8
- package/types/lib/cli/index.d.ts.map +1 -0
- package/types/lib/evinser/evinser.d.ts.map +1 -0
- package/types/lib/helpers/analyzer.d.ts.map +1 -0
- package/types/lib/helpers/cbomutils.d.ts.map +1 -0
- package/types/lib/helpers/db.d.ts.map +1 -0
- package/types/lib/helpers/display.d.ts.map +1 -0
- package/types/{envcontext.d.ts → lib/helpers/envcontext.d.ts} +1 -0
- package/types/lib/helpers/envcontext.d.ts.map +1 -0
- package/types/lib/helpers/protobom.d.ts.map +1 -0
- package/types/{utils.d.ts → lib/helpers/utils.d.ts} +18 -4
- package/types/lib/helpers/utils.d.ts.map +1 -0
- package/types/lib/helpers/validator.d.ts.map +1 -0
- package/types/lib/managers/binary.d.ts.map +1 -0
- package/types/lib/managers/docker.d.ts.map +1 -0
- package/types/lib/managers/piptree.d.ts.map +1 -0
- package/types/lib/server/server.d.ts.map +1 -0
- package/types/lib/stages/postgen/postgen.d.ts.map +1 -0
- package/types/lib/stages/pregen/pregen.d.ts.map +1 -0
- package/types/analyzer.d.ts.map +0 -1
- package/types/binary.d.ts.map +0 -1
- package/types/cbomutils.d.ts.map +0 -1
- package/types/db.d.ts.map +0 -1
- package/types/display.d.ts.map +0 -1
- package/types/docker.d.ts.map +0 -1
- package/types/envcontext.d.ts.map +0 -1
- package/types/evinser.d.ts.map +0 -1
- package/types/index.d.ts.map +0 -1
- package/types/piptree.d.ts.map +0 -1
- package/types/postgen.d.ts.map +0 -1
- package/types/pregen.d.ts.map +0 -1
- package/types/protobom.d.ts.map +0 -1
- package/types/server.d.ts.map +0 -1
- package/types/utils.d.ts.map +0 -1
- package/types/validator.d.ts.map +0 -1
- /package/{evinser.test.js → lib/evinser/evinser.test.js} +0 -0
- /package/{analyzer.js → lib/helpers/analyzer.js} +0 -0
- /package/{cbomutils.test.js → lib/helpers/cbomutils.test.js} +0 -0
- /package/{db.js → lib/helpers/db.js} +0 -0
- /package/{display.js → lib/helpers/display.js} +0 -0
- /package/{display.test.js → lib/helpers/display.test.js} +0 -0
- /package/{envcontext.test.js → lib/helpers/envcontext.test.js} +0 -0
- /package/{protobom.js → lib/helpers/protobom.js} +0 -0
- /package/{protobom.test.js → lib/helpers/protobom.test.js} +0 -0
- /package/{docker.test.js → lib/managers/docker.test.js} +0 -0
- /package/{piptree.js → lib/managers/piptree.js} +0 -0
- /package/{postgen.test.js → lib/stages/postgen/postgen.test.js} +0 -0
- /package/types/{index.d.ts → lib/cli/index.d.ts} +0 -0
- /package/types/{evinser.d.ts → lib/evinser/evinser.d.ts} +0 -0
- /package/types/{analyzer.d.ts → lib/helpers/analyzer.d.ts} +0 -0
- /package/types/{cbomutils.d.ts → lib/helpers/cbomutils.d.ts} +0 -0
- /package/types/{db.d.ts → lib/helpers/db.d.ts} +0 -0
- /package/types/{display.d.ts → lib/helpers/display.d.ts} +0 -0
- /package/types/{protobom.d.ts → lib/helpers/protobom.d.ts} +0 -0
- /package/types/{validator.d.ts → lib/helpers/validator.d.ts} +0 -0
- /package/types/{binary.d.ts → lib/managers/binary.d.ts} +0 -0
- /package/types/{docker.d.ts → lib/managers/docker.d.ts} +0 -0
- /package/types/{piptree.d.ts → lib/managers/piptree.d.ts} +0 -0
- /package/types/{server.d.ts → lib/server/server.d.ts} +0 -0
- /package/types/{postgen.d.ts → lib/stages/postgen/postgen.d.ts} +0 -0
- /package/types/{pregen.d.ts → lib/stages/pregen/pregen.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ Sections include:
|
|
|
55
55
|
## Installing
|
|
56
56
|
|
|
57
57
|
```shell
|
|
58
|
-
npm install -g @cyclonedx/cdxgen
|
|
58
|
+
npm install -g @cyclonedx/cdxgen
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
If you are a [Homebrew][homebrew-homepage] user, you can also install [cdxgen][homebrew-cdxgen] via:
|
|
@@ -312,7 +312,7 @@ cdxgen can retain the dependency tree under the `dependencies` attribute for a s
|
|
|
312
312
|
- Gradle
|
|
313
313
|
- Scala SBT
|
|
314
314
|
- Python (requirements.txt, setup.py, pyproject.toml, poetry.lock)
|
|
315
|
-
- .NET (packages.lock.json, project.assets.json, paket.lock)
|
|
315
|
+
- .NET (packages.lock.json, project.assets.json, paket.lock, .nuspec/.nupkg)
|
|
316
316
|
- Go (go.mod)
|
|
317
317
|
- PHP (composer.lock)
|
|
318
318
|
- Ruby (Gemfile.lock)
|
|
@@ -403,7 +403,7 @@ To generate test public/private key pairs, you can run cdxgen by passing the arg
|
|
|
403
403
|
Use the bundled `cdx-verify` command, which supports verifying a single signature added at the bom level.
|
|
404
404
|
|
|
405
405
|
```shell
|
|
406
|
-
npm install -g @cyclonedx/cdxgen
|
|
406
|
+
npm install -g @cyclonedx/cdxgen
|
|
407
407
|
cdx-verify -i bom.json --public-key public.key
|
|
408
408
|
```
|
|
409
409
|
|
package/bin/cdxgen.js
CHANGED
|
@@ -10,6 +10,7 @@ import { findUpSync } from "find-up";
|
|
|
10
10
|
import globalAgent from "global-agent";
|
|
11
11
|
import { load as _load } from "js-yaml";
|
|
12
12
|
import jws from "jws";
|
|
13
|
+
import { createBom, submitBom } from "../lib/cli/index.js";
|
|
13
14
|
import {
|
|
14
15
|
printCallStack,
|
|
15
16
|
printDependencyTree,
|
|
@@ -20,12 +21,11 @@ import {
|
|
|
20
21
|
printSponsorBanner,
|
|
21
22
|
printSummary,
|
|
22
23
|
printTable,
|
|
23
|
-
} from "../display.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import { validateBom } from "../validator.js";
|
|
24
|
+
} from "../lib/helpers/display.js";
|
|
25
|
+
import { ATOM_DB, dirNameStr } from "../lib/helpers/utils.js";
|
|
26
|
+
import { validateBom } from "../lib/helpers/validator.js";
|
|
27
|
+
import { postProcess } from "../lib/stages/postgen/postgen.js";
|
|
28
|
+
import { prepareEnv } from "../lib/stages/pregen/pregen.js";
|
|
29
29
|
|
|
30
30
|
// Support for config files
|
|
31
31
|
const configPath = findUpSync([
|
|
@@ -51,7 +51,7 @@ let url = import.meta.url;
|
|
|
51
51
|
if (!url.startsWith("file://")) {
|
|
52
52
|
url = new URL(`file://${import.meta.url}`).toString();
|
|
53
53
|
}
|
|
54
|
-
const dirName =
|
|
54
|
+
const dirName = dirNameStr;
|
|
55
55
|
|
|
56
56
|
import yargs from "yargs";
|
|
57
57
|
import { hideBin } from "yargs/helpers";
|
|
@@ -493,7 +493,7 @@ const checkPermissions = (filePath) => {
|
|
|
493
493
|
printSponsorBanner(options);
|
|
494
494
|
// Start SBOM server
|
|
495
495
|
if (options.server) {
|
|
496
|
-
const serverModule = await import("../server.js");
|
|
496
|
+
const serverModule = await import("../lib/server/server.js");
|
|
497
497
|
return serverModule.start(options);
|
|
498
498
|
}
|
|
499
499
|
// Check if cdxgen has the required permissions
|
|
@@ -666,7 +666,7 @@ const checkPermissions = (filePath) => {
|
|
|
666
666
|
if (!options.evinseOutput) {
|
|
667
667
|
options.evinseOutput = options.output;
|
|
668
668
|
}
|
|
669
|
-
const evinserModule = await import("../evinser.js");
|
|
669
|
+
const evinserModule = await import("../lib/evinser/evinser.js");
|
|
670
670
|
options.projectType = options.projectType || ["java"];
|
|
671
671
|
const evinseOptions = {
|
|
672
672
|
_: args._,
|
|
@@ -719,7 +719,7 @@ const checkPermissions = (filePath) => {
|
|
|
719
719
|
}
|
|
720
720
|
// Protobuf serialization
|
|
721
721
|
if (options.exportProto) {
|
|
722
|
-
const protobomModule = await import("../protobom.js");
|
|
722
|
+
const protobomModule = await import("../lib/helpers/protobom.js");
|
|
723
723
|
protobomModule.writeBinary(bomNSData.bomJson, options.protoBinFile);
|
|
724
724
|
}
|
|
725
725
|
if (options.print && bomNSData.bomJson && bomNSData.bomJson.components) {
|
package/bin/evinse.js
CHANGED
|
@@ -7,15 +7,19 @@ import { load as _load } from "js-yaml";
|
|
|
7
7
|
// Evinse (Evinse Verification Is Nearly SBOM Evidence)
|
|
8
8
|
import yargs from "yargs";
|
|
9
9
|
import { hideBin } from "yargs/helpers";
|
|
10
|
+
import {
|
|
11
|
+
analyzeProject,
|
|
12
|
+
createEvinseFile,
|
|
13
|
+
prepareDB,
|
|
14
|
+
} from "../lib/evinser/evinser.js";
|
|
10
15
|
import {
|
|
11
16
|
printCallStack,
|
|
12
17
|
printOccurrences,
|
|
13
18
|
printReachables,
|
|
14
19
|
printServices,
|
|
15
|
-
} from "../display.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { validateBom } from "../validator.js";
|
|
20
|
+
} from "../lib/helpers/display.js";
|
|
21
|
+
import { ATOM_DB } from "../lib/helpers/utils.js";
|
|
22
|
+
import { validateBom } from "../lib/helpers/validator.js";
|
|
19
23
|
|
|
20
24
|
// Support for config files
|
|
21
25
|
const configPath = findUpSync([
|
package/bin/repl.js
CHANGED
|
@@ -7,6 +7,7 @@ import process from "node:process";
|
|
|
7
7
|
import repl from "node:repl";
|
|
8
8
|
import jsonata from "jsonata";
|
|
9
9
|
|
|
10
|
+
import { createBom } from "../lib/cli/index.js";
|
|
10
11
|
import {
|
|
11
12
|
printCallStack,
|
|
12
13
|
printDependencyTree,
|
|
@@ -17,9 +18,8 @@ import {
|
|
|
17
18
|
printSummary,
|
|
18
19
|
printTable,
|
|
19
20
|
printVulnerabilities,
|
|
20
|
-
} from "../display.js";
|
|
21
|
-
import {
|
|
22
|
-
import { validateBom } from "../validator.js";
|
|
21
|
+
} from "../lib/helpers/display.js";
|
|
22
|
+
import { validateBom } from "../lib/helpers/validator.js";
|
|
23
23
|
|
|
24
24
|
const options = {
|
|
25
25
|
useColors: true,
|
package/bin/verify.js
CHANGED
|
@@ -7,12 +7,13 @@ import { URL, fileURLToPath } from "node:url";
|
|
|
7
7
|
import jws from "jws";
|
|
8
8
|
import yargs from "yargs";
|
|
9
9
|
import { hideBin } from "yargs/helpers";
|
|
10
|
+
import { dirNameStr } from "../lib/helpers/utils.js";
|
|
10
11
|
|
|
11
12
|
let url = import.meta.url;
|
|
12
13
|
if (!url.startsWith("file://")) {
|
|
13
14
|
url = new URL(`file://${import.meta.url}`).toString();
|
|
14
15
|
}
|
|
15
|
-
const dirName =
|
|
16
|
+
const dirName = dirNameStr;
|
|
16
17
|
|
|
17
18
|
const args = yargs(hideBin(process.argv))
|
|
18
19
|
.option("input", {
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
getOriginUrl,
|
|
28
28
|
gitTreeHashes,
|
|
29
29
|
listFiles,
|
|
30
|
-
} from "
|
|
30
|
+
} from "../helpers/envcontext.js";
|
|
31
31
|
import {
|
|
32
32
|
CARGO_CMD,
|
|
33
33
|
CLJ_CMD,
|
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
convertJarNSToPackages,
|
|
53
53
|
convertOSQueryResults,
|
|
54
54
|
determineSbtVersion,
|
|
55
|
+
dirNameStr,
|
|
55
56
|
encodeForPurl,
|
|
56
57
|
executeGradleProperties,
|
|
57
58
|
executeParallelGradleProperties,
|
|
@@ -143,34 +144,34 @@ import {
|
|
|
143
144
|
readZipEntry,
|
|
144
145
|
recomputeScope,
|
|
145
146
|
splitOutputByGradleProjects,
|
|
146
|
-
} from "
|
|
147
|
+
} from "../helpers/utils.js";
|
|
147
148
|
let url = import.meta.url;
|
|
148
149
|
if (!url.startsWith("file://")) {
|
|
149
150
|
url = new URL(`file://${import.meta.url}`).toString();
|
|
150
151
|
}
|
|
151
|
-
const dirName =
|
|
152
|
+
const dirName = dirNameStr;
|
|
152
153
|
|
|
153
154
|
const selfPJson = JSON.parse(
|
|
154
155
|
readFileSync(join(dirName, "package.json"), "utf-8"),
|
|
155
156
|
);
|
|
156
157
|
const _version = selfPJson.version;
|
|
157
158
|
import { gte, lte } from "semver";
|
|
158
|
-
import { findJSImportsExports } from "
|
|
159
|
+
import { findJSImportsExports } from "../helpers/analyzer.js";
|
|
160
|
+
import { collectOSCryptoLibs } from "../helpers/cbomutils.js";
|
|
159
161
|
import {
|
|
160
162
|
executeOsQuery,
|
|
161
163
|
getBinaryBom,
|
|
162
164
|
getCargoAuditableInfo,
|
|
163
165
|
getDotnetSlices,
|
|
164
166
|
getOSPackages,
|
|
165
|
-
} from "
|
|
166
|
-
import { collectOSCryptoLibs } from "./cbomutils.js";
|
|
167
|
+
} from "../managers/binary.js";
|
|
167
168
|
import {
|
|
168
169
|
addSkippedSrcFiles,
|
|
169
170
|
exportArchive,
|
|
170
171
|
exportImage,
|
|
171
172
|
getPkgPathList,
|
|
172
173
|
parseImageName,
|
|
173
|
-
} from "
|
|
174
|
+
} from "../managers/docker.js";
|
|
174
175
|
|
|
175
176
|
const isWin = _platform() === "win32";
|
|
176
177
|
|
|
@@ -557,6 +558,11 @@ function addMetadata(parentComponent = {}, options = {}, context = {}) {
|
|
|
557
558
|
}
|
|
558
559
|
}
|
|
559
560
|
if (parentComponent?.components) {
|
|
561
|
+
parentComponent.components = listComponents(
|
|
562
|
+
options,
|
|
563
|
+
{},
|
|
564
|
+
parentComponent.components,
|
|
565
|
+
);
|
|
560
566
|
const parentFullName = componentToSimpleFullName(parentComponent);
|
|
561
567
|
const subComponents = [];
|
|
562
568
|
const addedSubComponents = {};
|
|
@@ -591,7 +597,12 @@ function addMetadata(parentComponent = {}, options = {}, context = {}) {
|
|
|
591
597
|
}
|
|
592
598
|
}
|
|
593
599
|
} // for
|
|
594
|
-
|
|
600
|
+
// Avoid creating empty component.components attribute
|
|
601
|
+
if (subComponents.length) {
|
|
602
|
+
parentComponent.components = subComponents;
|
|
603
|
+
} else {
|
|
604
|
+
parentComponent.components = undefined;
|
|
605
|
+
}
|
|
595
606
|
}
|
|
596
607
|
metadata.component = parentComponent;
|
|
597
608
|
}
|
|
@@ -1457,7 +1468,7 @@ export async function createJavaBom(path, options) {
|
|
|
1457
1468
|
);
|
|
1458
1469
|
} else {
|
|
1459
1470
|
console.log(
|
|
1460
|
-
"1. Java version requirement: cdxgen container image bundles Java
|
|
1471
|
+
"1. Java version requirement: cdxgen container image bundles Java 23 with maven 3.9 which might be incompatible. Try running cdxgen with the unofficial JDK11-based image `ghcr.io/appthreat/cdxgen-java:v10`.",
|
|
1461
1472
|
);
|
|
1462
1473
|
}
|
|
1463
1474
|
console.log(
|
|
@@ -1624,7 +1635,7 @@ export async function createJavaBom(path, options) {
|
|
|
1624
1635
|
gradleFiles?.length &&
|
|
1625
1636
|
isPackageManagerAllowed("gradle", ["maven", "bazel", "sbt"], options)
|
|
1626
1637
|
) {
|
|
1627
|
-
|
|
1638
|
+
const retMap = executeGradleProperties(gradleRootPath, null);
|
|
1628
1639
|
const allProjectsStr = retMap.projects || [];
|
|
1629
1640
|
const rootProject = retMap.rootProject;
|
|
1630
1641
|
if (rootProject) {
|
|
@@ -1636,65 +1647,31 @@ export async function createJavaBom(path, options) {
|
|
|
1636
1647
|
}
|
|
1637
1648
|
// Get the sub-project properties and set the root dependencies
|
|
1638
1649
|
if (allProjectsStr?.length) {
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
);
|
|
1650
|
+
const parallelPropTaskOut = executeParallelGradleProperties(
|
|
1651
|
+
gradleRootPath,
|
|
1652
|
+
allProjectsStr,
|
|
1653
|
+
);
|
|
1654
|
+
const splitPropTaskOut = splitOutputByGradleProjects(
|
|
1655
|
+
parallelPropTaskOut,
|
|
1656
|
+
["properties"],
|
|
1657
|
+
);
|
|
1648
1658
|
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
} else {
|
|
1662
|
-
retMap = parseGradleProperties(propTaskOut);
|
|
1663
|
-
}
|
|
1664
|
-
const rootSubProject = retMap.rootProject;
|
|
1665
|
-
if (rootSubProject) {
|
|
1666
|
-
const rspName = rootSubProject.replace(/^:/, "");
|
|
1667
|
-
const rootSubProjectObj = await buildObjectForGradleModule(
|
|
1668
|
-
rspName,
|
|
1669
|
-
retMap.metadata,
|
|
1670
|
-
);
|
|
1671
|
-
if (!allProjectsAddedPurls.includes(rootSubProjectObj["purl"])) {
|
|
1672
|
-
allProjects.push(rootSubProjectObj);
|
|
1673
|
-
rootDependsOn.push(rootSubProjectObj["bom-ref"]);
|
|
1674
|
-
allProjectsAddedPurls.push(rootSubProjectObj["purl"]);
|
|
1675
|
-
}
|
|
1676
|
-
gradleModules.set(rspName, rootSubProjectObj);
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
} else {
|
|
1680
|
-
for (const spstr of allProjectsStr) {
|
|
1681
|
-
retMap = executeGradleProperties(gradleRootPath, spstr);
|
|
1682
|
-
const rootSubProject = retMap.rootProject;
|
|
1683
|
-
if (rootSubProject) {
|
|
1684
|
-
const rspName = rootSubProject.replace(/^:/, "");
|
|
1685
|
-
const rootSubProjectObj = await buildObjectForGradleModule(
|
|
1686
|
-
rspName,
|
|
1687
|
-
retMap.metadata,
|
|
1688
|
-
);
|
|
1689
|
-
if (!allProjectsAddedPurls.includes(rootSubProjectObj["purl"])) {
|
|
1690
|
-
allProjects.push(rootSubProjectObj);
|
|
1691
|
-
rootDependsOn.push(rootSubProjectObj["bom-ref"]);
|
|
1692
|
-
allProjectsAddedPurls.push(rootSubProjectObj["purl"]);
|
|
1693
|
-
}
|
|
1694
|
-
gradleModules.set(rspName, rootSubProjectObj);
|
|
1659
|
+
for (const [key, propTaskOut] of splitPropTaskOut.entries()) {
|
|
1660
|
+
const retMap = parseGradleProperties(propTaskOut, key);
|
|
1661
|
+
const rootSubProject = retMap.rootProject;
|
|
1662
|
+
if (rootSubProject) {
|
|
1663
|
+
const rootSubProjectObj = await buildObjectForGradleModule(
|
|
1664
|
+
rootSubProject,
|
|
1665
|
+
retMap.metadata,
|
|
1666
|
+
);
|
|
1667
|
+
if (!allProjectsAddedPurls.includes(rootSubProjectObj["purl"])) {
|
|
1668
|
+
allProjects.push(rootSubProjectObj);
|
|
1669
|
+
rootDependsOn.push(rootSubProjectObj["bom-ref"]);
|
|
1670
|
+
allProjectsAddedPurls.push(rootSubProjectObj["purl"]);
|
|
1695
1671
|
}
|
|
1672
|
+
gradleModules.set(key, rootSubProjectObj);
|
|
1696
1673
|
}
|
|
1697
|
-
}
|
|
1674
|
+
}
|
|
1698
1675
|
// Bug #317 fix
|
|
1699
1676
|
parentComponent.components = allProjects.flatMap((s) => {
|
|
1700
1677
|
delete s.qualifiers;
|
|
@@ -1718,158 +1695,87 @@ export async function createJavaBom(path, options) {
|
|
|
1718
1695
|
? process.env.GRADLE_DEPENDENCY_TASK
|
|
1719
1696
|
: "dependencies";
|
|
1720
1697
|
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
for
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
)
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
encoding: "utf-8",
|
|
1755
|
-
timeout: TIMEOUT_MS,
|
|
1756
|
-
maxBuffer: MAX_BUFFER,
|
|
1757
|
-
});
|
|
1698
|
+
const gradleSubCommands = [];
|
|
1699
|
+
const modulesToSkip = process.env.GRADLE_SKIP_MODULES
|
|
1700
|
+
? process.env.GRADLE_SKIP_MODULES.split(",")
|
|
1701
|
+
: [];
|
|
1702
|
+
if (!modulesToSkip.includes("root")) {
|
|
1703
|
+
gradleSubCommands.push(gradleDepTask);
|
|
1704
|
+
}
|
|
1705
|
+
for (const [key, sp] of gradleModules) {
|
|
1706
|
+
//create single command for dependencies tasks on all subprojects
|
|
1707
|
+
if (sp.purl !== parentComponent.purl && !modulesToSkip.includes(key)) {
|
|
1708
|
+
gradleSubCommands.push(`${key}:${gradleDepTask}`);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
const gradleArguments = buildGradleCommandArguments(
|
|
1712
|
+
process.env.GRADLE_ARGS ? process.env.GRADLE_ARGS.split(" ") : [],
|
|
1713
|
+
gradleSubCommands,
|
|
1714
|
+
process.env.GRADLE_ARGS_DEPENDENCIES
|
|
1715
|
+
? process.env.GRADLE_ARGS_DEPENDENCIES.split(" ")
|
|
1716
|
+
: [],
|
|
1717
|
+
);
|
|
1718
|
+
console.log(
|
|
1719
|
+
"Executing",
|
|
1720
|
+
gradleCmd,
|
|
1721
|
+
gradleArguments.join(" "),
|
|
1722
|
+
"in",
|
|
1723
|
+
gradleRootPath,
|
|
1724
|
+
);
|
|
1725
|
+
const sresult = spawnSync(gradleCmd, gradleArguments, {
|
|
1726
|
+
cwd: gradleRootPath,
|
|
1727
|
+
encoding: "utf-8",
|
|
1728
|
+
timeout: TIMEOUT_MS,
|
|
1729
|
+
maxBuffer: MAX_BUFFER,
|
|
1730
|
+
});
|
|
1758
1731
|
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
}
|
|
1763
|
-
options.failOnError && process.exit(1);
|
|
1732
|
+
if (sresult.status !== 0 || sresult.error) {
|
|
1733
|
+
if (options.failOnError || DEBUG_MODE) {
|
|
1734
|
+
console.error(sresult.stdout, sresult.stderr);
|
|
1764
1735
|
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
const dlist = parsedList.pkgList;
|
|
1779
|
-
if (parsedList.dependenciesList && parsedList.dependenciesList) {
|
|
1780
|
-
dependencies = mergeDependencies(
|
|
1781
|
-
dependencies,
|
|
1782
|
-
parsedList.dependenciesList,
|
|
1783
|
-
parentComponent,
|
|
1784
|
-
);
|
|
1785
|
-
}
|
|
1786
|
-
if (dlist?.length) {
|
|
1787
|
-
if (DEBUG_MODE) {
|
|
1788
|
-
console.log(
|
|
1789
|
-
"Found",
|
|
1790
|
-
dlist.length,
|
|
1791
|
-
"packages in gradle project",
|
|
1792
|
-
sp.name,
|
|
1793
|
-
);
|
|
1794
|
-
}
|
|
1795
|
-
pkgList = pkgList.concat(dlist);
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
} else {
|
|
1800
|
-
if (DEBUG_MODE) {
|
|
1801
|
-
console.log(
|
|
1802
|
-
"Try the new multi-threaded mode for gradle. Set the environment variable GRADLE_MULTI_THREADED to true to enable this.",
|
|
1803
|
-
);
|
|
1804
|
-
}
|
|
1805
|
-
for (const sp of allProjects) {
|
|
1806
|
-
const gradleArguments = buildGradleCommandArguments(
|
|
1807
|
-
process.env.GRADLE_ARGS ? process.env.GRADLE_ARGS.split(" ") : [],
|
|
1808
|
-
[
|
|
1809
|
-
sp.purl === parentComponent.purl
|
|
1810
|
-
? gradleDepTask
|
|
1811
|
-
: `:${sp.name}:${gradleDepTask}`,
|
|
1812
|
-
],
|
|
1813
|
-
process.env.GRADLE_ARGS_DEPENDENCIES
|
|
1814
|
-
? process.env.GRADLE_ARGS_DEPENDENCIES.split(" ")
|
|
1815
|
-
: [],
|
|
1816
|
-
);
|
|
1817
|
-
|
|
1818
|
-
console.log(
|
|
1819
|
-
"Executing",
|
|
1820
|
-
gradleCmd,
|
|
1821
|
-
gradleArguments.join(" "),
|
|
1822
|
-
"in",
|
|
1736
|
+
options.failOnError && process.exit(1);
|
|
1737
|
+
}
|
|
1738
|
+
const sstdout = sresult.stdout;
|
|
1739
|
+
if (sstdout) {
|
|
1740
|
+
const cmdOutput = Buffer.from(sstdout).toString();
|
|
1741
|
+
const perProjectOutput = splitOutputByGradleProjects(cmdOutput, [
|
|
1742
|
+
gradleDepTask,
|
|
1743
|
+
]);
|
|
1744
|
+
for (const [key, sp] of gradleModules) {
|
|
1745
|
+
const parsedList = await parseGradleDep(
|
|
1746
|
+
perProjectOutput.has(key) ? perProjectOutput.get(key) : "",
|
|
1747
|
+
key,
|
|
1748
|
+
gradleModules,
|
|
1823
1749
|
gradleRootPath,
|
|
1824
1750
|
);
|
|
1825
|
-
const
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
if (sresult.status !== 0 || sresult.error) {
|
|
1832
|
-
if (options.failOnError || DEBUG_MODE) {
|
|
1833
|
-
console.error(sresult.stdout, sresult.stderr);
|
|
1834
|
-
}
|
|
1835
|
-
options.failOnError && process.exit(1);
|
|
1836
|
-
}
|
|
1837
|
-
const sstdout = sresult.stdout;
|
|
1838
|
-
if (sstdout) {
|
|
1839
|
-
const cmdOutput = Buffer.from(sstdout).toString();
|
|
1840
|
-
const parsedList = await parseGradleDep(
|
|
1841
|
-
cmdOutput,
|
|
1842
|
-
sp.name,
|
|
1843
|
-
gradleModules,
|
|
1844
|
-
gradleRootPath,
|
|
1751
|
+
const dlist = parsedList.pkgList;
|
|
1752
|
+
if (parsedList.dependenciesList && parsedList.dependenciesList) {
|
|
1753
|
+
dependencies = mergeDependencies(
|
|
1754
|
+
dependencies,
|
|
1755
|
+
parsedList.dependenciesList,
|
|
1756
|
+
parentComponent,
|
|
1845
1757
|
);
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1758
|
+
}
|
|
1759
|
+
if (dlist?.length) {
|
|
1760
|
+
if (DEBUG_MODE) {
|
|
1761
|
+
console.log(
|
|
1762
|
+
"Found",
|
|
1763
|
+
dlist.length,
|
|
1764
|
+
"packages in gradle project",
|
|
1765
|
+
key,
|
|
1852
1766
|
);
|
|
1853
1767
|
}
|
|
1854
|
-
|
|
1855
|
-
if (DEBUG_MODE) {
|
|
1856
|
-
console.log(
|
|
1857
|
-
"Found",
|
|
1858
|
-
dlist.length,
|
|
1859
|
-
"packages in gradle project",
|
|
1860
|
-
sp.name,
|
|
1861
|
-
);
|
|
1862
|
-
}
|
|
1863
|
-
pkgList = pkgList.concat(dlist);
|
|
1864
|
-
}
|
|
1768
|
+
pkgList = pkgList.concat(dlist);
|
|
1865
1769
|
}
|
|
1866
|
-
}
|
|
1770
|
+
}
|
|
1867
1771
|
}
|
|
1868
1772
|
if (pkgList.length) {
|
|
1869
1773
|
if (parentComponent.components?.length) {
|
|
1870
1774
|
for (const subProj of parentComponent.components) {
|
|
1871
1775
|
pkgList = pkgList.filter(
|
|
1872
|
-
(pkg) =>
|
|
1776
|
+
(pkg) =>
|
|
1777
|
+
pkg["bom-ref"] !== subProj["bom-ref"] &&
|
|
1778
|
+
pkg["bom-ref"] !== parentComponent["bom-ref"],
|
|
1873
1779
|
);
|
|
1874
1780
|
}
|
|
1875
1781
|
}
|
|
@@ -1898,7 +1804,7 @@ export async function createJavaBom(path, options) {
|
|
|
1898
1804
|
// NOTE: This can match BUILD files used by perl, so could lead to errors in some projects
|
|
1899
1805
|
const bazelFiles = getAllFiles(
|
|
1900
1806
|
path,
|
|
1901
|
-
`${options.multiProject ? "**/" : ""}BUILD
|
|
1807
|
+
`${options.multiProject ? "**/" : ""}BUILD{,.bazel}`,
|
|
1902
1808
|
options,
|
|
1903
1809
|
);
|
|
1904
1810
|
if (
|
|
@@ -2883,16 +2789,18 @@ export async function createPythonBom(path, options) {
|
|
|
2883
2789
|
);
|
|
2884
2790
|
}
|
|
2885
2791
|
}
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2792
|
+
if (retMap.rootList) {
|
|
2793
|
+
const parentDependsOn = [];
|
|
2794
|
+
// Complete the dependency tree by making parent component depend on the first level
|
|
2795
|
+
for (const p of retMap.rootList) {
|
|
2796
|
+
parentDependsOn.push(`pkg:pypi/${p.name.toLowerCase()}@${p.version}`);
|
|
2797
|
+
}
|
|
2798
|
+
const pdependencies = {
|
|
2799
|
+
ref: parentComponent["bom-ref"],
|
|
2800
|
+
dependsOn: parentDependsOn,
|
|
2801
|
+
};
|
|
2802
|
+
dependencies.splice(0, 0, pdependencies);
|
|
2890
2803
|
}
|
|
2891
|
-
const pdependencies = {
|
|
2892
|
-
ref: parentComponent["bom-ref"],
|
|
2893
|
-
dependsOn: parentDependsOn,
|
|
2894
|
-
};
|
|
2895
|
-
dependencies.splice(0, 0, pdependencies);
|
|
2896
2804
|
}
|
|
2897
2805
|
options.parentComponent = parentComponent;
|
|
2898
2806
|
} // poetryMode
|
|
@@ -4,8 +4,8 @@ import path from "node:path";
|
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { PackageURL } from "packageurl-js";
|
|
6
6
|
import { Op } from "sequelize";
|
|
7
|
-
import { findCryptoAlgos } from "
|
|
8
|
-
import * as db from "
|
|
7
|
+
import { findCryptoAlgos } from "../helpers/cbomutils.js";
|
|
8
|
+
import * as db from "../helpers/db.js";
|
|
9
9
|
import {
|
|
10
10
|
DEBUG_MODE,
|
|
11
11
|
collectGradleDependencies,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
getGradleCommand,
|
|
16
16
|
getMavenCommand,
|
|
17
17
|
getTimestamp,
|
|
18
|
-
} from "
|
|
18
|
+
} from "../helpers/utils.js";
|
|
19
19
|
const DB_NAME = "evinser.db";
|
|
20
20
|
const typePurlsCache = {};
|
|
21
21
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { executeOsQuery } from "
|
|
3
|
+
import { executeOsQuery } from "../managers/binary.js";
|
|
4
4
|
import { convertOSQueryResults, dirNameStr } from "./utils.js";
|
|
5
5
|
const cbomosDbQueries = JSON.parse(
|
|
6
6
|
readFileSync(join(dirNameStr, "data", "cbomosdb-queries.json"), "utf-8"),
|