@cyclonedx/cdxgen 12.4.3 → 12.4.4

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 (38) hide show
  1. package/README.md +6 -0
  2. package/bin/audit.js +7 -0
  3. package/bin/cdxgen.js +48 -2
  4. package/bin/evinse.js +7 -0
  5. package/lib/audit/index.js +165 -2
  6. package/lib/audit/index.poku.js +462 -0
  7. package/lib/cli/index.js +317 -169
  8. package/lib/evinser/evinser.js +31 -9
  9. package/lib/helpers/analyzer.js +890 -0
  10. package/lib/helpers/analyzer.poku.js +341 -0
  11. package/lib/helpers/atomUtils.js +445 -0
  12. package/lib/helpers/atomUtils.poku.js +137 -0
  13. package/lib/helpers/bomUtils.js +71 -0
  14. package/lib/helpers/bomUtils.poku.js +45 -0
  15. package/lib/helpers/depsUtils.js +146 -0
  16. package/lib/helpers/depsUtils.poku.js +183 -0
  17. package/lib/helpers/utils.js +585 -191
  18. package/lib/helpers/utils.poku.js +357 -4
  19. package/lib/managers/binary.js +18 -9
  20. package/lib/stages/postgen/postgen.js +215 -0
  21. package/lib/stages/postgen/postgen.poku.js +218 -3
  22. package/lib/validator/bomValidator.js +11 -2
  23. package/package.json +8 -8
  24. package/types/lib/audit/index.d.ts.map +1 -1
  25. package/types/lib/cli/index.d.ts.map +1 -1
  26. package/types/lib/helpers/analyzer.d.ts.map +1 -1
  27. package/types/lib/helpers/atomUtils.d.ts +18 -0
  28. package/types/lib/helpers/atomUtils.d.ts.map +1 -0
  29. package/types/lib/helpers/bomUtils.d.ts +10 -0
  30. package/types/lib/helpers/bomUtils.d.ts.map +1 -1
  31. package/types/lib/helpers/depsUtils.d.ts +9 -0
  32. package/types/lib/helpers/depsUtils.d.ts.map +1 -1
  33. package/types/lib/helpers/utils.d.ts +19 -0
  34. package/types/lib/helpers/utils.d.ts.map +1 -1
  35. package/types/lib/managers/binary.d.ts +2 -1
  36. package/types/lib/managers/binary.d.ts.map +1 -1
  37. package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
  38. package/types/lib/validator/bomValidator.d.ts.map +1 -1
@@ -4,6 +4,10 @@ import process from "node:process";
4
4
 
5
5
  import { PackageURL } from "packageurl-js";
6
6
 
