@cyclonedx/cdxgen 9.0.0 → 9.0.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 +1 -5
- package/data/lic-mapping.json +6 -1
- package/index.js +2 -2
- package/package.json +1 -1
- package/utils.js +88 -40
- package/utils.test.js +2 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
This tool creates a valid and compliant [CycloneDX][cyclonedx-homepage] Software Bill-of-Materials (SBOM) containing an aggregate of all project dependencies for c/c++, node.js, php, python, ruby, rust, java, .Net, dart, haskell, elixir, and Go projects in XML and JSON format. CycloneDX 1.
|
|
5
|
+
This tool creates a valid and compliant [CycloneDX][cyclonedx-homepage] Software Bill-of-Materials (SBOM) containing an aggregate of all project dependencies for c/c++, node.js, php, python, ruby, rust, java, .Net, dart, haskell, elixir, and Go projects in XML and JSON format. CycloneDX 1.5 is a lightweight SBOM specification that is easily created, human and machine-readable, and simple to parse.
|
|
6
6
|
|
|
7
7
|
When used with plugins, cdxgen could generate an SBoM for Linux docker images and even VMs running Linux or Windows operating system.
|
|
8
8
|
|
|
@@ -132,10 +132,6 @@ Minimal example.
|
|
|
132
132
|
cdxgen -o bom.json
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
-
NOTE:
|
|
136
|
-
|
|
137
|
-
cdxgen would always produce bom in both xml and json format as per CycloneDX 1.4 specification. json is the recommended format.
|
|
138
|
-
|
|
139
135
|
For a java project. This would automatically detect maven, gradle or sbt and build bom accordingly
|
|
140
136
|
|
|
141
137
|
```shell
|
package/data/lic-mapping.json
CHANGED
|
@@ -17,7 +17,12 @@
|
|
|
17
17
|
"The Apache License, Version 2.0",
|
|
18
18
|
"BSD or Apache License, Version 2.0",
|
|
19
19
|
"Apache Software License",
|
|
20
|
-
"Apache-2.0 OR MIT"
|
|
20
|
+
"Apache-2.0 OR MIT",
|
|
21
|
+
"Apache2.0",
|
|
22
|
+
"apache-2-0",
|
|
23
|
+
"https://opensource.org/licenses/Apache2.0",
|
|
24
|
+
"https://opensource.org/license/apache-2-0",
|
|
25
|
+
"http://www.apache.org/licenses/LICENSE-2.0.html"
|
|
21
26
|
]
|
|
22
27
|
},
|
|
23
28
|
{
|
package/index.js
CHANGED
|
@@ -912,7 +912,7 @@ const buildBomXml = (
|
|
|
912
912
|
const bom = create("bom", {
|
|
913
913
|
encoding: "utf-8",
|
|
914
914
|
separateArrayItems: true
|
|
915
|
-
}).att("xmlns", "http://cyclonedx.org/schema/bom/1.
|
|
915
|
+
}).att("xmlns", "http://cyclonedx.org/schema/bom/1.5");
|
|
916
916
|
bom.att("serialNumber", serialNum);
|
|
917
917
|
bom.att("version", 1);
|
|
918
918
|
const metadata = addMetadata(parentComponent, "xml", options);
|
|
@@ -977,7 +977,7 @@ const buildBomNSData = (options, pkgInfo, ptype, context) => {
|
|
|
977
977
|
context,
|
|
978
978
|
options
|
|
979
979
|
);
|
|
980
|
-
// CycloneDX 1.
|
|
980
|
+
// CycloneDX 1.5 Json Template
|
|
981
981
|
const jsonTpl = {
|
|
982
982
|
bomFormat: "CycloneDX",
|
|
983
983
|
specVersion: "1.5",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyclonedx/cdxgen",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "Creates CycloneDX Software Bill-of-Materials (SBOM) from source or container image",
|
|
5
5
|
"homepage": "http://github.com/cyclonedx/cdxgen",
|
|
6
6
|
"author": "Prabhu Subramanian <prabhu@appthreat.com>",
|
package/utils.js
CHANGED
|
@@ -4019,52 +4019,100 @@ export const getNugetMetadata = async function (pkgList) {
|
|
|
4019
4019
|
const NUGET_URL = "https://api.nuget.org/v3/registration3/";
|
|
4020
4020
|
const cdepList = [];
|
|
4021
4021
|
for (const p of pkgList) {
|
|
4022
|
+
let cacheKey = undefined;
|
|
4022
4023
|
try {
|
|
4023
|
-
if (DEBUG_MODE) {
|
|
4024
|
-
console.log(`Querying nuget for ${p.name}`);
|
|
4025
|
-
}
|
|
4026
|
-
const res = await cdxgenAgent.get(
|
|
4027
|
-
NUGET_URL +
|
|
4028
|
-
p.group.toLowerCase() +
|
|
4029
|
-
(p.group !== "" ? "." : "") +
|
|
4030
|
-
p.name.toLowerCase() +
|
|
4031
|
-
"/index.json",
|
|
4032
|
-
{ responseType: "json" }
|
|
4033
|
-
);
|
|
4034
|
-
const items = res.body.items;
|
|
4035
|
-
if (!items || !items[0] || !items[0].items) {
|
|
4036
|
-
continue;
|
|
4037
|
-
}
|
|
4038
|
-
const firstItem = items[0];
|
|
4039
|
-
const body = firstItem.items[firstItem.items.length - 1];
|
|
4040
|
-
// Set the latest version in case it is missing
|
|
4041
|
-
if (!p.version && body.catalogEntry.version) {
|
|
4042
|
-
p.version = body.catalogEntry.version;
|
|
4043
|
-
}
|
|
4044
|
-
p.description = body.catalogEntry.description;
|
|
4045
4024
|
if (
|
|
4046
|
-
|
|
4047
|
-
|
|
4025
|
+
(p.group && p.group.toLowerCase() === "system") ||
|
|
4026
|
+
p.name.toLowerCase().startsWith("system")
|
|
4048
4027
|
) {
|
|
4049
|
-
p.license =
|
|
4050
|
-
} else if (
|
|
4051
|
-
p.
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
p.
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4028
|
+
p.license = "http://go.microsoft.com/fwlink/?LinkId=329770";
|
|
4029
|
+
} else if (
|
|
4030
|
+
(p.group && p.group.toLowerCase() === "microsoft") ||
|
|
4031
|
+
p.name.toLowerCase().startsWith("microsoft")
|
|
4032
|
+
) {
|
|
4033
|
+
p.license =
|
|
4034
|
+
"http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm";
|
|
4035
|
+
} else if (
|
|
4036
|
+
(p.group && p.group.toLowerCase() === "nuget") ||
|
|
4037
|
+
p.name.toLowerCase().startsWith("nuget")
|
|
4038
|
+
) {
|
|
4039
|
+
p.license = "Apache-2.0";
|
|
4040
|
+
} else {
|
|
4041
|
+
// If there is a version, we can safely use the cache to retrieve the license
|
|
4042
|
+
// See: https://github.com/CycloneDX/cdxgen/issues/352
|
|
4043
|
+
const twoPartName = p.name.split(".").slice(0, 2).join(".");
|
|
4044
|
+
cacheKey = `${p.group}|${twoPartName}`;
|
|
4045
|
+
let body = metadata_cache[cacheKey];
|
|
4046
|
+
if (body && body.error) {
|
|
4047
|
+
cdepList.push(p);
|
|
4048
|
+
continue;
|
|
4049
|
+
}
|
|
4050
|
+
if (!body) {
|
|
4051
|
+
if (DEBUG_MODE) {
|
|
4052
|
+
console.log(`Querying nuget for ${p.name}`);
|
|
4053
|
+
}
|
|
4054
|
+
const res = await cdxgenAgent.get(
|
|
4055
|
+
NUGET_URL +
|
|
4056
|
+
p.group.toLowerCase() +
|
|
4057
|
+
(p.group !== "" ? "." : "") +
|
|
4058
|
+
p.name.toLowerCase() +
|
|
4059
|
+
"/index.json",
|
|
4060
|
+
{ responseType: "json" }
|
|
4061
|
+
);
|
|
4062
|
+
const items = res.body.items;
|
|
4063
|
+
if (!items || !items[0] || !items[0].items) {
|
|
4064
|
+
continue;
|
|
4065
|
+
}
|
|
4066
|
+
const firstItem = items[0];
|
|
4067
|
+
// Work backwards to find the body for the matching version
|
|
4068
|
+
body = firstItem.items[firstItem.items.length - 1];
|
|
4069
|
+
if (p.version) {
|
|
4070
|
+
const newBody = firstItem.items
|
|
4071
|
+
.reverse()
|
|
4072
|
+
.filter(
|
|
4073
|
+
(i) => i.catalogEntry && i.catalogEntry.version === p.version
|
|
4074
|
+
);
|
|
4075
|
+
if (newBody && newBody.length) {
|
|
4076
|
+
body = newBody[0];
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
metadata_cache[cacheKey] = body;
|
|
4080
|
+
}
|
|
4081
|
+
// Set the latest version in case it is missing
|
|
4082
|
+
if (!p.version && body.catalogEntry.version) {
|
|
4083
|
+
p.version = body.catalogEntry.version;
|
|
4084
|
+
}
|
|
4085
|
+
p.description = body.catalogEntry.description;
|
|
4086
|
+
if (body.catalogEntry.authors) {
|
|
4087
|
+
p.author = body.catalogEntry.authors.trim();
|
|
4088
|
+
}
|
|
4089
|
+
if (
|
|
4090
|
+
body.catalogEntry.licenseExpression &&
|
|
4091
|
+
body.catalogEntry.licenseExpression !== ""
|
|
4092
|
+
) {
|
|
4093
|
+
p.license = findLicenseId(body.catalogEntry.licenseExpression);
|
|
4094
|
+
} else if (body.catalogEntry.licenseUrl) {
|
|
4095
|
+
p.license = findLicenseId(body.catalogEntry.licenseUrl);
|
|
4096
|
+
}
|
|
4097
|
+
if (body.catalogEntry.projectUrl) {
|
|
4098
|
+
p.repository = { url: body.catalogEntry.projectUrl };
|
|
4099
|
+
p.homepage = {
|
|
4100
|
+
url:
|
|
4101
|
+
"https://www.nuget.org/packages/" +
|
|
4102
|
+
p.group +
|
|
4103
|
+
(p.group !== "" ? "." : "") +
|
|
4104
|
+
p.name +
|
|
4105
|
+
"/" +
|
|
4106
|
+
p.version +
|
|
4107
|
+
"/"
|
|
4108
|
+
};
|
|
4109
|
+
}
|
|
4065
4110
|
}
|
|
4066
4111
|
cdepList.push(p);
|
|
4067
4112
|
} catch (err) {
|
|
4113
|
+
if (cacheKey) {
|
|
4114
|
+
metadata_cache[cacheKey] = { error: err.code };
|
|
4115
|
+
}
|
|
4068
4116
|
cdepList.push(p);
|
|
4069
4117
|
}
|
|
4070
4118
|
}
|
package/utils.test.js
CHANGED
|
@@ -1107,6 +1107,7 @@ test("get nget metadata", async () => {
|
|
|
1107
1107
|
]);
|
|
1108
1108
|
expect(dep_list.length).toEqual(1);
|
|
1109
1109
|
expect(dep_list[0]).toEqual({
|
|
1110
|
+
author: "Castle Project Contributors",
|
|
1110
1111
|
group: "",
|
|
1111
1112
|
name: "Castle.Core",
|
|
1112
1113
|
version: "4.4.0",
|
|
@@ -1115,7 +1116,7 @@ test("get nget metadata", async () => {
|
|
|
1115
1116
|
homepage: {
|
|
1116
1117
|
url: "https://www.nuget.org/packages/Castle.Core/4.4.0/"
|
|
1117
1118
|
},
|
|
1118
|
-
license: "
|
|
1119
|
+
license: "Apache-2.0",
|
|
1119
1120
|
repository: {
|
|
1120
1121
|
url: "http://www.castleproject.org/"
|
|
1121
1122
|
}
|