@cyclonedx/cdxgen 11.1.10 → 11.2.1
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/bin/cdxgen.js +25 -9
- package/bin/repl.js +21 -12
- package/lib/cli/index.js +423 -67
- package/lib/evinser/evinser.js +11 -2
- package/lib/evinser/swiftsem.js +3 -0
- package/lib/helpers/display.js +4 -2
- package/lib/helpers/logger.js +3 -1
- package/lib/helpers/package_specific/gradleutils.js +48 -0
- package/lib/helpers/package_specific/gradleutils.test.js +65 -0
- package/lib/helpers/utils.js +794 -42
- package/lib/helpers/utils.test.js +125 -2
- package/lib/helpers/validator.js +15 -0
- package/lib/managers/docker.js +37 -6
- package/lib/stages/postgen/annotator.js +40 -2
- package/lib/stages/postgen/postgen.js +93 -8
- package/lib/stages/pregen/pregen.js +1 -1
- package/package.json +5 -5
- package/types/lib/cli/index.d.ts +7 -0
- package/types/lib/cli/index.d.ts.map +1 -1
- package/types/lib/evinser/swiftsem.d.ts.map +1 -1
- package/types/lib/helpers/display.d.ts.map +1 -1
- package/types/lib/helpers/logger.d.ts.map +1 -1
- package/types/lib/helpers/package_specific/gradleutils.d.ts +10 -0
- package/types/lib/helpers/package_specific/gradleutils.d.ts.map +1 -0
- package/types/lib/helpers/utils.d.ts +46 -1
- package/types/lib/helpers/utils.d.ts.map +1 -1
- package/types/lib/helpers/validator.d.ts.map +1 -1
- package/types/lib/managers/docker.d.ts +4 -0
- package/types/lib/managers/docker.d.ts.map +1 -1
- package/types/lib/stages/postgen/annotator.d.ts.map +1 -1
- package/types/lib/stages/postgen/postgen.d.ts +2 -2
- package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
package/bin/cdxgen.js
CHANGED
|
@@ -579,13 +579,25 @@ const applyAdvancedOptions = (options) => {
|
|
|
579
579
|
break;
|
|
580
580
|
}
|
|
581
581
|
// When the user specifies source-code-analysis as a technique, then enable deep and evidence mode.
|
|
582
|
-
if (
|
|
583
|
-
options?.technique
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
options.
|
|
588
|
-
|
|
582
|
+
if (options?.technique && Array.isArray(options.technique)) {
|
|
583
|
+
if (options?.technique?.includes("source-code-analysis")) {
|
|
584
|
+
options.deep = true;
|
|
585
|
+
options.evidence = true;
|
|
586
|
+
}
|
|
587
|
+
if (options.technique.length === 1) {
|
|
588
|
+
thoughtLog(
|
|
589
|
+
`Wait, the user wants me to use only the following technique: '${options.technique.join(", ")}'.`,
|
|
590
|
+
);
|
|
591
|
+
} else {
|
|
592
|
+
thoughtLog(
|
|
593
|
+
`Alright, I will use only the following techniques: '${options.technique.join(", ")}' for the final BOM.`,
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
if (!options.installDeps) {
|
|
598
|
+
thoughtLog(
|
|
599
|
+
"I must avoid any package installations and focus solely on the available artefacts, such as lock files.",
|
|
600
|
+
);
|
|
589
601
|
}
|
|
590
602
|
return options;
|
|
591
603
|
};
|
|
@@ -764,7 +776,11 @@ const checkPermissions = (filePath, options) => {
|
|
|
764
776
|
prepareEnv(filePath, options);
|
|
765
777
|
thoughtLog("Getting ready to generate the BOM ⚡️.");
|
|
766
778
|
let bomNSData = (await createBom(filePath, options)) || {};
|
|
767
|
-
|
|
779
|
+
if (bomNSData?.bomJson) {
|
|
780
|
+
thoughtLog(
|
|
781
|
+
"Tweaking the generated BOM data with useful annotations and properties.",
|
|
782
|
+
);
|
|
783
|
+
}
|
|
768
784
|
// Add extra metadata and annotations with post processing
|
|
769
785
|
bomNSData = postProcess(bomNSData, options);
|
|
770
786
|
if (
|
|
@@ -972,7 +988,7 @@ const checkPermissions = (filePath, options) => {
|
|
|
972
988
|
}
|
|
973
989
|
}
|
|
974
990
|
// Perform automatic validation
|
|
975
|
-
if (options.validate) {
|
|
991
|
+
if (options.validate && bomNSData?.bomJson) {
|
|
976
992
|
thoughtLog("Wait, let's check the generated BOM file for any issues.");
|
|
977
993
|
if (!validateBom(bomNSData.bomJson)) {
|
|
978
994
|
process.exit(1);
|
package/bin/repl.js
CHANGED
|
@@ -137,6 +137,19 @@ cdxgenRepl.defineCommand("import", {
|
|
|
137
137
|
this.displayPrompt();
|
|
138
138
|
},
|
|
139
139
|
});
|
|
140
|
+
cdxgenRepl.defineCommand("summary", {
|
|
141
|
+
help: "summarize an existing BOM",
|
|
142
|
+
action() {
|
|
143
|
+
if (sbom) {
|
|
144
|
+
printSummary(sbom);
|
|
145
|
+
} else {
|
|
146
|
+
console.log(
|
|
147
|
+
"⚠ No BOM is loaded. Use .import command to import an existing BOM",
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
this.displayPrompt();
|
|
151
|
+
},
|
|
152
|
+
});
|
|
140
153
|
cdxgenRepl.defineCommand("exit", {
|
|
141
154
|
help: "exit",
|
|
142
155
|
action() {
|
|
@@ -162,13 +175,13 @@ cdxgenRepl.defineCommand("search", {
|
|
|
162
175
|
if (sbom) {
|
|
163
176
|
if (searchStr) {
|
|
164
177
|
try {
|
|
165
|
-
|
|
166
|
-
let dependenciesSearchStr =
|
|
167
|
-
if (!
|
|
168
|
-
dependenciesSearchStr = `dependencies[ref ~> /${
|
|
169
|
-
|
|
178
|
+
let fixedSearchStr = searchStr.replaceAll("/", "\\/");
|
|
179
|
+
let dependenciesSearchStr = fixedSearchStr;
|
|
180
|
+
if (!fixedSearchStr.includes("~>")) {
|
|
181
|
+
dependenciesSearchStr = `dependencies[ref ~> /${fixedSearchStr}/i or dependsOn ~> /${fixedSearchStr}/i or provides ~> /${fixedSearchStr}/i]`;
|
|
182
|
+
fixedSearchStr = `components[group ~> /${fixedSearchStr}/i or name ~> /${fixedSearchStr}/i or description ~> /${fixedSearchStr}/i or publisher ~> /${fixedSearchStr}/i or purl ~> /${fixedSearchStr}/i or tags ~> /${fixedSearchStr}/i]`;
|
|
170
183
|
}
|
|
171
|
-
const expression = jsonata(
|
|
184
|
+
const expression = jsonata(fixedSearchStr);
|
|
172
185
|
let components = await expression.evaluate(sbom);
|
|
173
186
|
const dexpression = jsonata(dependenciesSearchStr);
|
|
174
187
|
let dependencies = await dexpression.evaluate(sbom);
|
|
@@ -181,16 +194,12 @@ cdxgenRepl.defineCommand("search", {
|
|
|
181
194
|
if (!components) {
|
|
182
195
|
console.log("No results found!");
|
|
183
196
|
} else {
|
|
184
|
-
printTable(
|
|
185
|
-
{ components, dependencies },
|
|
186
|
-
undefined,
|
|
187
|
-
originalSearchString,
|
|
188
|
-
);
|
|
197
|
+
printTable({ components, dependencies }, undefined, searchStr);
|
|
189
198
|
if (dependencies?.length) {
|
|
190
199
|
printDependencyTree(
|
|
191
200
|
{ components, dependencies },
|
|
192
201
|
"dependsOn",
|
|
193
|
-
|
|
202
|
+
searchStr,
|
|
194
203
|
);
|
|
195
204
|
}
|
|
196
205
|
}
|