@cyclonedx/cdxgen 11.2.1 → 11.2.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.
package/README.md CHANGED
@@ -147,7 +147,8 @@ Options:
147
147
  --server-host Listen address [default: "127.0.0.1"]
148
148
  --server-port Listen port [default: "9090"]
149
149
  --install-deps Install dependencies automatically for some projects. Defaults to true but disabled for c
150
- ontainers and oci scans. Use --no-install-deps to disable this feature. [boolean]
150
+ ontainers and oci scans. Use --no-install-deps to disable this feature.
151
+ [boolean] [default: true]
151
152
  --validate Validate the generated SBOM using json schema. Defaults to true. Pass --no-validate to di
152
153
  sable. [boolean] [default: true]
153
154
  --evidence Generate SBOM with evidence for supported languages. [boolean] [default: false]
@@ -170,6 +171,7 @@ Options:
170
171
  luated against or attested to.
171
172
  [array] [choices: "asvs-5.0", "asvs-4.0.3", "bsimm-v13", "masvs-2.0.0", "nist_ssdf-1.1", "pcissc-secure-slc-1.1", "scv
172
173
  s-1.0.0", "ssaf-DRAFT-2023-11"]
174
+ --json-pretty Pretty-print the generated BOM json. [boolean] [default: false]
173
175
  --min-confidence Minimum confidence needed for the identity of a component from 0 - 1, where 1 is 100% con
174
176
  fidence. [number] [default: 0]
175
177
  --technique Analysis technique to use
package/bin/cdxgen.js CHANGED
@@ -24,6 +24,7 @@ import {
24
24
  import { thoughtEnd, thoughtLog } from "../lib/helpers/logger.js";
25
25
  import {
26
26
  ATOM_DB,
27
+ DEBUG_MODE,
27
28
  dirNameStr,
28
29
  getTmpDir,
29
30
  isMac,
@@ -221,6 +222,7 @@ const args = yargs(hideBin(process.argv))
221
222
  description: "CycloneDX Specification version to use. Defaults to 1.6",
222
223
  default: 1.6,
223
224
  type: "number",
225
+ choices: [1.4, 1.5, 1.6],
224
226
  })
225
227
  .option("filter", {
226
228
  description:
@@ -303,6 +305,11 @@ const args = yargs(hideBin(process.argv))
303
305
  description:
304
306
  "Do not show the donation banner. Set this attribute if you are an active sponsor for OWASP CycloneDX.",
305
307
  })
308
+ .option("json-pretty", {
309
+ type: "boolean",
310
+ default: DEBUG_MODE,
311
+ description: "Pretty-print the generated BOM json.",
312
+ })
306
313
  .option("feature-flags", {
307
314
  description: "Experimental feature flags to enable. Advanced users only.",
308
315
  hidden: true,
@@ -442,11 +449,23 @@ if (!options.projectType) {
442
449
  "Ok, the user wants me to identify all the project types and generate a consolidated BOM document.",
443
450
  );
444
451
  }
445
- if (process.argv[1].includes("cbom")) {
446
- thoughtLog(
447
- "Ok, the user wants to generate Cryptographic Bill-of-Materials (CBOM).",
448
- );
449
- options.includeCrypto = true;
452
+ // Handle dedicated cbom and saasbom commands
453
+ if (["cbom", "saasbom"].includes(process.argv[1])) {
454
+ if (process.argv[1].includes("cbom")) {
455
+ thoughtLog(
456
+ "Ok, the user wants to generate Cryptographic Bill-of-Materials (CBOM).",
457
+ );
458
+ options.includeCrypto = true;
459
+ } else if (process.argv[1].includes("saasbom")) {
460
+ thoughtLog(
461
+ "Ok, the user wants to generate a Software as a Service Bill-of-Materials (SaaSBOM). I should carefully collect the services, endpoints, and data flows.",
462
+ );
463
+ if (process.env?.CDXGEN_IN_CONTAINER !== "true") {
464
+ thoughtLog(
465
+ "Wait, I'm not running in a container. This means the chances of successfully collecting this inventory are quite low. Perhaps this is an advanced user who has set up atom and atom-tools already 🤔?",
466
+ );
467
+ }
468
+ }
450
469
  options.evidence = true;
451
470
  options.specVersion = 1.6;
452
471
  options.deep = true;
@@ -693,7 +712,7 @@ const checkPermissions = (filePath, options) => {
693
712
  "usages-slices-file",
694
713
  "reachables-slices-file",
695
714
  ];
696
- if (options?.type?.includes("swift")) {
715
+ if (options?.type?.includes("swift") || options?.type?.includes("scala")) {
697
716
  slicesFilesKeys.push("semantics-slices-file");
698
717
  }
699
718
  for (const sf of slicesFilesKeys) {
@@ -798,7 +817,11 @@ const checkPermissions = (filePath, options) => {
798
817
  fs.writeFileSync(jsonFile, bomNSData.bomJson);
799
818
  jsonPayload = bomNSData.bomJson;
800
819
  } else {
801
- jsonPayload = JSON.stringify(bomNSData.bomJson, null, null);
820
+ jsonPayload = JSON.stringify(
821
+ bomNSData.bomJson,
822
+ null,
823
+ options.jsonPretty ? 2 : null,
824
+ );
802
825
  fs.writeFileSync(jsonFile, jsonPayload);
803
826
  if (jsonFile.endsWith("bom.json")) {
804
827
  thoughtLog(
@@ -900,7 +923,11 @@ const checkPermissions = (filePath, options) => {
900
923
  bomJsonUnsignedObj.signature = signatureBlock;
901
924
  fs.writeFileSync(
902
925
  jsonFile,
903
- JSON.stringify(bomJsonUnsignedObj, null, null),
926
+ JSON.stringify(
927
+ bomJsonUnsignedObj,
928
+ null,
929
+ options.jsonPretty ? 2 : null,
930
+ ),
904
931
  );
905
932
  thoughtLog(`Signing the BOM file "${jsonFile}".`);
906
933
  if (publicKeyFile) {
@@ -937,7 +964,9 @@ const checkPermissions = (filePath, options) => {
937
964
  }
938
965
  } else if (!options.print) {
939
966
  if (bomNSData.bomJson) {
940
- console.log(JSON.stringify(bomNSData.bomJson, null, 2));
967
+ console.log(
968
+ JSON.stringify(bomNSData.bomJson, null, options.jsonPretty ? 2 : null),
969
+ );
941
970
  } else {
942
971
  console.log("Unable to produce BOM for", filePath);
943
972
  console.log("Try running the command with -t <type> or -r argument");
@@ -967,6 +996,7 @@ const checkPermissions = (filePath, options) => {
967
996
  includeCrypto: options.includeCrypto,
968
997
  specVersion: options.specVersion,
969
998
  profile: options.profile,
999
+ jsonPretty: options.jsonPretty,
970
1000
  };
971
1001
  const dbObjMap = await evinserModule.prepareDB(evinseOptions);
972
1002
  if (dbObjMap) {
@@ -1003,6 +1033,7 @@ const checkPermissions = (filePath, options) => {
1003
1033
  await submitBom(options, bomNSData.bomJson);
1004
1034
  } catch (err) {
1005
1035
  console.log(err);
1036
+ process.exit(1);
1006
1037
  }
1007
1038
  }
1008
1039
  // Protobuf serialization
package/bin/evinse.js CHANGED
@@ -73,6 +73,7 @@ const args = yargs(hideBin(process.argv))
73
73
  "swift",
74
74
  "ios",
75
75
  "ruby",
76
+ "scala",
76
77
  ],
77
78
  })
78
79
  .option("db-path", {
@@ -127,7 +128,10 @@ const args = yargs(hideBin(process.argv))
127
128
  .option("semantics-slices-file", {
128
129
  description: "Use an existing semantics slices file.",
129
130
  default: "semantics.slices.json",
130
- hidden: true,
131
+ })
132
+ .option("openapi-spec-file", {
133
+ description: "Use an existing openapi specification file (SaaSBOM).",
134
+ default: "openapi.json",
131
135
  })
132
136
  .option("print", {
133
137
  alias: "p",
@@ -320,8 +320,8 @@
320
320
  {
321
321
  "browser": [
322
322
  "^(edge)",
323
- "(firefox|chrome|opera|brave|mullvad|tor|chromium)",
324
- "(microsoft+edge|microsoft+edge+webview2|microsoft+html)"
323
+ "^(firefox|chrome|opera|brave|mullvad|tor|chromium)",
324
+ "^(microsoft+edge|microsoft+edge+webview2|microsoft+html)"
325
325
  ]
326
326
  },
327
327
  {