@cyclonedx/cdxgen 8.5.0 → 8.5.2
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/index.js +19 -18
- package/package.json +1 -1
- package/utils.js +1 -1
- package/utils.test.js +21 -0
package/index.js
CHANGED
|
@@ -1178,6 +1178,18 @@ const createJavaBom = async (path, options) => {
|
|
|
1178
1178
|
qualifiers: { type: "jar" },
|
|
1179
1179
|
...(retMap.metadata || {})
|
|
1180
1180
|
};
|
|
1181
|
+
const parentPurl = decodeURIComponent(
|
|
1182
|
+
new PackageURL(
|
|
1183
|
+
"maven",
|
|
1184
|
+
parentComponent.group || "",
|
|
1185
|
+
parentComponent.name,
|
|
1186
|
+
parentComponent.version,
|
|
1187
|
+
parentComponent.qualifiers,
|
|
1188
|
+
null
|
|
1189
|
+
).toString()
|
|
1190
|
+
);
|
|
1191
|
+
parentComponent["purl"] = parentPurl;
|
|
1192
|
+
parentComponent["bom-ref"] = parentPurl;
|
|
1181
1193
|
}
|
|
1182
1194
|
// Get the sub-project properties and set the root dependencies
|
|
1183
1195
|
if (allProjectsStr && allProjectsStr.length) {
|
|
@@ -1217,28 +1229,17 @@ const createJavaBom = async (path, options) => {
|
|
|
1217
1229
|
return s;
|
|
1218
1230
|
});
|
|
1219
1231
|
dependencies.push({
|
|
1220
|
-
ref:
|
|
1221
|
-
new PackageURL(
|
|
1222
|
-
"maven",
|
|
1223
|
-
parentComponent.group,
|
|
1224
|
-
parentComponent.name,
|
|
1225
|
-
parentComponent.version,
|
|
1226
|
-
parentComponent.qualifiers,
|
|
1227
|
-
null
|
|
1228
|
-
).toString()
|
|
1229
|
-
),
|
|
1232
|
+
ref: parentComponent["bom-ref"],
|
|
1230
1233
|
dependsOn: rootDependsOn
|
|
1231
1234
|
});
|
|
1232
1235
|
}
|
|
1233
1236
|
}
|
|
1234
1237
|
if (gradleFiles && gradleFiles.length && options.installDeps) {
|
|
1235
1238
|
let gradleCmd = utils.getGradleCommand(path, null);
|
|
1236
|
-
|
|
1237
|
-
allProjects.push(parentComponent);
|
|
1238
|
-
}
|
|
1239
|
+
allProjects.push(parentComponent);
|
|
1239
1240
|
for (let sp of allProjects) {
|
|
1240
1241
|
let gradleDepArgs = [
|
|
1241
|
-
sp.
|
|
1242
|
+
sp.purl === parentComponent.purl
|
|
1242
1243
|
? "dependencies"
|
|
1243
1244
|
: `:${sp.name}:dependencies`,
|
|
1244
1245
|
"-q",
|
|
@@ -1302,7 +1303,7 @@ const createJavaBom = async (path, options) => {
|
|
|
1302
1303
|
console.log(
|
|
1303
1304
|
"Obtained",
|
|
1304
1305
|
pkgList.length,
|
|
1305
|
-
"from this gradle
|
|
1306
|
+
"from this gradle project. De-duping this list ..."
|
|
1306
1307
|
);
|
|
1307
1308
|
} else {
|
|
1308
1309
|
console.log(
|
|
@@ -1693,7 +1694,7 @@ const createNodejsBom = async (path, options) => {
|
|
|
1693
1694
|
type: "application"
|
|
1694
1695
|
};
|
|
1695
1696
|
ppurl = new PackageURL(
|
|
1696
|
-
"
|
|
1697
|
+
"npm",
|
|
1697
1698
|
parentComponent.group,
|
|
1698
1699
|
parentComponent.name,
|
|
1699
1700
|
parentComponent.version,
|
|
@@ -1824,7 +1825,7 @@ const createNodejsBom = async (path, options) => {
|
|
|
1824
1825
|
type: "application"
|
|
1825
1826
|
};
|
|
1826
1827
|
ppurl = new PackageURL(
|
|
1827
|
-
"
|
|
1828
|
+
"npm",
|
|
1828
1829
|
parentComponent.group,
|
|
1829
1830
|
parentComponent.name,
|
|
1830
1831
|
parentComponent.version,
|
|
@@ -1852,7 +1853,7 @@ const createNodejsBom = async (path, options) => {
|
|
|
1852
1853
|
// Fixes: 212. Handle case where there are no package.json to determine the parent package
|
|
1853
1854
|
if (Object.keys(parentComponent).length && parentComponent.name) {
|
|
1854
1855
|
const ppurl = new PackageURL(
|
|
1855
|
-
"
|
|
1856
|
+
"npm",
|
|
1856
1857
|
parentComponent.group,
|
|
1857
1858
|
parentComponent.name,
|
|
1858
1859
|
parentComponent.version,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cyclonedx/cdxgen",
|
|
3
|
-
"version": "8.5.
|
|
3
|
+
"version": "8.5.2",
|
|
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
|
@@ -1533,7 +1533,7 @@ const parseGradleProperties = function (rawOutput) {
|
|
|
1533
1533
|
const spStrs = tmpB[1].replace(/[[\]']/g, "").split(", ");
|
|
1534
1534
|
const tmpprojects = spStrs
|
|
1535
1535
|
.flatMap((s) => s.replace("project ", ""))
|
|
1536
|
-
.filter((s) =>
|
|
1536
|
+
.filter((s) => ![":app", ""].includes(s.trim()));
|
|
1537
1537
|
tmpprojects.forEach(projects.add, projects);
|
|
1538
1538
|
}
|
|
1539
1539
|
}
|
package/utils.test.js
CHANGED
|
@@ -310,6 +310,27 @@ test("parse gradle properties", () => {
|
|
|
310
310
|
]
|
|
311
311
|
}
|
|
312
312
|
});
|
|
313
|
+
retMap = utils.parseGradleProperties(
|
|
314
|
+
fs.readFileSync("./test/data/gradle-properties-single2.txt", {
|
|
315
|
+
encoding: "utf-8"
|
|
316
|
+
})
|
|
317
|
+
);
|
|
318
|
+
expect(retMap).toEqual({
|
|
319
|
+
rootProject: "java-test",
|
|
320
|
+
projects: [],
|
|
321
|
+
metadata: {
|
|
322
|
+
group: "com.ajmalab.demo",
|
|
323
|
+
version: "latest",
|
|
324
|
+
properties: [
|
|
325
|
+
{
|
|
326
|
+
name: "buildFile",
|
|
327
|
+
value: "/home/almalinux/work/sandbox/java-test/build.gradle"
|
|
328
|
+
},
|
|
329
|
+
{ name: "projectDir", value: "/home/almalinux/work/sandbox/java-test" },
|
|
330
|
+
{ name: "rootDir", value: "/home/almalinux/work/sandbox/java-test" }
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
});
|
|
313
334
|
retMap = utils.parseGradleProperties(
|
|
314
335
|
fs.readFileSync("./test/data/gradle-properties-elastic.txt", {
|
|
315
336
|
encoding: "utf-8"
|