@cyclonedx/cdxgen 8.0.5 → 8.1.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/index.js CHANGED
@@ -2108,7 +2108,7 @@ const createGoBom = async (path, options) => {
2108
2108
  for (let f of gomodFiles) {
2109
2109
  const basePath = pathLib.dirname(f);
2110
2110
  // Ignore vendor packages
2111
- if (basePath.includes("vendor") || basePath.includes("build")) {
2111
+ if (basePath.includes("/vendor/") || basePath.includes("/build/")) {
2112
2112
  continue;
2113
2113
  }
2114
2114
  if (DEBUG_MODE) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cyclonedx/cdxgen",
3
- "version": "8.0.5",
3
+ "version": "8.1.0",
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
@@ -477,7 +477,7 @@ const yarnLockToIdentMap = function (lockData) {
477
477
  s = s.substring(0, s.length - 1);
478
478
  }
479
479
  // Non-strict mode parsing
480
- const match = s.match(/^(?:@([^/]+?)\/)?([^/]+?)(?:@(.+))?$/);
480
+ const match = s.match(/^(?:(@[^/]+?)\/)?([^/]+?)(?:@(.+))?$/);
481
481
  if (!match) {
482
482
  continue;
483
483
  }
@@ -488,7 +488,7 @@ const yarnLockToIdentMap = function (lockData) {
488
488
  if (range && range.startsWith("npm:")) {
489
489
  range = range.replace("npm:", "");
490
490
  }
491
- currentIdents.push(`${group || ""}${name}@${range}`);
491
+ currentIdents.push(`${group || ""}${name}|${range}`);
492
492
  }
493
493
  }
494
494
  }
@@ -525,6 +525,7 @@ const parseYarnLock = async function (yarnLockFile) {
525
525
  let deplist = [];
526
526
  // This would have the keys and the resolved version required to solve the dependency tree
527
527
  const identMap = yarnLockToIdentMap(lockData);
528
+ let prefixAtSymbol = false;
528
529
  lockData.split("\n").forEach((l) => {
529
530
  if (l === "\n" || l.startsWith("#")) {
530
531
  return;
@@ -575,7 +576,9 @@ const parseYarnLock = async function (yarnLockFile) {
575
576
  depsMode = false;
576
577
  }
577
578
  // Collect the group and the name
578
- const tmpA = l.replace(/["']/g, "").split("@");
579
+ l = l.replace(/["']/g, "");
580
+ prefixAtSymbol = l.startsWith("@");
581
+ const tmpA = l.split("@");
579
582
  // ignore possible leading empty strings
580
583
  if (tmpA[0] === "") {
581
584
  tmpA.shift();
@@ -584,7 +587,7 @@ const parseYarnLock = async function (yarnLockFile) {
584
587
  const fullName = tmpA[0];
585
588
  if (fullName.indexOf("/") > -1) {
586
589
  const parts = fullName.split("/");
587
- group = parts[0];
590
+ group = (prefixAtSymbol ? "@" : "") + parts[0];
588
591
  name = parts[1];
589
592
  } else {
590
593
  name = fullName;
@@ -598,13 +601,10 @@ const parseYarnLock = async function (yarnLockFile) {
598
601
  const tmpA = l.trim().replace(/["']/g, "").split(" ");
599
602
  if (tmpA && tmpA.length === 2) {
600
603
  let dgroupname = tmpA[0];
601
- if (dgroupname.startsWith("@")) {
602
- dgroupname = dgroupname.substring(1);
603
- }
604
604
  if (dgroupname.endsWith(":")) {
605
605
  dgroupname = dgroupname.substring(0, dgroupname.length - 1);
606
606
  }
607
- const resolvedVersion = identMap[`${dgroupname}@${tmpA[1]}`];
607
+ const resolvedVersion = identMap[`${dgroupname}|${tmpA[1]}`];
608
608
  const depPurlString = new PackageURL(
609
609
  "npm",
610
610
  null,
package/utils.test.js CHANGED
@@ -1133,7 +1133,7 @@ test("parseYarnLock", async () => {
1133
1133
  expect(parsedList.pkgList.length).toEqual(2029);
1134
1134
  expect(parsedList.dependenciesList.length).toEqual(2029);
1135
1135
  expect(parsedList.pkgList[0]).toEqual({
1136
- group: "babel",
1136
+ group: "@babel",
1137
1137
  name: "cli",
1138
1138
  version: "7.10.1",
1139
1139
  _integrity:
@@ -1158,7 +1158,7 @@ test("parseYarnLock", async () => {
1158
1158
  expect(parsedList.pkgList[0]).toEqual({
1159
1159
  _integrity:
1160
1160
  "sha512-zpruxnFMz6K94gs2pqc3sidzFDbQpKT5D6P/J/I9s8ekHZ5eczgnRp6pqXC86Bh7+44j/btpmOT0kwiboyqTnA==",
1161
- group: "apollo",
1161
+ group: "@apollo",
1162
1162
  name: "client",
1163
1163
  version: "3.2.5",
1164
1164
  properties: [
@@ -1177,7 +1177,7 @@ test("parseYarnLock", async () => {
1177
1177
  expect(parsedList.pkgList[0]).toEqual({
1178
1178
  _integrity:
1179
1179
  "sha512-rZ1k9kQvJX21Vwgx1L6kSQ6yeXo9cCMyqURSnjG+MRoJn+Mr3LblxmVdzScHXRzv0N9yzy49oG7Bqxp9Knyv/g==",
1180
- group: "actions",
1180
+ group: "@actions",
1181
1181
  name: "artifact",
1182
1182
  version: "0.6.1",
1183
1183
  properties: [
@@ -1211,7 +1211,7 @@ test("parseYarnLock", async () => {
1211
1211
  expect(parsedList.pkgList[0]).toEqual({
1212
1212
  _integrity:
1213
1213
  "sha512-G0U5NjBUYIs39l1J1ckgpVfVX2IxpzRAIT4/2An86O2Mcri3k5xNu7/RRkfObo12wN9s7BmnREAMhH7252oZiA==",
1214
- group: "arcanis",
1214
+ group: "@arcanis",
1215
1215
  name: "slice-ansi",
1216
1216
  version: "1.0.2",
1217
1217
  properties: [
@@ -1227,7 +1227,7 @@ test("parseYarnLock", async () => {
1227
1227
  expect(parsedList.pkgList[0]).toEqual({
1228
1228
  _integrity:
1229
1229
  "sha512-vtU+q0TmdIDmezU7lKub73vObN6nmd3lkcKWz7R9hyNI8gz5o7grDb+FML9nykOLW+09gGIup2xyJ86j5vBKpg==",
1230
- group: "babel",
1230
+ group: "@babel",
1231
1231
  name: "code-frame",
1232
1232
  version: "7.16.7",
1233
1233
  properties: [
@@ -1239,6 +1239,19 @@ test("parseYarnLock", async () => {
1239
1239
  });
1240
1240
  parsedList = await utils.parseYarnLock("./test/data/yarn_locks/yarn4.lock");
1241
1241
  expect(parsedList.pkgList.length).toEqual(1);
1242
+ parsedList = await utils.parseYarnLock("./test/data/yarn_locks/yarn-at.lock");
1243
+ expect(parsedList.pkgList.length).toEqual(4);
1244
+ expect(parsedList.dependenciesList.length).toEqual(4);
1245
+ expect(parsedList.pkgList[0]).toEqual({
1246
+ group: "@ac-synth",
1247
+ name: "yjs",
1248
+ version: "13.5.39-alpha1",
1249
+ _integrity:
1250
+ "sha512-JE93VWVyVa07xkK1wJ5ogjSZ30Nn4ptUuUXdPnu8MsKme1xFHLFFD3UtnHxnxnNDSnGx+WLlhuyHdIFfSCYqYg==",
1251
+ properties: [
1252
+ { name: "SrcFile", value: "./test/data/yarn_locks/yarn-at.lock" }
1253
+ ]
1254
+ });
1242
1255
  });
1243
1256
 
1244
1257
  test("parseComposerLock", () => {