@cyclonedx/cdxgen 9.11.5 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/analyzer.js +1 -0
- package/bin/cdxgen.js +140 -142
- package/bin/repl.js +5 -5
- package/bin/verify.js +1 -1
- package/binary.js +19 -13
- package/cbomutils.js +39 -0
- package/cbomutils.test.js +8 -0
- package/data/README.md +1 -0
- package/data/cbomosdb-queries.json +68 -0
- package/data/cosdb-queries.json +1 -1
- package/display.js +2 -2
- package/docker.js +15 -3
- package/envcontext.js +302 -0
- package/envcontext.test.js +31 -0
- package/evinser.js +9 -8
- package/index.js +229 -486
- package/package.json +7 -8
- package/protobom.test.js +1 -1
- package/server.js +2 -1
- package/utils.js +225 -162
- package/utils.test.js +37 -32
- package/validator.js +5 -4
package/utils.test.js
CHANGED
|
@@ -80,7 +80,8 @@ import {
|
|
|
80
80
|
import { readFileSync } from "node:fs";
|
|
81
81
|
import { parse } from "ssri";
|
|
82
82
|
import { expect, test } from "@jest/globals";
|
|
83
|
-
import path from "path";
|
|
83
|
+
import path from "node:path";
|
|
84
|
+
import { Buffer } from "node:buffer";
|
|
84
85
|
|
|
85
86
|
test("SSRI test", () => {
|
|
86
87
|
// gopkg.lock hash
|
|
@@ -1180,7 +1181,7 @@ test("parse clojure data", () => {
|
|
|
1180
1181
|
});
|
|
1181
1182
|
});
|
|
1182
1183
|
|
|
1183
|
-
test("parse mix lock data",
|
|
1184
|
+
test("parse mix lock data", () => {
|
|
1184
1185
|
expect(parseMixLockData(null)).toEqual([]);
|
|
1185
1186
|
let dep_list = parseMixLockData(
|
|
1186
1187
|
readFileSync("./test/data/mix.lock", { encoding: "utf-8" })
|
|
@@ -1200,12 +1201,12 @@ test("parse mix lock data", async () => {
|
|
|
1200
1201
|
});
|
|
1201
1202
|
});
|
|
1202
1203
|
|
|
1203
|
-
test("parse github actions workflow data",
|
|
1204
|
+
test("parse github actions workflow data", () => {
|
|
1204
1205
|
expect(parseGitHubWorkflowData(null)).toEqual([]);
|
|
1205
1206
|
let dep_list = parseGitHubWorkflowData(
|
|
1206
1207
|
readFileSync("./.github/workflows/nodejs.yml", { encoding: "utf-8" })
|
|
1207
1208
|
);
|
|
1208
|
-
expect(dep_list.length).toEqual(
|
|
1209
|
+
expect(dep_list.length).toEqual(5);
|
|
1209
1210
|
expect(dep_list[0]).toEqual({
|
|
1210
1211
|
group: "actions",
|
|
1211
1212
|
name: "checkout",
|
|
@@ -1214,7 +1215,7 @@ test("parse github actions workflow data", async () => {
|
|
|
1214
1215
|
dep_list = parseGitHubWorkflowData(
|
|
1215
1216
|
readFileSync("./.github/workflows/repotests.yml", { encoding: "utf-8" })
|
|
1216
1217
|
);
|
|
1217
|
-
expect(dep_list.length).toEqual(
|
|
1218
|
+
expect(dep_list.length).toEqual(8);
|
|
1218
1219
|
expect(dep_list[0]).toEqual({
|
|
1219
1220
|
group: "actions",
|
|
1220
1221
|
name: "checkout",
|
|
@@ -1466,7 +1467,7 @@ test("parse .net cs proj", async () => {
|
|
|
1466
1467
|
});
|
|
1467
1468
|
|
|
1468
1469
|
test("get nget metadata", async () => {
|
|
1469
|
-
|
|
1470
|
+
const dep_list = [
|
|
1470
1471
|
{
|
|
1471
1472
|
dependsOn: [
|
|
1472
1473
|
"pkg:nuget/Microsoft.NET.Test.Sdk@17.1.0",
|
|
@@ -1504,7 +1505,7 @@ test("get nget metadata", async () => {
|
|
|
1504
1505
|
ref: "pkg:nuget/Serilog@3.0.1"
|
|
1505
1506
|
}
|
|
1506
1507
|
];
|
|
1507
|
-
|
|
1508
|
+
const pkg_list = [
|
|
1508
1509
|
{
|
|
1509
1510
|
group: "",
|
|
1510
1511
|
name: "Castle.Core",
|
|
@@ -1719,10 +1720,10 @@ test("get licenses", () => {
|
|
|
1719
1720
|
});
|
|
1720
1721
|
|
|
1721
1722
|
test("parsePkgLock v1", async () => {
|
|
1722
|
-
|
|
1723
|
+
const parsedList = await parsePkgLock(
|
|
1723
1724
|
"./test/data/package-json/v1/package-lock.json"
|
|
1724
1725
|
);
|
|
1725
|
-
|
|
1726
|
+
const deps = parsedList.pkgList;
|
|
1726
1727
|
expect(deps.length).toEqual(910);
|
|
1727
1728
|
expect(deps[1]._integrity).toEqual(
|
|
1728
1729
|
"sha512-ZmIomM7EE1DvPEnSFAHZn9Vs9zJl5A9H7el0EGTE6ZbW9FKe/14IYAlPbC8iH25YarEQxZL+E8VW7Mi7kfQrDQ=="
|
|
@@ -1731,10 +1732,10 @@ test("parsePkgLock v1", async () => {
|
|
|
1731
1732
|
});
|
|
1732
1733
|
|
|
1733
1734
|
test("parsePkgLock v2", async () => {
|
|
1734
|
-
|
|
1735
|
+
const parsedList = await parsePkgLock(
|
|
1735
1736
|
"./test/data/package-json/v2/package-lock.json"
|
|
1736
1737
|
);
|
|
1737
|
-
|
|
1738
|
+
const deps = parsedList.pkgList;
|
|
1738
1739
|
expect(deps.length).toEqual(134);
|
|
1739
1740
|
expect(deps[1]._integrity).toEqual(
|
|
1740
1741
|
"sha512-x9yaMvEh5BEaZKeVQC4vp3l+QoFj3BXcd4aYfuKSzIIyihjdVARAadYy3SMNIz0WCCdS2vB9JL/U6GQk5PaxQw=="
|
|
@@ -1771,27 +1772,31 @@ test("parsePkgLock v2", async () => {
|
|
|
1771
1772
|
});
|
|
1772
1773
|
|
|
1773
1774
|
test("parsePkgLock v2 workspace", async () => {
|
|
1774
|
-
|
|
1775
|
+
const parsedList = await parsePkgLock(
|
|
1775
1776
|
"./test/data/package-json/v2-workspace/package-lock.json"
|
|
1776
1777
|
);
|
|
1777
|
-
|
|
1778
|
-
|
|
1778
|
+
const pkgs = parsedList.pkgList;
|
|
1779
|
+
const deps = parsedList.dependenciesList;
|
|
1779
1780
|
expect(pkgs.length).toEqual(1034);
|
|
1780
1781
|
expect(pkgs[0].license).toEqual("MIT");
|
|
1781
|
-
|
|
1782
|
+
const hasAppWorkspacePkg = pkgs.some(
|
|
1782
1783
|
(obj) => obj["bom-ref"] === "pkg:npm/app@0.0.0"
|
|
1783
1784
|
);
|
|
1784
|
-
|
|
1785
|
+
const hasAppWorkspaceDeps = deps.some(
|
|
1786
|
+
(obj) => obj.ref === "pkg:npm/app@0.0.0"
|
|
1787
|
+
);
|
|
1785
1788
|
expect(hasAppWorkspacePkg).toEqual(true);
|
|
1786
1789
|
expect(hasAppWorkspaceDeps).toEqual(true);
|
|
1787
|
-
|
|
1788
|
-
|
|
1790
|
+
const hasRootPkg = pkgs.some(
|
|
1791
|
+
(obj) => obj["bom-ref"] === "pkg:npm/root@0.0.0"
|
|
1792
|
+
);
|
|
1793
|
+
const hasRootDeps = deps.some((obj) => obj.ref === "pkg:npm/root@0.0.0");
|
|
1789
1794
|
expect(hasRootPkg).toEqual(true);
|
|
1790
1795
|
expect(hasRootDeps).toEqual(true);
|
|
1791
|
-
|
|
1796
|
+
const hasScriptsWorkspacePkg = pkgs.some(
|
|
1792
1797
|
(obj) => obj["bom-ref"] === "pkg:npm/scripts@0.0.0"
|
|
1793
1798
|
);
|
|
1794
|
-
|
|
1799
|
+
const hasScriptsWorkspaceDeps = deps.some(
|
|
1795
1800
|
(obj) => obj.ref === "pkg:npm/scripts@0.0.0"
|
|
1796
1801
|
);
|
|
1797
1802
|
expect(hasScriptsWorkspacePkg).toEqual(true);
|
|
@@ -1828,8 +1833,8 @@ test("parsePkgLock v3", async () => {
|
|
|
1828
1833
|
projectName: "cdxgen"
|
|
1829
1834
|
});
|
|
1830
1835
|
deps = parsedList.pkgList;
|
|
1831
|
-
expect(deps.length).toEqual(
|
|
1832
|
-
expect(parsedList.dependenciesList.length).toEqual(
|
|
1836
|
+
expect(deps.length).toEqual(1200);
|
|
1837
|
+
expect(parsedList.dependenciesList.length).toEqual(1200);
|
|
1833
1838
|
});
|
|
1834
1839
|
|
|
1835
1840
|
test("parseBowerJson", async () => {
|
|
@@ -2622,7 +2627,7 @@ test("parse requirements.txt", async () => {
|
|
|
2622
2627
|
});
|
|
2623
2628
|
});
|
|
2624
2629
|
|
|
2625
|
-
test("parse pyproject.toml",
|
|
2630
|
+
test("parse pyproject.toml", () => {
|
|
2626
2631
|
const pkg = parsePyProjectToml("./test/data/pyproject.toml");
|
|
2627
2632
|
expect(pkg).toEqual({
|
|
2628
2633
|
name: "cpggen",
|
|
@@ -2727,7 +2732,7 @@ test("parse scala sbt list", () => {
|
|
|
2727
2732
|
});
|
|
2728
2733
|
|
|
2729
2734
|
test("parse scala sbt tree", () => {
|
|
2730
|
-
|
|
2735
|
+
const retMap = parseSbtTree("./test/data/atom-sbt-tree.txt");
|
|
2731
2736
|
expect(retMap.pkgList.length).toEqual(153);
|
|
2732
2737
|
expect(retMap.dependenciesList.length).toEqual(153);
|
|
2733
2738
|
});
|
|
@@ -2788,7 +2793,7 @@ test("parse bazel build", () => {
|
|
|
2788
2793
|
expect(projs[0]).toEqual("java-maven-lib");
|
|
2789
2794
|
});
|
|
2790
2795
|
|
|
2791
|
-
test("parse helm charts",
|
|
2796
|
+
test("parse helm charts", () => {
|
|
2792
2797
|
let dep_list = parseHelmYamlData(
|
|
2793
2798
|
readFileSync("./test/data/Chart.yaml", { encoding: "utf-8" })
|
|
2794
2799
|
);
|
|
@@ -2819,7 +2824,7 @@ test("parse helm charts", async () => {
|
|
|
2819
2824
|
});
|
|
2820
2825
|
});
|
|
2821
2826
|
|
|
2822
|
-
test("parse container spec like files",
|
|
2827
|
+
test("parse container spec like files", () => {
|
|
2823
2828
|
let dep_list = parseContainerSpecData(
|
|
2824
2829
|
readFileSync("./test/data/docker-compose.yml", { encoding: "utf-8" })
|
|
2825
2830
|
);
|
|
@@ -2905,8 +2910,8 @@ test("parse container spec like files", async () => {
|
|
|
2905
2910
|
});
|
|
2906
2911
|
});
|
|
2907
2912
|
|
|
2908
|
-
test("parse containerfiles / dockerfiles",
|
|
2909
|
-
|
|
2913
|
+
test("parse containerfiles / dockerfiles", () => {
|
|
2914
|
+
const dep_list = parseContainerFile(
|
|
2910
2915
|
readFileSync("./test/data/Dockerfile", { encoding: "utf-8" })
|
|
2911
2916
|
);
|
|
2912
2917
|
expect(dep_list.length).toEqual(5);
|
|
@@ -2930,8 +2935,8 @@ test("parse containerfiles / dockerfiles", async () => {
|
|
|
2930
2935
|
});
|
|
2931
2936
|
});
|
|
2932
2937
|
|
|
2933
|
-
test("parse bitbucket-pipelines",
|
|
2934
|
-
|
|
2938
|
+
test("parse bitbucket-pipelines", () => {
|
|
2939
|
+
const dep_list = parseBitbucketPipelinesFile(
|
|
2935
2940
|
readFileSync("./test/data/bitbucket-pipelines.yml", { encoding: "utf-8" })
|
|
2936
2941
|
);
|
|
2937
2942
|
expect(dep_list.length).toEqual(5);
|
|
@@ -2952,7 +2957,7 @@ test("parse bitbucket-pipelines", async () => {
|
|
|
2952
2957
|
});
|
|
2953
2958
|
});
|
|
2954
2959
|
|
|
2955
|
-
test("parse cloudbuild data",
|
|
2960
|
+
test("parse cloudbuild data", () => {
|
|
2956
2961
|
expect(parseCloudBuildData(null)).toEqual([]);
|
|
2957
2962
|
const dep_list = parseCloudBuildData(
|
|
2958
2963
|
readFileSync("./test/data/cloudbuild.yaml", { encoding: "utf-8" })
|
|
@@ -2973,7 +2978,7 @@ test("parse privado files", () => {
|
|
|
2973
2978
|
expect(servList[0].properties.length).toEqual(5);
|
|
2974
2979
|
});
|
|
2975
2980
|
|
|
2976
|
-
test("parse openapi spec files",
|
|
2981
|
+
test("parse openapi spec files", () => {
|
|
2977
2982
|
let aservice = parseOpenapiSpecData(
|
|
2978
2983
|
readFileSync("./test/data/openapi/openapi-spec.json", {
|
|
2979
2984
|
encoding: "utf-8"
|
package/validator.js
CHANGED
|
@@ -5,7 +5,7 @@ import { join, dirname } from "node:path";
|
|
|
5
5
|
import { PackageURL } from "packageurl-js";
|
|
6
6
|
import { DEBUG_MODE } from "./utils.js";
|
|
7
7
|
|
|
8
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { fileURLToPath, URL } from "node:url";
|
|
9
9
|
let url = import.meta.url;
|
|
10
10
|
if (!url.startsWith("file://")) {
|
|
11
11
|
url = new URL(`file://${import.meta.url}`).toString();
|
|
@@ -23,14 +23,15 @@ export const validateBom = (bomJson) => {
|
|
|
23
23
|
}
|
|
24
24
|
const schema = JSON.parse(
|
|
25
25
|
readFileSync(
|
|
26
|
-
join(dirName, "data", `bom-${bomJson.specVersion}.schema.json`)
|
|
26
|
+
join(dirName, "data", `bom-${bomJson.specVersion}.schema.json`),
|
|
27
|
+
"utf-8"
|
|
27
28
|
)
|
|
28
29
|
);
|
|
29
30
|
const defsSchema = JSON.parse(
|
|
30
|
-
readFileSync(join(dirName, "data", "jsf-0.82.schema.json"))
|
|
31
|
+
readFileSync(join(dirName, "data", "jsf-0.82.schema.json"), "utf-8")
|
|
31
32
|
);
|
|
32
33
|
const spdxSchema = JSON.parse(
|
|
33
|
-
readFileSync(join(dirName, "data", "spdx.schema.json"))
|
|
34
|
+
readFileSync(join(dirName, "data", "spdx.schema.json"), "utf-8")
|
|
34
35
|
);
|
|
35
36
|
const ajv = new Ajv({
|
|
36
37
|
schemas: [schema, defsSchema, spdxSchema],
|