7
+ import {
8
+ buildAtomCommandEnv,
9
+ filterAtomSlicesByExcludePatterns,
10
+ } from "../helpers/atomUtils.js";
7
11
  import {
8
12
  collectDosaiCryptoComponents,
9
13
  findCryptoAlgos,
@@ -41,6 +45,10 @@ import { createSemanticsSlices } from "./swiftsem.js";
41
45
 
42
46
  const typePurlsCache = {};
43
47
 
48
+ function filterAtomSliceData(sliceData, options = {}) {
49
+ return filterAtomSlicesByExcludePatterns(sliceData, options.exclude);
50
+ }
51
+
44
52
  /**
45
53
  * Function to create the db for the libraries referred in the sbom.
46
54
  *
@@ -357,8 +365,10 @@ export async function createSlice(
357
365
  args.push(process.env.ATOM_SLICE_DEPTH);
358
366
  }
359
367
  args.push(resolve(filePath));
368
+ const atomExcludeEnv = buildAtomCommandEnv(options, language);
360
369
  // Execute atom
361
370
  const result = executeAtom(filePath, args, {
371
+ ...atomExcludeEnv,
362
372
  ATOM_TOOLS_OPENAPI_FILENAME: openapiSpecFile, // The file would get over-written
363
373
  ATOM_TOOLS_OPENAPI_FORMAT:
364
374
  process.env?.ATOM_TOOLS_OPENAPI_FORMAT || "openapi3.1.0", // editor.swagger.io doesn't support 3.1.0 yet
@@ -597,15 +607,17 @@ export async function analyzeProject(dbObjMap, options) {
597
607
  usableSlicesFile(options.reachablesSlicesFile)
598
608
  ) {
599
609
  reachablesSlicesFile = options.reachablesSlicesFile;
600
- reachablesSlice = JSON.parse(
601
- fs.readFileSync(options.reachablesSlicesFile, "utf-8"),
610
+ reachablesSlice = filterAtomSliceData(
611
+ JSON.parse(fs.readFileSync(options.reachablesSlicesFile, "utf-8")),
612
+ options,
602
613
  );
603
614
  } else {
604
615
  retMap = await createSlice(language, dirPath, "reachables", options);
605
616
  if (retMap?.slicesFile && safeExistsSync(retMap.slicesFile)) {
606
617
  reachablesSlicesFile = retMap.slicesFile;
607
- reachablesSlice = JSON.parse(
608
- fs.readFileSync(retMap.slicesFile, "utf-8"),
618
+ reachablesSlice = filterAtomSliceData(
619
+ JSON.parse(fs.readFileSync(retMap.slicesFile, "utf-8")),
620
+ options,
609
621
  );
610
622
  }
611
623
  }
@@ -618,13 +630,19 @@ export async function analyzeProject(dbObjMap, options) {
618
630
  }
619
631
  // Reuse existing usages slices
620
632
  if (options.usagesSlicesFile && usableSlicesFile(options.usagesSlicesFile)) {
621
- usageSlice = JSON.parse(fs.readFileSync(options.usagesSlicesFile, "utf-8"));
633
+ usageSlice = filterAtomSliceData(
634
+ JSON.parse(fs.readFileSync(options.usagesSlicesFile, "utf-8")),
635
+ options,
636
+ );
622
637
  usagesSlicesFile = options.usagesSlicesFile;
623
638
  } else {
624
639
  // Generate our own slices
625
640
  retMap = await createSlice(language, dirPath, "usages", options);
626
641
  if (retMap?.slicesFile && safeExistsSync(retMap.slicesFile)) {
627
- usageSlice = JSON.parse(fs.readFileSync(retMap.slicesFile, "utf-8"));
642
+ usageSlice = filterAtomSliceData(
643
+ JSON.parse(fs.readFileSync(retMap.slicesFile, "utf-8")),
644
+ options,
645
+ );
628
646
  usagesSlicesFile = retMap.slicesFile;
629
647
  }
630
648
  if (retMap?.semanticsSlicesFile) {
@@ -698,14 +716,18 @@ export async function analyzeProject(dbObjMap, options) {
698
716
  safeExistsSync(options.dataFlowSlicesFile)
699
717
  ) {
700
718
  dataFlowSlicesFile = options.dataFlowSlicesFile;
701
- dataFlowSlice = JSON.parse(
702
- fs.readFileSync(options.dataFlowSlicesFile, "utf-8"),
719
+ dataFlowSlice = filterAtomSliceData(
720
+ JSON.parse(fs.readFileSync(options.dataFlowSlicesFile, "utf-8")),
721
+ options,
703
722
  );
704
723
  } else if (!PROJECT_TYPE_ALIASES.scala.includes(language)) {
705
724
  retMap = await createSlice(language, dirPath, "data-flow", options);
706
725
  if (retMap?.slicesFile && safeExistsSync(retMap.slicesFile)) {
707
726
  dataFlowSlicesFile = retMap.slicesFile;
708
- dataFlowSlice = JSON.parse(fs.readFileSync(retMap.slicesFile, "utf-8"));
727
+ dataFlowSlice = filterAtomSliceData(
728
+ JSON.parse(fs.readFileSync(retMap.slicesFile, "utf-8")),
729
+ options,
730
+ );
709
731
  }
710
732
  }
711
733
  }