@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.
Files changed (87) hide show
  1. package/README.md +6 -0
  2. package/bin/cdxgen.js +1 -2
  3. package/data/rules/ai-agent-governance.yaml +43 -0
  4. package/data/rules/ci-permissions.yaml +132 -0
  5. package/data/rules/dependency-sources.yaml +65 -5
  6. package/data/rules/mcp-servers.yaml +36 -2
  7. package/data/rules/package-integrity.yaml +22 -0
  8. package/lib/cli/index.js +436 -56
  9. package/lib/cli/index.poku.js +875 -2
  10. package/lib/helpers/agentFormulationParser.js +10 -3
  11. package/lib/helpers/agentFormulationParser.poku.js +42 -0
  12. package/lib/helpers/aiInventory.js +262 -0
  13. package/lib/helpers/aiInventory.poku.js +111 -0
  14. package/lib/helpers/analyzer.js +413 -54
  15. package/lib/helpers/analyzer.poku.js +117 -0
  16. package/lib/helpers/auditCategories.js +76 -0
  17. package/lib/helpers/chromextutils.js +25 -3
  18. package/lib/helpers/chromextutils.poku.js +68 -0
  19. package/lib/helpers/ciParsers/githubActions.js +79 -0
  20. package/lib/helpers/ciParsers/githubActions.poku.js +103 -0
  21. package/lib/helpers/communityAiConfigParser.js +15 -5
  22. package/lib/helpers/communityAiConfigParser.poku.js +71 -0
  23. package/lib/helpers/depsUtils.js +5 -0
  24. package/lib/helpers/depsUtils.poku.js +55 -0
  25. package/lib/helpers/display.js +50 -24
  26. package/lib/helpers/display.poku.js +70 -58
  27. package/lib/helpers/formulationParsers.js +26 -6
  28. package/lib/helpers/jsonLike.js +21 -20
  29. package/lib/helpers/jsonLike.poku.js +34 -0
  30. package/lib/helpers/mcpConfigParser.js +32 -16
  31. package/lib/helpers/mcpConfigParser.poku.js +104 -0
  32. package/lib/helpers/mcpDiscovery.js +13 -23
  33. package/lib/helpers/mcpDiscovery.poku.js +21 -0
  34. package/lib/helpers/propertySanitizer.js +121 -0
  35. package/lib/helpers/utils.js +953 -41
  36. package/lib/helpers/utils.poku.js +901 -1
  37. package/lib/managers/binary.js +16 -0
  38. package/lib/managers/binary.poku.js +1 -0
  39. package/lib/managers/docker.js +240 -16
  40. package/lib/managers/docker.poku.js +1142 -2
  41. package/lib/server/server.js +7 -4
  42. package/lib/server/server.poku.js +36 -1
  43. package/lib/stages/postgen/annotator.js +2 -1
  44. package/lib/stages/postgen/annotator.poku.js +15 -0
  45. package/lib/stages/postgen/auditBom.js +12 -6
  46. package/lib/stages/postgen/auditBom.poku.js +755 -6
  47. package/lib/stages/postgen/postgen.js +229 -6
  48. package/lib/stages/postgen/postgen.poku.js +180 -0
  49. package/package.json +2 -1
  50. package/types/lib/cli/index.d.ts +1 -0
  51. package/types/lib/cli/index.d.ts.map +1 -1
  52. package/types/lib/helpers/agentFormulationParser.d.ts +19 -0
  53. package/types/lib/helpers/agentFormulationParser.d.ts.map +1 -0
  54. package/types/lib/helpers/aiInventory.d.ts +23 -0
  55. package/types/lib/helpers/aiInventory.d.ts.map +1 -0
  56. package/types/lib/helpers/analyzer.d.ts +5 -0
  57. package/types/lib/helpers/analyzer.d.ts.map +1 -1
  58. package/types/lib/helpers/auditCategories.d.ts +12 -0
  59. package/types/lib/helpers/auditCategories.d.ts.map +1 -0
  60. package/types/lib/helpers/chromextutils.d.ts.map +1 -1
  61. package/types/lib/helpers/ciParsers/githubActions.d.ts.map +1 -1
  62. package/types/lib/helpers/communityAiConfigParser.d.ts +29 -0
  63. package/types/lib/helpers/communityAiConfigParser.d.ts.map +1 -0
  64. package/types/lib/helpers/depsUtils.d.ts.map +1 -1
  65. package/types/lib/helpers/display.d.ts +1 -0
  66. package/types/lib/helpers/display.d.ts.map +1 -1
  67. package/types/lib/helpers/formulationParsers.d.ts.map +1 -1
  68. package/types/lib/helpers/jsonLike.d.ts +4 -0
  69. package/types/lib/helpers/jsonLike.d.ts.map +1 -0
  70. package/types/lib/helpers/mcp.d.ts +29 -0
  71. package/types/lib/helpers/mcp.d.ts.map +1 -0
  72. package/types/lib/helpers/mcpConfigParser.d.ts +30 -0
  73. package/types/lib/helpers/mcpConfigParser.d.ts.map +1 -0
  74. package/types/lib/helpers/mcpDiscovery.d.ts +5 -0
  75. package/types/lib/helpers/mcpDiscovery.d.ts.map +1 -0
  76. package/types/lib/helpers/propertySanitizer.d.ts +3 -0
  77. package/types/lib/helpers/propertySanitizer.d.ts.map +1 -0
  78. package/types/lib/helpers/utils.d.ts +31 -0
  79. package/types/lib/helpers/utils.d.ts.map +1 -1
  80. package/types/lib/managers/binary.d.ts.map +1 -1
  81. package/types/lib/managers/docker.d.ts +3 -0
  82. package/types/lib/managers/docker.d.ts.map +1 -1
  83. package/types/lib/server/server.d.ts +1 -0
  84. package/types/lib/server/server.d.ts.map +1 -1
  85. package/types/lib/stages/postgen/annotator.d.ts.map +1 -1
  86. package/types/lib/stages/postgen/auditBom.d.ts.map +1 -1
  87. package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
@@ -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
- if (hostname === allowedHost) {
91
+ const normalizedAllowedHost = allowedHost.toLowerCase();
92
+ if (normalizedHostname === normalizedAllowedHost) {
91
93
  return true;
92
94
  }
93
95
  if (
94
- allowedHost.startsWith("*.") &&
95
- hostname.endsWith(allowedHost.slice(1))
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 { getQueryParams, parseQueryString, parseValue } from "./server.js";
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 = metadata.distribution;
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 = options.bomAuditCategories
49
- .split(",")
50
- .map((c) => c.trim())
51
- .filter(Boolean);
52
+ const { categories, expandedCategories } = validateBomAuditCategories(
53
+ options.bomAuditCategories,
54
+ rules,
55
+ );
52
56
  if (categories.length > 0) {
53
- activeRules = rules.filter((r) => categories.includes(r.category));
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
  }