@cyclonedx/cdxgen 12.1.1 → 12.1.3

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.
Files changed (45) hide show
  1. package/README.md +27 -9
  2. package/bin/cdxgen.js +1 -1
  3. package/data/spdx.schema.json +35 -2
  4. package/data/templates/asvs-5.0.cdx.json +1727 -3471
  5. package/lib/cli/index.js +32 -4
  6. package/lib/evinser/evinser.js +2 -8
  7. package/lib/helpers/display.js +1 -1
  8. package/lib/helpers/envcontext.js +10 -2
  9. package/lib/helpers/utils.js +487 -115
  10. package/lib/helpers/utils.poku.js +200 -3
  11. package/lib/helpers/validator.js +37 -3
  12. package/lib/managers/binary.js +34 -12
  13. package/lib/managers/containerutils.js +68 -0
  14. package/lib/managers/docker.getConnection.poku.js +61 -0
  15. package/lib/managers/docker.js +72 -119
  16. package/lib/parsers/iri.js +1 -2
  17. package/lib/server/server.js +164 -34
  18. package/lib/server/server.poku.js +232 -10
  19. package/lib/stages/postgen/annotator.js +281 -3
  20. package/lib/stages/postgen/postgen.js +4 -7
  21. package/lib/third-party/arborist/lib/diff.js +1 -1
  22. package/lib/third-party/arborist/lib/node.js +1 -1
  23. package/lib/third-party/arborist/lib/yarn-lock.js +1 -1
  24. package/package.json +22 -326
  25. package/types/bin/dependencies.d.ts.map +1 -1
  26. package/types/bin/licenses.d.ts +3 -0
  27. package/types/bin/licenses.d.ts.map +1 -0
  28. package/types/lib/cli/index.d.ts.map +1 -1
  29. package/types/lib/evinser/evinser.d.ts.map +1 -1
  30. package/types/lib/helpers/envcontext.d.ts.map +1 -1
  31. package/types/lib/helpers/utils.d.ts +1 -1
  32. package/types/lib/helpers/utils.d.ts.map +1 -1
  33. package/types/lib/helpers/validator.d.ts.map +1 -1
  34. package/types/lib/managers/binary.d.ts.map +1 -1
  35. package/types/lib/managers/containerutils.d.ts +3 -0
  36. package/types/lib/managers/containerutils.d.ts.map +1 -0
  37. package/types/lib/managers/docker.d.ts +0 -2
  38. package/types/lib/managers/docker.d.ts.map +1 -1
  39. package/types/lib/parsers/iri.d.ts.map +1 -1
  40. package/types/lib/server/server.d.ts +14 -0
  41. package/types/lib/server/server.d.ts.map +1 -1
  42. package/types/lib/stages/postgen/annotator.d.ts.map +1 -1
  43. package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
  44. package/bin/dependencies.js +0 -131
  45. package/lib/helpers/dependencies.poku.js +0 -11
