@cdxgen/cdxgen 13.0.1 → 13.2.0
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 +30 -16
- package/bin/audit.js +6 -0
- package/bin/cdxgen.js +141 -7
- package/bin/evinse.js +3 -1
- package/data/component-tags.json +8 -1
- package/data/crypto-oid.json +88 -12
- package/data/frameworks-list.json +86 -1
- package/data/remediations.json +1167 -0
- package/data/rules/ai-bom.yaml +78 -0
- package/data/rules/asar-archives.yaml +1 -1
- package/data/rules/build-fidelity.yaml +782 -0
- package/data/rules/cargo-rust.yaml +132 -0
- package/data/rules/mcp-servers.yaml +122 -0
- package/data/rules/package-integrity.yaml +13 -13
- package/lib/audit/index.js +48 -4
- package/lib/audit/scoring.js +2 -8
- package/lib/audit/targets.js +6 -1
- package/lib/cli/bomAssembly.js +32 -1
- package/lib/cli/cliOptions.js +94 -7
- package/lib/cli/index.js +268 -49
- package/lib/cli/jsBom.js +91 -5
- package/lib/cli/jvmBom.js +1515 -1314
- package/lib/cli/managedBom.js +249 -28
- package/lib/cli/nativeBom.js +986 -10
- package/lib/core/activity.js +120 -2
- package/lib/core/buildLedger.js +799 -0
- package/lib/core/deferredExit.js +141 -0
- package/lib/core/env.js +108 -2
- package/lib/core/fs.js +60 -0
- package/lib/core/logger.js +12 -99
- package/lib/core/severity.js +16 -0
- package/lib/core/syncFileWriter.js +106 -0
- package/lib/core/userAgent.js +151 -0
- package/lib/ecosystems/cargoCache.js +364 -0
- package/lib/ecosystems/caxa.js +13 -5
- package/lib/ecosystems/cppEvidence.js +40 -2
- package/lib/ecosystems/ecosystems.js +250 -91
- package/lib/ecosystems/golem.js +11 -1
- package/lib/ecosystems/gradleutils.js +498 -17
- package/lib/ecosystems/kosi.js +1256 -0
- package/lib/ecosystems/parsers-crystal.js +179 -0
- package/lib/ecosystems/parsers-dotnet.js +69 -39
- package/lib/ecosystems/parsers-elm.js +816 -0
- package/lib/ecosystems/parsers-gleam.js +1 -1
- package/lib/ecosystems/parsers-js.js +26 -0
- package/lib/ecosystems/parsers-julia.js +268 -0
- package/lib/ecosystems/parsers-jvm.js +9 -0
- package/lib/ecosystems/parsers-lua.js +218 -0
- package/lib/ecosystems/parsers-misc.js +188 -2
- package/lib/ecosystems/parsers-nim.js +221 -0
- package/lib/ecosystems/parsers-opam.js +180 -0
- package/lib/ecosystems/parsers-perl.js +277 -0
- package/lib/ecosystems/parsers-python.js +172 -36
- package/lib/ecosystems/parsers-r.js +148 -0
- package/lib/ecosystems/parsers-rebar.js +411 -0
- package/lib/ecosystems/parsers-rust.js +944 -19
- package/lib/ecosystems/parsers-spack.js +204 -0
- package/lib/ecosystems/parsers-stack.js +264 -0
- package/lib/ecosystems/parsers-terraform.js +194 -0
- package/lib/ecosystems/pypiClassifiers.js +326 -0
- package/lib/ecosystems/pythonutils.js +49 -1
- package/lib/ecosystems/rubyutils.js +13 -0
- package/lib/ecosystems/rusi.js +126 -6
- package/lib/evinser/evinser.js +141 -13
- package/lib/helpers/agenticToolutils.js +925 -0
- package/lib/helpers/remote/dependency-track.js +81 -14
- package/lib/inventory/agentFormulationParser.js +57 -4
- package/lib/inventory/aiCollector.js +504 -10
- package/lib/inventory/aiInventory.js +12 -0
- package/lib/inventory/analyzer.js +488 -30
- package/lib/inventory/astWorker.js +6 -0
- package/lib/inventory/auditCategories.js +17 -0
- package/lib/inventory/cbomutils.js +30 -0
- package/lib/inventory/cdxrs.js +7 -2
- package/lib/inventory/communityAiConfigParser.js +215 -2
- package/lib/inventory/depsUtils.js +72 -0
- package/lib/inventory/dosai.js +508 -22
- package/lib/inventory/envcontext.js +215 -24
- package/lib/inventory/evidenceUtils.js +13 -0
- package/lib/inventory/fetchBatch.js +131 -2
- package/lib/inventory/fetchRate.js +74 -11
- package/lib/inventory/forgeEnricher.js +3 -2
- package/lib/inventory/jvmToolEnv.js +594 -0
- package/lib/inventory/mcpConfigParser.js +166 -2
- package/lib/inventory/mcpDiscovery.js +11 -0
- package/lib/inventory/mcpServerManifest.js +389 -0
- package/lib/inventory/mcpbBundle.js +419 -0
- package/lib/inventory/osinfo.js +1 -0
- package/lib/inventory/plugins.js +3 -0
- package/lib/inventory/protobom.js +54 -88
- package/lib/inventory/protobomLoader.js +4 -0
- package/lib/inventory/rustFormulationParser.js +1 -1
- package/lib/inventory/source.js +10 -4
- package/lib/inventory/stylePackageRefs.js +41 -0
- package/lib/inventory/svelteUtils.js +524 -0
- package/lib/inventory/toolRequirements.js +903 -0
- package/lib/managers/binary.js +24 -0
- package/lib/managers/docker.js +26 -5
- package/lib/parsers/huggingfaceUtils.js +15 -7
- package/lib/parsers/onnx.js +294 -0
- package/lib/parsers/safetensors.js +114 -0
- package/lib/server/server.js +1 -1
- package/lib/stages/postgen/annotationBuilder.js +97 -0
- package/lib/stages/postgen/auditBom.js +76 -79
- package/lib/stages/postgen/introspection/annotate.js +320 -0
- package/lib/stages/postgen/introspection/commandFacts.js +293 -0
- package/lib/stages/postgen/introspection/emit.js +192 -0
- package/lib/stages/postgen/introspection/formulationEvidence.js +427 -0
- package/lib/stages/postgen/introspection/markers.js +250 -0
- package/lib/stages/postgen/introspection/reflect.js +1214 -0
- package/lib/stages/postgen/introspection/report.js +1208 -0
- package/lib/stages/postgen/introspection/score.js +1067 -0
- package/lib/stages/postgen/introspection/shapeCommand.js +304 -0
- package/lib/stages/postgen/parentEdge.js +156 -0
- package/lib/stages/postgen/postgen.js +284 -3
- package/lib/stages/postgen/ruleEngine.js +17 -0
- package/lib/stages/pregen/envAudit.js +42 -2
- package/lib/stages/pregen/pregen.js +1171 -6
- package/lib/third-party/arborist/snapshots/calc-dep-flags.test.cjs +462 -0
- package/lib/validator/bomValidator.js +11 -2
- package/package.json +26 -26
- package/types/lib/audit/index.d.ts.map +1 -1
- package/types/lib/audit/scoring.d.ts +2 -8
- package/types/lib/audit/scoring.d.ts.map +1 -1
- package/types/lib/audit/targets.d.ts.map +1 -1
- package/types/lib/cli/bomAssembly.d.ts.map +1 -1
- package/types/lib/cli/cliOptions.d.ts +2 -1
- package/types/lib/cli/cliOptions.d.ts.map +1 -1
- package/types/lib/cli/index.d.ts +10 -2
- package/types/lib/cli/index.d.ts.map +1 -1
- package/types/lib/cli/jsBom.d.ts +23 -0
- package/types/lib/cli/jsBom.d.ts.map +1 -1
- package/types/lib/cli/jvmBom.d.ts.map +1 -1
- package/types/lib/cli/managedBom.d.ts +33 -0
- package/types/lib/cli/managedBom.d.ts.map +1 -1
- package/types/lib/cli/nativeBom.d.ts +88 -8
- package/types/lib/cli/nativeBom.d.ts.map +1 -1
- package/types/lib/core/activity.d.ts.map +1 -1
- package/types/lib/core/buildLedger.d.ts +272 -0
- package/types/lib/core/buildLedger.d.ts.map +1 -0
- package/types/lib/core/deferredExit.d.ts +84 -0
- package/types/lib/core/deferredExit.d.ts.map +1 -0
- package/types/lib/core/env.d.ts +43 -1
- package/types/lib/core/env.d.ts.map +1 -1
- package/types/lib/core/fs.d.ts +21 -0
- package/types/lib/core/fs.d.ts.map +1 -1
- package/types/lib/core/logger.d.ts +2 -11
- package/types/lib/core/logger.d.ts.map +1 -1
- package/types/lib/core/severity.d.ts +11 -0
- package/types/lib/core/severity.d.ts.map +1 -0
- package/types/lib/core/syncFileWriter.d.ts +33 -0
- package/types/lib/core/syncFileWriter.d.ts.map +1 -0
- package/types/lib/core/userAgent.d.ts +56 -0
- package/types/lib/core/userAgent.d.ts.map +1 -0
- package/types/lib/ecosystems/cargoCache.d.ts +75 -0
- package/types/lib/ecosystems/cargoCache.d.ts.map +1 -0
- package/types/lib/ecosystems/caxa.d.ts.map +1 -1
- package/types/lib/ecosystems/cppEvidence.d.ts +1 -1
- package/types/lib/ecosystems/cppEvidence.d.ts.map +1 -1
- package/types/lib/ecosystems/ecosystems.d.ts +15 -1
- package/types/lib/ecosystems/ecosystems.d.ts.map +1 -1
- package/types/lib/ecosystems/gradleutils.d.ts +53 -0
- package/types/lib/ecosystems/gradleutils.d.ts.map +1 -1
- package/types/lib/ecosystems/kosi.d.ts +73 -0
- package/types/lib/ecosystems/kosi.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-crystal.d.ts +27 -0
- package/types/lib/ecosystems/parsers-crystal.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-dotnet.d.ts +19 -0
- package/types/lib/ecosystems/parsers-dotnet.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-elm.d.ts +79 -0
- package/types/lib/ecosystems/parsers-elm.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-js.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-julia.d.ts +57 -0
- package/types/lib/ecosystems/parsers-julia.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-jvm.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-lua.d.ts +50 -0
- package/types/lib/ecosystems/parsers-lua.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-misc.d.ts +23 -0
- package/types/lib/ecosystems/parsers-misc.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-nim.d.ts +43 -0
- package/types/lib/ecosystems/parsers-nim.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-opam.d.ts +31 -0
- package/types/lib/ecosystems/parsers-opam.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-perl.d.ts +36 -0
- package/types/lib/ecosystems/parsers-perl.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-python.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-r.d.ts +35 -0
- package/types/lib/ecosystems/parsers-r.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-rebar.d.ts +42 -0
- package/types/lib/ecosystems/parsers-rebar.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-rust.d.ts +199 -0
- package/types/lib/ecosystems/parsers-rust.d.ts.map +1 -1
- package/types/lib/ecosystems/parsers-spack.d.ts +33 -0
- package/types/lib/ecosystems/parsers-spack.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-stack.d.ts +35 -0
- package/types/lib/ecosystems/parsers-stack.d.ts.map +1 -0
- package/types/lib/ecosystems/parsers-terraform.d.ts +34 -0
- package/types/lib/ecosystems/parsers-terraform.d.ts.map +1 -0
- package/types/lib/ecosystems/pypiClassifiers.d.ts +80 -0
- package/types/lib/ecosystems/pypiClassifiers.d.ts.map +1 -0
- package/types/lib/ecosystems/pythonutils.d.ts +21 -1
- package/types/lib/ecosystems/pythonutils.d.ts.map +1 -1
- package/types/lib/ecosystems/rubyutils.d.ts.map +1 -1
- package/types/lib/ecosystems/rusi.d.ts.map +1 -1
- package/types/lib/evinser/evinser.d.ts +34 -1
- package/types/lib/evinser/evinser.d.ts.map +1 -1
- package/types/lib/helpers/agenticToolutils.d.ts +87 -0
- package/types/lib/helpers/agenticToolutils.d.ts.map +1 -0
- package/types/lib/helpers/remote/dependency-track.d.ts +45 -4
- package/types/lib/helpers/remote/dependency-track.d.ts.map +1 -1
- package/types/lib/inventory/agentFormulationParser.d.ts.map +1 -1
- package/types/lib/inventory/aiCollector.d.ts.map +1 -1
- package/types/lib/inventory/aiInventory.d.ts.map +1 -1
- package/types/lib/inventory/analyzer.d.ts.map +1 -1
- package/types/lib/inventory/auditCategories.d.ts +12 -0
- package/types/lib/inventory/auditCategories.d.ts.map +1 -1
- package/types/lib/inventory/cbomutils.d.ts.map +1 -1
- package/types/lib/inventory/communityAiConfigParser.d.ts.map +1 -1
- package/types/lib/inventory/depsUtils.d.ts.map +1 -1
- package/types/lib/inventory/dosai.d.ts +43 -0
- package/types/lib/inventory/dosai.d.ts.map +1 -1
- package/types/lib/inventory/envcontext.d.ts.map +1 -1
- package/types/lib/inventory/evidenceUtils.d.ts.map +1 -1
- package/types/lib/inventory/fetchBatch.d.ts +43 -0
- package/types/lib/inventory/fetchBatch.d.ts.map +1 -1
- package/types/lib/inventory/fetchRate.d.ts +9 -6
- package/types/lib/inventory/fetchRate.d.ts.map +1 -1
- package/types/lib/inventory/forgeEnricher.d.ts.map +1 -1
- package/types/lib/inventory/jvmToolEnv.d.ts +190 -0
- package/types/lib/inventory/jvmToolEnv.d.ts.map +1 -0
- package/types/lib/inventory/mcpConfigParser.d.ts.map +1 -1
- package/types/lib/inventory/mcpDiscovery.d.ts.map +1 -1
- package/types/lib/inventory/mcpServerManifest.d.ts +19 -0
- package/types/lib/inventory/mcpServerManifest.d.ts.map +1 -0
- package/types/lib/inventory/mcpbBundle.d.ts +19 -0
- package/types/lib/inventory/mcpbBundle.d.ts.map +1 -0
- package/types/lib/inventory/osinfo.d.ts.map +1 -1
- package/types/lib/inventory/plugins.d.ts.map +1 -1
- package/types/lib/inventory/protobom.d.ts +18 -13
- package/types/lib/inventory/protobom.d.ts.map +1 -1
- package/types/lib/inventory/protobomLoader.d.ts.map +1 -1
- package/types/lib/inventory/source.d.ts.map +1 -1
- package/types/lib/inventory/stylePackageRefs.d.ts +17 -0
- package/types/lib/inventory/stylePackageRefs.d.ts.map +1 -0
- package/types/lib/inventory/svelteUtils.d.ts +124 -0
- package/types/lib/inventory/svelteUtils.d.ts.map +1 -0
- package/types/lib/inventory/toolRequirements.d.ts +216 -0
- package/types/lib/inventory/toolRequirements.d.ts.map +1 -0
- package/types/lib/managers/binary.d.ts.map +1 -1
- package/types/lib/managers/docker.d.ts.map +1 -1
- package/types/lib/parsers/huggingfaceUtils.d.ts +8 -1
- package/types/lib/parsers/huggingfaceUtils.d.ts.map +1 -1
- package/types/lib/parsers/onnx.d.ts +28 -0
- package/types/lib/parsers/onnx.d.ts.map +1 -0
- package/types/lib/parsers/safetensors.d.ts +22 -0
- package/types/lib/parsers/safetensors.d.ts.map +1 -0
- package/types/lib/stages/postgen/annotationBuilder.d.ts +53 -0
- package/types/lib/stages/postgen/annotationBuilder.d.ts.map +1 -0
- package/types/lib/stages/postgen/auditBom.d.ts.map +1 -1
- package/types/lib/stages/postgen/introspection/annotate.d.ts +81 -0
- package/types/lib/stages/postgen/introspection/annotate.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/commandFacts.d.ts +32 -0
- package/types/lib/stages/postgen/introspection/commandFacts.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/emit.d.ts +71 -0
- package/types/lib/stages/postgen/introspection/emit.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/formulationEvidence.d.ts +154 -0
- package/types/lib/stages/postgen/introspection/formulationEvidence.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/markers.d.ts +58 -0
- package/types/lib/stages/postgen/introspection/markers.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/reflect.d.ts +77 -0
- package/types/lib/stages/postgen/introspection/reflect.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/report.d.ts +85 -0
- package/types/lib/stages/postgen/introspection/report.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/score.d.ts +149 -0
- package/types/lib/stages/postgen/introspection/score.d.ts.map +1 -0
- package/types/lib/stages/postgen/introspection/shapeCommand.d.ts +79 -0
- package/types/lib/stages/postgen/introspection/shapeCommand.d.ts.map +1 -0
- package/types/lib/stages/postgen/parentEdge.d.ts +35 -0
- package/types/lib/stages/postgen/parentEdge.d.ts.map +1 -0
- package/types/lib/stages/postgen/postgen.d.ts +35 -2
- 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/envAudit.d.ts.map +1 -1
- package/types/lib/stages/pregen/pregen.d.ts +131 -0
- package/types/lib/stages/pregen/pregen.d.ts.map +1 -1
- package/types/lib/validator/bomValidator.d.ts.map +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
|
+
import { randomBytes } from "node:crypto";
|
|
2
3
|
|
|
3
4
|
import { hasDangerousUnicode } from "../../core/activity.js";
|
|
4
5
|
|
|
@@ -44,26 +45,23 @@ export function getDependencyTrackBomUrl(serverUrl) {
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
|
-
* Build the
|
|
48
|
+
* Build the form fields for a Dependency-Track BOM submission.
|
|
49
|
+
*
|
|
50
|
+
* Field names follow the `multipart/form-data` variant of `/api/v1/bom`, which differs
|
|
51
|
+
* from the JSON variant: the JSON body calls the flag `isLatestProjectVersion` and takes
|
|
52
|
+
* `projectTags` as an array of objects, while the form takes `isLatest` and a
|
|
53
|
+
* comma-separated tag list.
|
|
48
54
|
*
|
|
49
55
|
* @param {Object} args CLI/server arguments
|
|
50
|
-
* @
|
|
51
|
-
* @returns {Object | undefined} payload object if project coordinates are valid
|
|
56
|
+
* @returns {Object | undefined} field map if the project coordinates are valid
|
|
52
57
|
*/
|
|
53
|
-
export function buildDependencyTrackBomPayload(args
|
|
54
|
-
let encodedBomContents = Buffer.from(JSON.stringify(bomContents)).toString(
|
|
55
|
-
"base64",
|
|
56
|
-
);
|
|
57
|
-
if (encodedBomContents.startsWith("77u/")) {
|
|
58
|
-
encodedBomContents = encodedBomContents.substring(4);
|
|
59
|
-
}
|
|
58
|
+
export function buildDependencyTrackBomPayload(args) {
|
|
60
59
|
const autoCreate =
|
|
61
60
|
typeof args.autoCreate === "boolean"
|
|
62
61
|
? args.autoCreate
|
|
63
62
|
: args.autoCreate !== "false";
|
|
64
63
|
const bomPayload = {
|
|
65
64
|
autoCreate: String(autoCreate),
|
|
66
|
-
bom: encodedBomContents,
|
|
67
65
|
};
|
|
68
66
|
if (
|
|
69
67
|
typeof args.projectId !== "undefined" ||
|
|
@@ -103,15 +101,84 @@ export function buildDependencyTrackBomPayload(args, bomContents) {
|
|
|
103
101
|
args.isLatest === "true" ||
|
|
104
102
|
args.isLatest === "false"
|
|
105
103
|
) {
|
|
106
|
-
bomPayload.isLatest =
|
|
104
|
+
bomPayload.isLatest = String(
|
|
107
105
|
typeof args.isLatest === "boolean"
|
|
108
106
|
? args.isLatest
|
|
109
|
-
: args.isLatest === "true"
|
|
107
|
+
: args.isLatest === "true",
|
|
108
|
+
);
|
|
110
109
|
}
|
|
111
110
|
if (typeof args.projectTag !== "undefined") {
|
|
111
|
+
// The server splits this field on commas, so a tag cannot itself contain one.
|
|
112
112
|
bomPayload.projectTags = (
|
|
113
113
|
Array.isArray(args.projectTag) ? args.projectTag : [args.projectTag]
|
|
114
|
-
).
|
|
114
|
+
).join(",");
|
|
115
115
|
}
|
|
116
116
|
return bomPayload;
|
|
117
117
|
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Encode text fields and a single file part as a `multipart/form-data` body.
|
|
121
|
+
*
|
|
122
|
+
* @param {Object} fields Text fields keyed by field name
|
|
123
|
+
* @param {Object} file File part
|
|
124
|
+
* @param {string} file.name Field name of the file part
|
|
125
|
+
* @param {string} file.filename File name reported to the server
|
|
126
|
+
* @param {string} file.contentType Content type of the file part
|
|
127
|
+
* @param {Buffer} file.content File content
|
|
128
|
+
* @returns {{ body: Buffer, contentType: string }} encoded body and its content type
|
|
129
|
+
*/
|
|
130
|
+
export function encodeMultipartFormData(fields, file) {
|
|
131
|
+
// A random boundary keeps the delimiter from colliding with the BOM content.
|
|
132
|
+
const boundary = `--------------------------cdxgen${randomBytes(16).toString("hex")}`;
|
|
133
|
+
const chunks = [];
|
|
134
|
+
const pushPart = (header, content) => {
|
|
135
|
+
chunks.push(
|
|
136
|
+
Buffer.from(`--${boundary}\r\n${header}\r\n\r\n`),
|
|
137
|
+
Buffer.isBuffer(content) ? content : Buffer.from(String(content)),
|
|
138
|
+
Buffer.from("\r\n"),
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
142
|
+
pushPart(`Content-Disposition: form-data; name="${name}"`, value);
|
|
143
|
+
}
|
|
144
|
+
pushPart(
|
|
145
|
+
`Content-Disposition: form-data; name="${file.name}"; filename="${file.filename}"\r\nContent-Type: ${file.contentType}`,
|
|
146
|
+
file.content,
|
|
147
|
+
);
|
|
148
|
+
chunks.push(Buffer.from(`--${boundary}--\r\n`));
|
|
149
|
+
return {
|
|
150
|
+
body: Buffer.concat(chunks),
|
|
151
|
+
contentType: `multipart/form-data; boundary=${boundary}`,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Build the `multipart/form-data` request for Dependency-Track BOM submission.
|
|
157
|
+
*
|
|
158
|
+
* The JSON variant of the endpoint carries the BOM as a base64 string, which Jackson
|
|
159
|
+
* refuses to read beyond 20,000,000 characters - roughly a 15 MB BOM, which container
|
|
160
|
+
* image scans exceed routinely. The form variant carries the BOM as a file part and has
|
|
161
|
+
* no such limit, and is what the server recommends for large uploads.
|
|
162
|
+
*
|
|
163
|
+
* @param {Object} args CLI/server arguments
|
|
164
|
+
* @param {Object | string} bomContents BOM Json
|
|
165
|
+
* @returns {{ body: Buffer, contentType: string } | undefined} request body and content type if the arguments are valid
|
|
166
|
+
*/
|
|
167
|
+
export function buildDependencyTrackBomRequest(args, bomContents) {
|
|
168
|
+
if (!bomContents) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
const fields = buildDependencyTrackBomPayload(args);
|
|
172
|
+
if (!fields) {
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
const bomString =
|
|
176
|
+
typeof bomContents === "string" ? bomContents : JSON.stringify(bomContents);
|
|
177
|
+
return encodeMultipartFormData(fields, {
|
|
178
|
+
name: "bom",
|
|
179
|
+
filename: "bom.json",
|
|
180
|
+
contentType: "application/vnd.cyclonedx+json",
|
|
181
|
+
// The server rejects a BOM that still carries a byte order mark.
|
|
182
|
+
content: Buffer.from(bomString.replace(/^\ufeff/, "")),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
import { basename, extname } from "node:path";
|
|
2
|
+
import { basename, dirname, extname, join } from "node:path";
|
|
3
3
|
|
|
4
|
+
import { safeExistsSync } from "../core/fs.js";
|
|
4
5
|
import { sanitizeBomUrl } from "../core/propertySanitizer.js";
|
|
5
6
|
import {
|
|
6
7
|
credentialIndicatorsForText,
|
|
@@ -11,10 +12,20 @@ import {
|
|
|
11
12
|
import { scanTextForHiddenUnicode } from "./unicodeScan.js";
|
|
12
13
|
|
|
13
14
|
const AGENT_FILE_PATTERNS = [
|
|
15
|
+
// The discovery glob is case-insensitive, so a single entry covers AGENTS.md
|
|
16
|
+
// and agents.md; AGENT.md is a distinct singular filename.
|
|
14
17
|
"AGENTS.md",
|
|
15
|
-
"
|
|
18
|
+
"AGENT.md",
|
|
16
19
|
"CLAUDE.md",
|
|
20
|
+
"GEMINI.md",
|
|
21
|
+
"QWEN.md",
|
|
17
22
|
"Cursor.md",
|
|
23
|
+
"CONVENTIONS.md",
|
|
24
|
+
".cursorrules",
|
|
25
|
+
".windsurfrules",
|
|
26
|
+
".clinerules",
|
|
27
|
+
".clinerules/**/*.{md,markdown,txt}",
|
|
28
|
+
".aider.conf.yml",
|
|
18
29
|
".github/copilot-instructions.md",
|
|
19
30
|
".github/instructions/**/*.{md,mdx,markdown,txt}",
|
|
20
31
|
".github/workflows/copilot-setup-steps.yml",
|
|
@@ -49,15 +60,57 @@ function syntaxForFile(filePath) {
|
|
|
49
60
|
return "text";
|
|
50
61
|
}
|
|
51
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Determine whether a CONVENTIONS.md file is an Aider conventions file rather
|
|
65
|
+
* than an ordinary docs file, by looking for a sibling Aider marker.
|
|
66
|
+
*
|
|
67
|
+
* The original (not lower-cased) path must be passed: on a case-sensitive
|
|
68
|
+
* filesystem a lower-cased directory does not exist, which would silently make
|
|
69
|
+
* every CONVENTIONS.md look unmarked.
|
|
70
|
+
*
|
|
71
|
+
* @param {string} filePath Original file path as discovered
|
|
72
|
+
* @returns {boolean} true when an Aider marker sits alongside the file
|
|
73
|
+
*/
|
|
74
|
+
function hasAiderMarker(filePath) {
|
|
75
|
+
const directory = dirname(filePath);
|
|
76
|
+
return (
|
|
77
|
+
safeExistsSync(join(directory, ".aider.conf.yml")) ||
|
|
78
|
+
safeExistsSync(join(directory, ".aider.conf.yaml")) ||
|
|
79
|
+
safeExistsSync(join(directory, ".aider.model.settings.yml"))
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
52
83
|
function kindForFile(filePath) {
|
|
53
|
-
|
|
84
|
+
// Normalize separators so the endsWith/includes checks below behave the same
|
|
85
|
+
// on Windows (backslash) and POSIX (forward slash) absolute paths.
|
|
86
|
+
const lowerPath = filePath.replaceAll("\\", "/").toLowerCase();
|
|
54
87
|
if (lowerPath.endsWith("copilot-setup-steps.yml")) {
|
|
55
88
|
return "copilot-setup-workflow";
|
|
56
89
|
}
|
|
57
90
|
if (lowerPath.endsWith("copilot-instructions.md")) {
|
|
58
91
|
return "copilot-instructions";
|
|
59
92
|
}
|
|
60
|
-
if (lowerPath.endsWith("
|
|
93
|
+
if (lowerPath.endsWith(".aider.conf.yml")) {
|
|
94
|
+
return "agent-config";
|
|
95
|
+
}
|
|
96
|
+
// CONVENTIONS.md is an Aider convention but also an ordinary docs filename.
|
|
97
|
+
// Only classify it as agent instructions when an Aider marker sits beside it;
|
|
98
|
+
// otherwise treat it as a generic file so unrelated repos are not tagged.
|
|
99
|
+
if (lowerPath.endsWith("conventions.md")) {
|
|
100
|
+
return hasAiderMarker(filePath) ? "agent-instructions" : "ai-agent-file";
|
|
101
|
+
}
|
|
102
|
+
if (
|
|
103
|
+
lowerPath.endsWith("agents.md") ||
|
|
104
|
+
lowerPath.endsWith("agent.md") ||
|
|
105
|
+
lowerPath.endsWith("claude.md") ||
|
|
106
|
+
lowerPath.endsWith("gemini.md") ||
|
|
107
|
+
lowerPath.endsWith("qwen.md") ||
|
|
108
|
+
lowerPath.endsWith("cursor.md") ||
|
|
109
|
+
lowerPath.endsWith(".cursorrules") ||
|
|
110
|
+
lowerPath.endsWith(".windsurfrules") ||
|
|
111
|
+
lowerPath.endsWith(".clinerules") ||
|
|
112
|
+
lowerPath.includes("/.clinerules/")
|
|
113
|
+
) {
|
|
61
114
|
return "agent-instructions";
|
|
62
115
|
}
|
|
63
116
|
if (lowerPath.endsWith(".prompt") || lowerPath.endsWith(".mdc")) {
|