@cyclonedx/cdxgen 12.3.1 → 12.3.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 +6 -0
- package/bin/cdxgen.js +1 -2
- package/data/rules/ai-agent-governance.yaml +43 -0
- package/data/rules/ci-permissions.yaml +132 -0
- package/data/rules/dependency-sources.yaml +65 -5
- package/data/rules/mcp-servers.yaml +36 -2
- package/data/rules/package-integrity.yaml +22 -0
- package/lib/cli/index.js +436 -56
- package/lib/cli/index.poku.js +875 -2
- package/lib/helpers/agentFormulationParser.js +10 -3
- package/lib/helpers/agentFormulationParser.poku.js +42 -0
- package/lib/helpers/aiInventory.js +262 -0
- package/lib/helpers/aiInventory.poku.js +111 -0
- package/lib/helpers/analyzer.js +413 -54
- package/lib/helpers/analyzer.poku.js +117 -0
- package/lib/helpers/auditCategories.js +76 -0
- package/lib/helpers/chromextutils.js +25 -3
- package/lib/helpers/chromextutils.poku.js +68 -0
- package/lib/helpers/ciParsers/githubActions.js +79 -0
- package/lib/helpers/ciParsers/githubActions.poku.js +103 -0
- package/lib/helpers/communityAiConfigParser.js +15 -5
- package/lib/helpers/communityAiConfigParser.poku.js +71 -0
- package/lib/helpers/depsUtils.js +5 -0
- package/lib/helpers/depsUtils.poku.js +55 -0
- package/lib/helpers/display.js +50 -24
- package/lib/helpers/display.poku.js +70 -58
- package/lib/helpers/formulationParsers.js +26 -6
- package/lib/helpers/jsonLike.js +21 -20
- package/lib/helpers/jsonLike.poku.js +34 -0
- package/lib/helpers/mcpConfigParser.js +32 -16
- package/lib/helpers/mcpConfigParser.poku.js +104 -0
- package/lib/helpers/mcpDiscovery.js +13 -23
- package/lib/helpers/mcpDiscovery.poku.js +21 -0
- package/lib/helpers/propertySanitizer.js +121 -0
- package/lib/helpers/utils.js +953 -41
- package/lib/helpers/utils.poku.js +901 -1
- package/lib/managers/binary.js +16 -0
- package/lib/managers/binary.poku.js +1 -0
- package/lib/managers/docker.js +240 -16
- package/lib/managers/docker.poku.js +1142 -2
- package/lib/server/server.js +7 -4
- package/lib/server/server.poku.js +36 -1
- package/lib/stages/postgen/annotator.js +2 -1
- package/lib/stages/postgen/annotator.poku.js +15 -0
- package/lib/stages/postgen/auditBom.js +12 -6
- package/lib/stages/postgen/auditBom.poku.js +755 -6
- package/lib/stages/postgen/postgen.js +229 -6
- package/lib/stages/postgen/postgen.poku.js +180 -0
- package/package.json +2 -1
- package/types/lib/cli/index.d.ts +1 -0
- package/types/lib/cli/index.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 +5 -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/chromextutils.d.ts.map +1 -1
- 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.map +1 -1
- package/types/lib/helpers/display.d.ts +1 -0
- 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/propertySanitizer.d.ts +3 -0
- package/types/lib/helpers/propertySanitizer.d.ts.map +1 -0
- package/types/lib/helpers/utils.d.ts +31 -0
- package/types/lib/helpers/utils.d.ts.map +1 -1
- package/types/lib/managers/binary.d.ts.map +1 -1
- package/types/lib/managers/docker.d.ts +3 -0
- package/types/lib/managers/docker.d.ts.map +1 -1
- package/types/lib/server/server.d.ts +1 -0
- package/types/lib/server/server.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/lib/server/server.js
CHANGED
|
@@ -76,23 +76,26 @@ const ALLOWED_PARAMS = [
|
|
|
76
76
|
|
|
77
77
|
const app = connect();
|
|
78
78
|
|
|
79
|
-
function isAllowedHttpHost(hostname) {
|
|
79
|
+
export function isAllowedHttpHost(hostname) {
|
|
80
80
|
if (!process.env.CDXGEN_ALLOWED_HOSTS) {
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
83
83
|
if (!hostname || hasDangerousUnicode(hostname)) {
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
|
+
const normalizedHostname = hostname.toLowerCase();
|
|
86
87
|
const allowHosts = process.env.CDXGEN_ALLOWED_HOSTS.split(",")
|
|
87
88
|
.map((host) => host.trim())
|
|
88
89
|
.filter(Boolean);
|
|
89
90
|
for (const allowedHost of allowHosts) {
|
|
90
|
-
|
|
91
|
+
const normalizedAllowedHost = allowedHost.toLowerCase();
|
|
92
|
+
if (normalizedHostname === normalizedAllowedHost) {
|
|
91
93
|
return true;
|
|
92
94
|
}
|
|
93
95
|
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
normalizedAllowedHost.startsWith("*.") &&
|
|
97
|
+
normalizedHostname.length > normalizedAllowedHost.length - 1 &&
|
|
98
|
+
normalizedHostname.endsWith(`.${normalizedAllowedHost.slice(2)}`)
|
|
96
99
|
) {
|
|
97
100
|
return true;
|
|
98
101
|
}
|
|
@@ -12,7 +12,12 @@ import {
|
|
|
12
12
|
validateAndRejectGitSource,
|
|
13
13
|
} from "../helpers/source.js";
|
|
14
14
|
import { isWin } from "../helpers/utils.js";
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
getQueryParams,
|
|
17
|
+
isAllowedHttpHost,
|
|
18
|
+
parseQueryString,
|
|
19
|
+
parseValue,
|
|
20
|
+
} from "./server.js";
|
|
16
21
|
|
|
17
22
|
function nullProtoObj(obj) {
|
|
18
23
|
if (obj === null || typeof obj !== "object") {
|
|
@@ -171,6 +176,36 @@ describe("isAllowedHost()", () => {
|
|
|
171
176
|
});
|
|
172
177
|
});
|
|
173
178
|
|
|
179
|
+
describe("isAllowedHttpHost()", () => {
|
|
180
|
+
let originalAllowedHosts;
|
|
181
|
+
|
|
182
|
+
beforeEach(() => {
|
|
183
|
+
originalAllowedHosts = process.env.CDXGEN_ALLOWED_HOSTS;
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
afterEach(() => {
|
|
187
|
+
if (originalAllowedHosts === undefined) {
|
|
188
|
+
delete process.env.CDXGEN_ALLOWED_HOSTS;
|
|
189
|
+
} else {
|
|
190
|
+
process.env.CDXGEN_ALLOWED_HOSTS = originalAllowedHosts;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("allows exact host matches", () => {
|
|
195
|
+
process.env.CDXGEN_ALLOWED_HOSTS = "dependencytrack.example.com";
|
|
196
|
+
assert.strictEqual(isAllowedHttpHost("dependencytrack.example.com"), true);
|
|
197
|
+
assert.strictEqual(isAllowedHttpHost("other.example.com"), false);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("allows only real subdomains for wildcard entries", () => {
|
|
201
|
+
process.env.CDXGEN_ALLOWED_HOSTS = "*.example.com";
|
|
202
|
+
assert.strictEqual(isAllowedHttpHost("api.example.com"), true);
|
|
203
|
+
assert.strictEqual(isAllowedHttpHost("deep.api.example.com"), true);
|
|
204
|
+
assert.strictEqual(isAllowedHttpHost("example.com"), false);
|
|
205
|
+
assert.strictEqual(isAllowedHttpHost("evil-example.com"), false);
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
|
|
174
209
|
describe("isAllowedPath()", () => {
|
|
175
210
|
let originalPaths;
|
|
176
211
|
|
|
@@ -285,7 +285,8 @@ export function textualMetadata(bomJson) {
|
|
|
285
285
|
const { bomType, bomTypeDescription } = findBomType(bomJson);
|
|
286
286
|
const metadata = bomJson.metadata;
|
|
287
287
|
const lifecycles = metadata?.lifecycles || [];
|
|
288
|
-
const tlpClassification =
|
|
288
|
+
const tlpClassification =
|
|
289
|
+
metadata.distributionConstraints?.tlp || metadata.distribution;
|
|
289
290
|
const cryptoAssetsCount = bomJson?.components?.filter(
|
|
290
291
|
(c) => c.type === "cryptographic-asset",
|
|
291
292
|
).length;
|
|
@@ -311,3 +311,18 @@ it("extractTags tests", () => {
|
|
|
311
311
|
"security",
|
|
312
312
|
]);
|
|
313
313
|
});
|
|
314
|
+
|
|
315
|
+
it("textualMetadata includes the CycloneDX 1.7 TLP classification from distributionConstraints", () => {
|
|
316
|
+
assert.match(
|
|
317
|
+
textualMetadata({
|
|
318
|
+
bomFormat: "CycloneDX",
|
|
319
|
+
specVersion: "1.7",
|
|
320
|
+
metadata: {
|
|
321
|
+
distributionConstraints: {
|
|
322
|
+
tlp: "AMBER_AND_STRICT",
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
}),
|
|
326
|
+
/TLP\) classification for this document is 'AMBER_AND_STRICT'/,
|
|
327
|
+
);
|
|
328
|
+
});
|
|
@@ -6,6 +6,10 @@ import { join, resolve } from "node:path";
|
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
|
|
8
8
|
import { buildAnnotationText } from "../../helpers/annotationFormatter.js";
|
|
9
|
+
import {
|
|
10
|
+
expandBomAuditCategories,
|
|
11
|
+
validateBomAuditCategories,
|
|
12
|
+
} from "../../helpers/auditCategories.js";
|
|
9
13
|
import { table } from "../../helpers/table.js";
|
|
10
14
|
import {
|
|
11
15
|
DEBUG_MODE,
|
|
@@ -45,15 +49,17 @@ export async function auditBom(bomJson, options) {
|
|
|
45
49
|
}
|
|
46
50
|
let activeRules = rules;
|
|
47
51
|
if (options.bomAuditCategories) {
|
|
48
|
-
const categories =
|
|
49
|
-
.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
const { categories, expandedCategories } = validateBomAuditCategories(
|
|
53
|
+
options.bomAuditCategories,
|
|
54
|
+
rules,
|
|
55
|
+
);
|
|
52
56
|
if (categories.length > 0) {
|
|
53
|
-
activeRules = rules.filter((r) =>
|
|
57
|
+
activeRules = rules.filter((r) =>
|
|
58
|
+
expandedCategories.includes(r.category),
|
|
59
|
+
);
|
|
54
60
|
if (DEBUG_MODE) {
|
|
55
61
|
console.log(
|
|
56
|
-
`Filtering rules by categories: ${categories.join(", ")} (${activeRules.length} active)`,
|
|
62
|
+
`Filtering rules by categories: ${categories.join(", ")} -> ${expandBomAuditCategories(categories).join(", ")} (${activeRules.length} active)`,
|
|
57
63
|
);
|
|
58
64
|
}
|
|
59
65
|
}
|