package/lib/cli/index.js CHANGED
@@ -3957,7 +3957,7 @@ export async function createPythonBom(path, options) {
3957
3957
  metadataFilename = reqDirFiles.join(", ");
3958
3958
  } else if (reqFiles?.length) {
3959
3959
  for (const f of reqFiles) {
3960
- const dlist = await parseReqFile(f, true);
3960
+ const dlist = await parseReqFile(f, false);
3961
3961
  if (dlist?.length) {
3962
3962
  pkgList = pkgList.concat(dlist);
3963
3963
  }
@@ -4379,7 +4379,7 @@ export async function createGoBom(path, options) {
4379
4379
  ) {
4380
4380
  for (const f of sortedGomodFiles) {
4381
4381
  const basePath = dirname(f);
4382
- // Ignore vendor packages
4382
+ // Ignore vendor packages and test fixtures
4383
4383
  if (
4384
4384
  basePath.includes("/vendor/") ||
4385
4385
  basePath.includes("/build/") ||
@@ -4391,13 +4391,14 @@ export async function createGoBom(path, options) {
4391
4391
  if (DEBUG_MODE) {
4392
4392
  console.log("Executing go list -deps in", basePath);
4393
4393
  }
4394
+ // TODO: Replacing this with -json gives us more interesting data points such as GoFiles, Imports, and Deps
4394
4395
  let result = safeSpawnSync(
4395
4396
  "go",
4396
4397
  [
4397
4398
  "list",
4398
4399
  "-deps",
4399
4400
  "-f",
4400
- "'{{with .Module}}{{.Path}} {{.Version}} {{.Indirect}} {{.GoMod}} {{.GoVersion}} {{.Main}}{{end}}'",
4401
+ "'{{with .Module}}{{.Path}}|{{.Version}}|{{.Indirect}}|{{.GoMod}}|{{.GoVersion}}|{{.Main}}|{{.Time}}|{{.Deprecated}}|{{.GoModSum}}|{{.Dir}}{{end}}'",
4401
4402
  "./...",
4402
4403
  ],
4403
4404
  {
@@ -6407,6 +6408,7 @@ export async function createRubyBom(path, options) {
6407
6408
  const gemLockExcludeList = (options.exclude || []).concat([
6408
6409
  "**/vendor/bundle/ruby/**/Gemfile.lock",
6409
6410
  "**/test/data/**/Gemfile*.lock",
6411
+ "**/.rbenv/versions/**/Gemfile.lock",
6410
6412
  ]);
6411
6413
  if (!hasAnyProjectType(["oci"], options, false)) {
6412
6414
  excludeList.push("**/vendor/bundle/**");
@@ -6509,6 +6511,7 @@ export async function createRubyBom(path, options) {
6509
6511
  }
6510
6512
  }
6511
6513
  // Parsing .gemspec files would help us get more metadata such as description, authors, licenses etc
6514
+ let rootGemspecComponent;
6512
6515
  if (gemspecFiles.length) {
6513
6516
  if (!gemLockFiles.length && !hasAnyProjectType(["oci"], options, false)) {
6514
6517
  console.log(
@@ -6522,8 +6525,33 @@ export async function createRubyBom(path, options) {
6522
6525
  if (gpkgList.length) {
6523
6526
  pkgList = pkgList.concat(gpkgList);
6524
6527
  pkgList = trimComponents(pkgList);
6528
+ if (
6529
+ !rootGemspecComponent &&
6530
+ dirname(resolve(f)) === resolve(path) &&
6531
+ gpkgList[0]?.name
6532
+ ) {
6533
+ rootGemspecComponent = gpkgList[0];
6534
+ }
6525
6535
  }
6526
6536
  }
6537
+ if (
6538
+ rootGemspecComponent &&
6539
+ !("project-name" in options) &&
6540
+ options.projectName === undefined
6541
+ ) {
6542
+ parentComponent.name = rootGemspecComponent.name;
6543
+ parentComponent.version = rootGemspecComponent.version || "latest";
6544
+ const parentPurl = new PackageURL(
6545
+ "gem",
6546
+ parentComponent.group,
6547
+ parentComponent.name,
6548
+ parentComponent.version,
6549
+ null,
6550
+ null,
6551
+ ).toString();
6552
+ parentComponent["bom-ref"] = decodeURIComponent(parentPurl);
6553
+ parentComponent["purl"] = parentPurl;
6554
+ }
6527
6555
  }
6528
6556
  if (rootList.length) {
6529
6557
  dependencies = mergeDependencies(
@@ -7033,7 +7061,7 @@ export async function createCsharpBom(path, options) {
7033
7061
  }
7034
7062
  }
7035
7063
  // Parent dependency tree
7036
- if (parentDependsOn.size && parentComponent && parentComponent["bom-ref"]) {
7064
+ if (parentDependsOn.size && parentComponent?.["bom-ref"]) {
7037
7065
  dependencies.splice(0, 0, {
7038
7066
  ref: parentComponent["bom-ref"],
7039
7067
  dependsOn: Array.from(parentDependsOn).sort(),
@@ -1248,8 +1248,7 @@ export function detectServicesFromUsages(language, slice, servicesMap = {}) {
1248
1248
  export function detectServicesFromUDT(language, userDefinedTypes, servicesMap) {
1249
1249
  if (
1250
1250
  ["python", "py", "c", "cpp", "c++", "php", "ruby"].includes(language) &&
1251
- userDefinedTypes &&
1252
- userDefinedTypes.length
1251
+ userDefinedTypes?.length
1253
1252
  ) {
1254
1253
  for (const audt of userDefinedTypes) {
1255
1254
  if (
@@ -1270,12 +1269,7 @@ export function detectServicesFromUDT(language, userDefinedTypes, servicesMap) {
1270
1269
  audt.name.toLowerCase().includes("connect")
1271
1270
  ) {
1272
1271
  const fields = audt.fields || [];
1273
- if (
1274
- fields.length &&
1275
- fields[0] &&
1276
- fields[0].name &&
1277
- fields[0].name.length > 1
1278
- ) {
1272
+ if (fields.length && fields[0]?.name && fields[0].name.length > 1) {
1279
1273
  const endpoints = extractEndpoints(language, fields[0].name);
1280
1274
  let serviceName = "service";
1281
1275
  if (audt.fileName) {
@@ -14,7 +14,7 @@ const SYMBOLS_ANSI = {
14
14
 
15
15
  const MAX_TREE_DEPTH = 6;
16
16
  const highlightStr = (s, highlight) => {
17
- if (highlight && s && s.includes(highlight)) {
17
+ if (highlight && s?.includes(highlight)) {
18
18
  s = s.replaceAll(highlight, `\x1b[1;33m${highlight}\x1b[0m`);
19
19
  }
20
20
  return s;
@@ -200,9 +200,17 @@ export function collectDotnetInfo(dir) {
200
200
  * @returns Object containing python details
201
201
  */
202
202
  export function collectPythonInfo(dir) {
203
- const versionDesc = getCommandOutput(getPythonCommand(), dir, ["--version"]);
203
+ const versionDesc = getCommandOutput(getPythonCommand(), dir, [
204
+ "-S",
205
+ "--version",
206
+ ]);
204
207
  const moduleDesc =
205
- getCommandOutput(getPythonCommand(), dir, ["-m", "pip", "--version"]) || "";
208
+ getCommandOutput(getPythonCommand(), dir, [
209
+ "-S",
210
+ "-m",
211
+ "pip",
212
+ "--version",
213
+ ]) || "";
206
214
  if (versionDesc) {
207
215
  return {
208
216
  type: "platform",