@cyclonedx/cdxgen 12.3.0 → 12.3.2
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 +15 -5
- package/bin/audit.js +7 -0
- package/bin/cdxgen.js +241 -81
- package/bin/repl.js +138 -0
- package/data/rules/ai-agent-governance.yaml +249 -0
- package/data/rules/dependency-sources.yaml +41 -0
- package/data/rules/mcp-servers.yaml +304 -0
- package/data/rules/package-integrity.yaml +123 -0
- package/lib/audit/index.js +353 -29
- package/lib/audit/index.poku.js +247 -7
- package/lib/audit/reporters.js +26 -0
- package/lib/audit/scoring.js +262 -13
- package/lib/audit/scoring.poku.js +179 -0
- package/lib/audit/targets.js +391 -2
- package/lib/audit/targets.poku.js +416 -3
- package/lib/cli/index.js +588 -45
- package/lib/cli/index.poku.js +735 -1
- package/lib/evinser/evinser.js +8 -5
- package/lib/helpers/agentFormulationParser.js +318 -0
- package/lib/helpers/aiInventory.js +262 -0
- package/lib/helpers/aiInventory.poku.js +111 -0
- package/lib/helpers/analyzer.js +1769 -0
- package/lib/helpers/analyzer.poku.js +284 -3
- package/lib/helpers/auditCategories.js +76 -0
- package/lib/helpers/ciParsers/githubActions.js +140 -16
- package/lib/helpers/ciParsers/githubActions.poku.js +110 -0
- package/lib/helpers/communityAiConfigParser.js +672 -0
- package/lib/helpers/communityAiConfigParser.poku.js +63 -0
- package/lib/helpers/depsUtils.js +108 -0
- package/lib/helpers/depsUtils.poku.js +72 -1
- package/lib/helpers/display.js +325 -3
- package/lib/helpers/display.poku.js +301 -0
- package/lib/helpers/formulationParsers.js +28 -0
- package/lib/helpers/formulationParsers.poku.js +504 -1
- package/lib/helpers/jsonLike.js +102 -0
- package/lib/helpers/jsonLike.poku.js +34 -0
- package/lib/helpers/mcp.js +248 -0
- package/lib/helpers/mcp.poku.js +101 -0
- package/lib/helpers/mcpConfigParser.js +656 -0
- package/lib/helpers/mcpConfigParser.poku.js +126 -0
- package/lib/helpers/mcpDiscovery.js +84 -0
- package/lib/helpers/mcpDiscovery.poku.js +21 -0
- package/lib/helpers/protobom.js +3 -3
- package/lib/helpers/provenanceUtils.js +29 -4
- package/lib/helpers/provenanceUtils.poku.js +29 -3
- package/lib/helpers/registryProvenance.js +210 -0
- package/lib/helpers/registryProvenance.poku.js +144 -0
- package/lib/helpers/rustFormulationParser.js +330 -0
- package/lib/helpers/source.js +21 -2
- package/lib/helpers/source.poku.js +38 -0
- package/lib/helpers/utils.js +1331 -83
- package/lib/helpers/utils.poku.js +599 -188
- package/lib/helpers/vsixutils.js +12 -4
- package/lib/helpers/vsixutils.poku.js +34 -0
- package/lib/managers/binary.js +36 -12
- package/lib/managers/binary.poku.js +68 -0
- package/lib/managers/docker.js +59 -9
- package/lib/managers/docker.poku.js +61 -0
- package/lib/managers/piptree.js +12 -7
- package/lib/managers/piptree.poku.js +44 -0
- package/lib/stages/postgen/annotator.js +2 -1
- package/lib/stages/postgen/annotator.poku.js +15 -0
- package/lib/stages/postgen/auditBom.js +20 -6
- package/lib/stages/postgen/auditBom.poku.js +694 -1
- package/lib/stages/postgen/postgen.js +262 -11
- package/lib/stages/postgen/postgen.poku.js +306 -2
- package/lib/stages/postgen/ruleEngine.js +49 -1
- package/lib/stages/postgen/spdxConverter.poku.js +70 -0
- package/lib/stages/pregen/pregen.js +6 -4
- package/package.json +1 -1
- package/types/bin/repl.d.ts.map +1 -1
- package/types/lib/audit/index.d.ts.map +1 -1
- package/types/lib/audit/reporters.d.ts.map +1 -1
- package/types/lib/audit/scoring.d.ts.map +1 -1
- package/types/lib/audit/targets.d.ts +12 -0
- package/types/lib/audit/targets.d.ts.map +1 -1
- package/types/lib/cli/index.d.ts +2 -8
- package/types/lib/cli/index.d.ts.map +1 -1
- package/types/lib/evinser/evinser.d.ts.map +1 -1
- package/types/lib/helpers/agentFormulationParser.d.ts +19 -0
- package/types/lib/helpers/agentFormulationParser.d.ts.map +1 -0
- package/types/lib/helpers/aiInventory.d.ts +23 -0
- package/types/lib/helpers/aiInventory.d.ts.map +1 -0
- package/types/lib/helpers/analyzer.d.ts +10 -0
- package/types/lib/helpers/analyzer.d.ts.map +1 -1
- package/types/lib/helpers/auditCategories.d.ts +12 -0
- package/types/lib/helpers/auditCategories.d.ts.map +1 -0
- package/types/lib/helpers/ciParsers/githubActions.d.ts.map +1 -1
- package/types/lib/helpers/communityAiConfigParser.d.ts +29 -0
- package/types/lib/helpers/communityAiConfigParser.d.ts.map +1 -0
- package/types/lib/helpers/depsUtils.d.ts +8 -0
- package/types/lib/helpers/depsUtils.d.ts.map +1 -1
- package/types/lib/helpers/display.d.ts +17 -1
- package/types/lib/helpers/display.d.ts.map +1 -1
- package/types/lib/helpers/formulationParsers.d.ts.map +1 -1
- package/types/lib/helpers/jsonLike.d.ts +4 -0
- package/types/lib/helpers/jsonLike.d.ts.map +1 -0
- package/types/lib/helpers/mcp.d.ts +29 -0
- package/types/lib/helpers/mcp.d.ts.map +1 -0
- package/types/lib/helpers/mcpConfigParser.d.ts +30 -0
- package/types/lib/helpers/mcpConfigParser.d.ts.map +1 -0
- package/types/lib/helpers/mcpDiscovery.d.ts +5 -0
- package/types/lib/helpers/mcpDiscovery.d.ts.map +1 -0
- package/types/lib/helpers/provenanceUtils.d.ts +5 -3
- package/types/lib/helpers/provenanceUtils.d.ts.map +1 -1
- package/types/lib/helpers/registryProvenance.d.ts +9 -0
- package/types/lib/helpers/registryProvenance.d.ts.map +1 -1
- package/types/lib/helpers/rustFormulationParser.d.ts +17 -0
- package/types/lib/helpers/rustFormulationParser.d.ts.map +1 -0
- package/types/lib/helpers/source.d.ts.map +1 -1
- package/types/lib/helpers/utils.d.ts +31 -1
- package/types/lib/helpers/utils.d.ts.map +1 -1
- package/types/lib/helpers/vsixutils.d.ts.map +1 -1
- package/types/lib/managers/binary.d.ts.map +1 -1
- package/types/lib/managers/docker.d.ts.map +1 -1
- package/types/lib/managers/piptree.d.ts.map +1 -1
- package/types/lib/stages/postgen/annotator.d.ts.map +1 -1
- package/types/lib/stages/postgen/auditBom.d.ts.map +1 -1
- package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
- package/types/lib/stages/postgen/ruleEngine.d.ts.map +1 -1
- package/types/lib/stages/pregen/pregen.d.ts.map +1 -1
|
@@ -5,9 +5,11 @@ import { assert, it } from "poku";
|
|
|
5
5
|
import sinon from "sinon";
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
+
buildActivitySummaryPayload,
|
|
8
9
|
buildDependencyTreeLegendLines,
|
|
9
10
|
buildDependencyTreeLines,
|
|
10
11
|
printDependencyTree,
|
|
12
|
+
serializeActivitySummary,
|
|
11
13
|
} from "./display.js";
|
|
12
14
|
import { REGISTRY_PROVENANCE_ICON } from "./provenanceUtils.js";
|
|
13
15
|
|
|
@@ -91,6 +93,31 @@ it("prints a provenance icon for registry-backed components", async () => {
|
|
|
91
93
|
}
|
|
92
94
|
});
|
|
93
95
|
|
|
96
|
+
it("displaySelfThreatModel does not assume a default TLP classification", async () => {
|
|
97
|
+
const tableStub = sinon.stub().returns("table-output");
|
|
98
|
+
try {
|
|
99
|
+
const { displaySelfThreatModel } = await esmock("./display.js", {
|
|
100
|
+
"./table.js": {
|
|
101
|
+
createStream: sinon.stub(),
|
|
102
|
+
table: tableStub,
|
|
103
|
+
},
|
|
104
|
+
"./utils.js": {
|
|
105
|
+
isSecureMode: false,
|
|
106
|
+
safeExistsSync: sinon.stub(),
|
|
107
|
+
toCamel: sinon.stub().callsFake((value) => value),
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
displaySelfThreatModel("/workspace/project", {}, {}, []);
|
|
111
|
+
const [headerData] = tableStub.firstCall.args;
|
|
112
|
+
assert.deepStrictEqual(headerData[0], [
|
|
113
|
+
"TLP Classification",
|
|
114
|
+
"Not set — no distribution constraints recorded.",
|
|
115
|
+
]);
|
|
116
|
+
} finally {
|
|
117
|
+
sinon.restore();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
94
121
|
it("renders shared dependencies once while including dangling trees", () => {
|
|
95
122
|
const treeLines = buildDependencyTreeLines([
|
|
96
123
|
{
|
|
@@ -170,3 +197,277 @@ it("returns no legend lines when the dependency tree has no markers", () => {
|
|
|
170
197
|
[],
|
|
171
198
|
);
|
|
172
199
|
});
|
|
200
|
+
|
|
201
|
+
it("prints an informative activity summary table", async () => {
|
|
202
|
+
const tableStub = sinon.stub().returns("activity-table");
|
|
203
|
+
try {
|
|
204
|
+
const { printActivitySummary: printActivitySummaryMocked } = await esmock(
|
|
205
|
+
"./display.js",
|
|
206
|
+
{
|
|
207
|
+
"./table.js": {
|
|
208
|
+
createStream: sinon.stub(),
|
|
209
|
+
table: tableStub,
|
|
210
|
+
},
|
|
211
|
+
"./utils.js": {
|
|
212
|
+
getRecordedActivities: sinon.stub().returns([
|
|
213
|
+
{
|
|
214
|
+
identifier: "ACT-0001",
|
|
215
|
+
projectType: "ruby,js,python",
|
|
216
|
+
packageType: "npm",
|
|
217
|
+
kind: "execute",
|
|
218
|
+
reason: "Dry run mode blocks child process execution.",
|
|
219
|
+
status: "blocked",
|
|
220
|
+
target: "npm install",
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
identifier: "ACT-0002",
|
|
224
|
+
projectType: "python",
|
|
225
|
+
packageType: "pypi",
|
|
226
|
+
kind: "read",
|
|
227
|
+
status: "completed",
|
|
228
|
+
target: "/workspace/requirements.txt",
|
|
229
|
+
},
|
|
230
|
+
]),
|
|
231
|
+
isDryRun: true,
|
|
232
|
+
isSecureMode: false,
|
|
233
|
+
safeExistsSync: sinon.stub(),
|
|
234
|
+
toCamel: sinon.stub(),
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
);
|
|
238
|
+
printActivitySummaryMocked();
|
|
239
|
+
sinon.assert.calledOnce(tableStub);
|
|
240
|
+
const [data, config] = tableStub.firstCall.args;
|
|
241
|
+
assert.strictEqual(
|
|
242
|
+
config.header.content,
|
|
243
|
+
"cdxgen dry-run activity summary\n1 completed 1 blocked 0 failed",
|
|
244
|
+
);
|
|
245
|
+
assert.deepStrictEqual(data[0], [
|
|
246
|
+
"Identifier",
|
|
247
|
+
"Type",
|
|
248
|
+
"Package Type",
|
|
249
|
+
"Activity",
|
|
250
|
+
"Target",
|
|
251
|
+
"Outcome / Why",
|
|
252
|
+
]);
|
|
253
|
+
assert.strictEqual(data[1][0], "ACT-0001");
|
|
254
|
+
assert.strictEqual(data[1][1], "js\npython\nruby");
|
|
255
|
+
assert.strictEqual(data[1][2], "npm");
|
|
256
|
+
assert.strictEqual(data[1][3], "execute");
|
|
257
|
+
assert.strictEqual(
|
|
258
|
+
data[1][5],
|
|
259
|
+
"blocked\nDry run mode blocks child process execution.",
|
|
260
|
+
);
|
|
261
|
+
} finally {
|
|
262
|
+
sinon.restore();
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it("renders known comma-separated activity target properties across lines", async () => {
|
|
267
|
+
const tableStub = sinon.stub().returns("activity-table");
|
|
268
|
+
try {
|
|
269
|
+
const { printActivitySummary: printActivitySummaryMocked } = await esmock(
|
|
270
|
+
"./display.js",
|
|
271
|
+
{
|
|
272
|
+
"./table.js": {
|
|
273
|
+
createStream: sinon.stub(),
|
|
274
|
+
table: tableStub,
|
|
275
|
+
},
|
|
276
|
+
"./utils.js": {
|
|
277
|
+
getRecordedActivities: sinon.stub().returns([
|
|
278
|
+
{
|
|
279
|
+
identifier: "ACT-0001",
|
|
280
|
+
projectType: "oci",
|
|
281
|
+
packageType: "container",
|
|
282
|
+
kind: "read",
|
|
283
|
+
reason: "Collected image metadata.",
|
|
284
|
+
status: "completed",
|
|
285
|
+
target:
|
|
286
|
+
"Image=ghcr.io/cdxgen/cdxgen, SrcFiles=pnpm-lock.yaml,Dockerfile,package.json",
|
|
287
|
+
},
|
|
288
|
+
]),
|
|
289
|
+
isDryRun: true,
|
|
290
|
+
isSecureMode: false,
|
|
291
|
+
safeExistsSync: sinon.stub(),
|
|
292
|
+
toCamel: sinon.stub(),
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
);
|
|
296
|
+
printActivitySummaryMocked();
|
|
297
|
+
const [data] = tableStub.firstCall.args;
|
|
298
|
+
assert.strictEqual(
|
|
299
|
+
data[1][4],
|
|
300
|
+
"Image=ghcr.io/cdxgen/cdxgen\nSrcFiles=\n- Dockerfile\n- package.json\n- pnpm-lock.yaml",
|
|
301
|
+
);
|
|
302
|
+
} finally {
|
|
303
|
+
sinon.restore();
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
it("renders plain comma-separated activity paths one per line sorted by depth", async () => {
|
|
308
|
+
const tableStub = sinon.stub().returns("activity-table");
|
|
309
|
+
try {
|
|
310
|
+
const { printActivitySummary: printActivitySummaryMocked } = await esmock(
|
|
311
|
+
"./display.js",
|
|
312
|
+
{
|
|
313
|
+
"./table.js": {
|
|
314
|
+
createStream: sinon.stub(),
|
|
315
|
+
table: tableStub,
|
|
316
|
+
},
|
|
317
|
+
"./utils.js": {
|
|
318
|
+
getRecordedActivities: sinon.stub().returns([
|
|
319
|
+
{
|
|
320
|
+
identifier: "ACT-0004",
|
|
321
|
+
projectType: "github",
|
|
322
|
+
packageType: "github",
|
|
323
|
+
kind: "read",
|
|
324
|
+
reason: "Collected github component metadata.",
|
|
325
|
+
status: "completed",
|
|
326
|
+
target:
|
|
327
|
+
"/workspace/.github/workflows/deeper/build.yml, /workspace/.github/workflows/test.yml, /workspace/.github/workflows/deeper/nightly/scan.yml",
|
|
328
|
+
},
|
|
329
|
+
]),
|
|
330
|
+
isDryRun: true,
|
|
331
|
+
isSecureMode: false,
|
|
332
|
+
safeExistsSync: sinon.stub(),
|
|
333
|
+
toCamel: sinon.stub(),
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
);
|
|
337
|
+
printActivitySummaryMocked();
|
|
338
|
+
const [data] = tableStub.firstCall.args;
|
|
339
|
+
assert.strictEqual(
|
|
340
|
+
data[1][4],
|
|
341
|
+
"/workspace/.github/workflows/test.yml\n/workspace/.github/workflows/deeper/build.yml\n/workspace/.github/workflows/deeper/nightly/scan.yml",
|
|
342
|
+
);
|
|
343
|
+
} finally {
|
|
344
|
+
sinon.restore();
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it("prints grouped environment audit findings in a secure-mode panel", async () => {
|
|
349
|
+
const tableStub = sinon.stub().returns("env-audit-table");
|
|
350
|
+
try {
|
|
351
|
+
const {
|
|
352
|
+
printEnvironmentAuditFindings: printEnvironmentAuditFindingsMocked,
|
|
353
|
+
} = await esmock("./display.js", {
|
|
354
|
+
"./table.js": {
|
|
355
|
+
createStream: sinon.stub(),
|
|
356
|
+
table: tableStub,
|
|
357
|
+
},
|
|
358
|
+
"./utils.js": {
|
|
359
|
+
getRecordedActivities: sinon.stub(),
|
|
360
|
+
isDryRun: true,
|
|
361
|
+
isSecureMode: false,
|
|
362
|
+
safeExistsSync: sinon.stub(),
|
|
363
|
+
toCamel: sinon.stub().callsFake((value) => value),
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
printEnvironmentAuditFindingsMocked([
|
|
367
|
+
{
|
|
368
|
+
type: "credential-exposure",
|
|
369
|
+
variable: "HF_TOKEN",
|
|
370
|
+
severity: "low",
|
|
371
|
+
message:
|
|
372
|
+
"HF_TOKEN matches a credential naming pattern and is set in the environment. Build tools or install scripts invoked during SBOM generation may read environment variables.",
|
|
373
|
+
mitigation: "Unset HF_TOKEN.",
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
type: "environment-variable",
|
|
377
|
+
variable: "NODE_PATH",
|
|
378
|
+
severity: "high",
|
|
379
|
+
message:
|
|
380
|
+
"NODE_PATH is set and may cause unexpected modules to be loaded, enabling module-resolution poisoning.",
|
|
381
|
+
mitigation: "Unset NODE_PATH before processing untrusted repositories.",
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
type: "credential-exposure",
|
|
385
|
+
variable: "GITHUB_TOKEN",
|
|
386
|
+
severity: "low",
|
|
387
|
+
message:
|
|
388
|
+
"GITHUB_TOKEN matches a credential naming pattern and is set in the environment. Build tools or install scripts invoked during SBOM generation may read environment variables.",
|
|
389
|
+
mitigation: "Unset GITHUB_TOKEN.",
|
|
390
|
+
},
|
|
391
|
+
]);
|
|
392
|
+
sinon.assert.calledOnce(tableStub);
|
|
393
|
+
const [data, config] = tableStub.firstCall.args;
|
|
394
|
+
assert.strictEqual(
|
|
395
|
+
config.header.content,
|
|
396
|
+
"SECURE MODE: Environment audit\n1 high 2 low",
|
|
397
|
+
);
|
|
398
|
+
assert.deepStrictEqual(data[1], [
|
|
399
|
+
"Environment Variable",
|
|
400
|
+
"HIGH",
|
|
401
|
+
"NODE_PATH",
|
|
402
|
+
"NODE_PATH is set and may cause unexpected modules to be loaded, enabling module-resolution poisoning.\nMitigation: Unset NODE_PATH before processing untrusted repositories.",
|
|
403
|
+
]);
|
|
404
|
+
assert.deepStrictEqual(data[2], [
|
|
405
|
+
"Credential Exposure",
|
|
406
|
+
"LOW",
|
|
407
|
+
"GITHUB_TOKEN\nHF_TOKEN",
|
|
408
|
+
"Credential-like environment variables are set. Build tools or install scripts invoked during SBOM generation may read inherited environment variables.\nMitigation: Unset unneeded secrets when scanning untrusted repositories. Prefer ephemeral, scoped CI credentials injected only for the step that needs them.",
|
|
409
|
+
]);
|
|
410
|
+
} finally {
|
|
411
|
+
sinon.restore();
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
it("prints the activity summary as JSON", async () => {
|
|
416
|
+
const lines = serializeActivitySummary(
|
|
417
|
+
[
|
|
418
|
+
{
|
|
419
|
+
identifier: "ACT-0001",
|
|
420
|
+
projectType: "js",
|
|
421
|
+
packageType: "npm",
|
|
422
|
+
kind: "execute",
|
|
423
|
+
status: "blocked",
|
|
424
|
+
target: "npm install",
|
|
425
|
+
},
|
|
426
|
+
],
|
|
427
|
+
"json",
|
|
428
|
+
true,
|
|
429
|
+
);
|
|
430
|
+
assert.strictEqual(lines.length, 1);
|
|
431
|
+
const payload = JSON.parse(lines[0]);
|
|
432
|
+
assert.strictEqual(payload.mode, "dry-run");
|
|
433
|
+
assert.strictEqual(payload.summary.total, 1);
|
|
434
|
+
assert.strictEqual(payload.activities[0].identifier, "ACT-0001");
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it("prints the activity summary as JSON Lines", async () => {
|
|
438
|
+
const lines = serializeActivitySummary(
|
|
439
|
+
[
|
|
440
|
+
{
|
|
441
|
+
identifier: "ACT-0001",
|
|
442
|
+
projectType: "js",
|
|
443
|
+
packageType: "npm",
|
|
444
|
+
kind: "execute",
|
|
445
|
+
status: "blocked",
|
|
446
|
+
target: "npm install",
|
|
447
|
+
},
|
|
448
|
+
],
|
|
449
|
+
"jsonl",
|
|
450
|
+
true,
|
|
451
|
+
);
|
|
452
|
+
assert.strictEqual(lines.length, 2);
|
|
453
|
+
const summary = JSON.parse(lines[0]);
|
|
454
|
+
const activity = JSON.parse(lines[1]);
|
|
455
|
+
assert.strictEqual(summary.recordType, "summary");
|
|
456
|
+
assert.strictEqual(summary.total, 1);
|
|
457
|
+
assert.strictEqual(activity.recordType, "activity");
|
|
458
|
+
assert.strictEqual(activity.identifier, "ACT-0001");
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it("builds summary counts for serialized activity reports", () => {
|
|
462
|
+
const payload = buildActivitySummaryPayload(
|
|
463
|
+
[{ status: "blocked" }, { status: "completed" }, { status: "failed" }],
|
|
464
|
+
true,
|
|
465
|
+
);
|
|
466
|
+
assert.deepStrictEqual(payload.summary, {
|
|
467
|
+
blocked: 1,
|
|
468
|
+
completed: 1,
|
|
469
|
+
failed: 1,
|
|
470
|
+
total: 3,
|
|
471
|
+
});
|
|
472
|
+
assert.strictEqual(payload.mode, "dry-run");
|
|
473
|
+
});
|
|
@@ -4,6 +4,11 @@ import process from "node:process";
|
|
|
4
4
|
|
|
5
5
|
import { v4 as uuidv4 } from "uuid";
|
|
6
6
|
|
|
7
|
+
import {
|
|
8
|
+
AI_INVENTORY_PROJECT_TYPES,
|
|
9
|
+
collectAiInventory,
|
|
10
|
+
optionIncludesAiInventoryProjectType,
|
|
11
|
+
} from "./aiInventory.js";
|
|
7
12
|
import { collectOSCryptoLibs } from "./cbomutils.js";
|
|
8
13
|
import { azurePipelinesParser } from "./ciParsers/azurePipelines.js";
|
|
9
14
|
import { circleCiParser } from "./ciParsers/circleCi.js";
|
|
@@ -18,6 +23,7 @@ import {
|
|
|
18
23
|
gitTreeHashes,
|
|
19
24
|
listFiles,
|
|
20
25
|
} from "./envcontext.js";
|
|
26
|
+
import { rustFormulationParser } from "./rustFormulationParser.js";
|
|
21
27
|
import { scanTextForHiddenUnicode } from "./unicodeScan.js";
|
|
22
28
|
import { getAllFiles } from "./utils.js";
|
|
23
29
|
|
|
@@ -95,6 +101,7 @@ function buildReadmeSecurityComponents(discoveryPath, options) {
|
|
|
95
101
|
* ```
|
|
96
102
|
*/
|
|
97
103
|
const _parsers = [
|
|
104
|
+
rustFormulationParser,
|
|
98
105
|
githubActionsParser,
|
|
99
106
|
gitlabCiParser,
|
|
100
107
|
jenkinsParser,
|
|
@@ -304,6 +311,12 @@ export function addFormulationSection(filePath, options, context = {}) {
|
|
|
304
311
|
const ciProperties = [];
|
|
305
312
|
|
|
306
313
|
const discoveryPath = projectPath || ".";
|
|
314
|
+
const excludedInventoryTypes = AI_INVENTORY_PROJECT_TYPES.filter((type) => {
|
|
315
|
+
return optionIncludesAiInventoryProjectType(options?.excludeType, type);
|
|
316
|
+
});
|
|
317
|
+
const includedInventoryTypes = AI_INVENTORY_PROJECT_TYPES.filter(
|
|
318
|
+
(type) => !excludedInventoryTypes.includes(type),
|
|
319
|
+
);
|
|
307
320
|
|
|
308
321
|
for (const parser of _parsers) {
|
|
309
322
|
const matchedFiles = [];
|
|
@@ -347,6 +360,21 @@ export function addFormulationSection(filePath, options, context = {}) {
|
|
|
347
360
|
}
|
|
348
361
|
}
|
|
349
362
|
|
|
363
|
+
const aiInventory = collectAiInventory(
|
|
364
|
+
discoveryPath,
|
|
365
|
+
options,
|
|
366
|
+
includedInventoryTypes,
|
|
367
|
+
);
|
|
368
|
+
if (aiInventory.components.length) {
|
|
369
|
+
ciComponents.push(...aiInventory.components);
|
|
370
|
+
}
|
|
371
|
+
if (aiInventory.services.length) {
|
|
372
|
+
ciServices.push(...aiInventory.services);
|
|
373
|
+
}
|
|
374
|
+
if (aiInventory.dependencies.length) {
|
|
375
|
+
dependencies.push(...aiInventory.dependencies);
|
|
376
|
+
}
|
|
377
|
+
|
|
350
378
|
// Merge CI components into the formulation component list
|
|
351
379
|
if (ciComponents.length) {
|
|
352
380
|
components = components.concat(ciComponents);
|