circle-ir 4.19.0 → 4.21.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.
Files changed (262) hide show
  1. package/dist/analysis/advisories.d.ts +21 -3
  2. package/dist/analysis/advisories.d.ts.map +1 -1
  3. package/dist/analysis/advisories.js +26 -8
  4. package/dist/analysis/advisories.js.map +1 -1
  5. package/dist/analysis/arg-executing-programs.d.ts +16 -0
  6. package/dist/analysis/arg-executing-programs.d.ts.map +1 -0
  7. package/dist/analysis/arg-executing-programs.js +24 -0
  8. package/dist/analysis/arg-executing-programs.js.map +1 -0
  9. package/dist/analysis/config-loader.d.ts.map +1 -1
  10. package/dist/analysis/config-loader.js +27 -3
  11. package/dist/analysis/config-loader.js.map +1 -1
  12. package/dist/analysis/constant-caller-gate.d.ts +3 -1
  13. package/dist/analysis/constant-caller-gate.d.ts.map +1 -1
  14. package/dist/analysis/constant-caller-gate.js +108 -1
  15. package/dist/analysis/constant-caller-gate.js.map +1 -1
  16. package/dist/analysis/constant-propagation/index.d.ts.map +1 -1
  17. package/dist/analysis/constant-propagation/index.js +1 -1
  18. package/dist/analysis/constant-propagation/index.js.map +1 -1
  19. package/dist/analysis/constant-propagation/patterns.d.ts.map +1 -1
  20. package/dist/analysis/constant-propagation/patterns.js +8 -0
  21. package/dist/analysis/constant-propagation/patterns.js.map +1 -1
  22. package/dist/analysis/constant-propagation/propagator.d.ts +47 -2
  23. package/dist/analysis/constant-propagation/propagator.d.ts.map +1 -1
  24. package/dist/analysis/constant-propagation/propagator.js +422 -57
  25. package/dist/analysis/constant-propagation/propagator.js.map +1 -1
  26. package/dist/analysis/constant-propagation/types.d.ts +2 -0
  27. package/dist/analysis/constant-propagation/types.d.ts.map +1 -1
  28. package/dist/analysis/dependency-versions.d.ts +33 -0
  29. package/dist/analysis/dependency-versions.d.ts.map +1 -1
  30. package/dist/analysis/dependency-versions.js +70 -0
  31. package/dist/analysis/dependency-versions.js.map +1 -1
  32. package/dist/analysis/findings.d.ts.map +1 -1
  33. package/dist/analysis/findings.js +7 -5
  34. package/dist/analysis/findings.js.map +1 -1
  35. package/dist/analysis/interprocedural.d.ts +16 -0
  36. package/dist/analysis/interprocedural.d.ts.map +1 -1
  37. package/dist/analysis/interprocedural.js +545 -197
  38. package/dist/analysis/interprocedural.js.map +1 -1
  39. package/dist/analysis/passes/constant-propagation-pass.d.ts.map +1 -1
  40. package/dist/analysis/passes/constant-propagation-pass.js +1 -0
  41. package/dist/analysis/passes/constant-propagation-pass.js.map +1 -1
  42. package/dist/analysis/passes/cross-file-pass.d.ts.map +1 -1
  43. package/dist/analysis/passes/cross-file-pass.js +61 -0
  44. package/dist/analysis/passes/cross-file-pass.js.map +1 -1
  45. package/dist/analysis/passes/csharp-sanitizer-credit.d.ts.map +1 -1
  46. package/dist/analysis/passes/csharp-sanitizer-credit.js +60 -3
  47. package/dist/analysis/passes/csharp-sanitizer-credit.js.map +1 -1
  48. package/dist/analysis/passes/csrf-samesite-none-session-pass.d.ts +58 -0
  49. package/dist/analysis/passes/csrf-samesite-none-session-pass.d.ts.map +1 -0
  50. package/dist/analysis/passes/csrf-samesite-none-session-pass.js +159 -0
  51. package/dist/analysis/passes/csrf-samesite-none-session-pass.js.map +1 -0
  52. package/dist/analysis/passes/deserialization-safety-gate-pass.d.ts +15 -0
  53. package/dist/analysis/passes/deserialization-safety-gate-pass.d.ts.map +1 -1
  54. package/dist/analysis/passes/deserialization-safety-gate-pass.js +60 -1
  55. package/dist/analysis/passes/deserialization-safety-gate-pass.js.map +1 -1
  56. package/dist/analysis/passes/interprocedural-pass.d.ts +23 -1
  57. package/dist/analysis/passes/interprocedural-pass.d.ts.map +1 -1
  58. package/dist/analysis/passes/interprocedural-pass.js +220 -7
  59. package/dist/analysis/passes/interprocedural-pass.js.map +1 -1
  60. package/dist/analysis/passes/language-sources-pass.d.ts +0 -18
  61. package/dist/analysis/passes/language-sources-pass.d.ts.map +1 -1
  62. package/dist/analysis/passes/language-sources-pass.js +549 -22
  63. package/dist/analysis/passes/language-sources-pass.js.map +1 -1
  64. package/dist/analysis/passes/param-source-flow-gate-pass.d.ts.map +1 -1
  65. package/dist/analysis/passes/param-source-flow-gate-pass.js +71 -1
  66. package/dist/analysis/passes/param-source-flow-gate-pass.js.map +1 -1
  67. package/dist/analysis/passes/prompt-injection-safety-gate-pass.js +1 -1
  68. package/dist/analysis/passes/prompt-injection-safety-gate-pass.js.map +1 -1
  69. package/dist/analysis/passes/resource-leak-pass.d.ts.map +1 -1
  70. package/dist/analysis/passes/resource-leak-pass.js +15 -3
  71. package/dist/analysis/passes/resource-leak-pass.js.map +1 -1
  72. package/dist/analysis/passes/scan-secrets-pass.js +2 -2
  73. package/dist/analysis/passes/scan-secrets-pass.js.map +1 -1
  74. package/dist/analysis/passes/sensitive-data-in-log-pass.d.ts +66 -0
  75. package/dist/analysis/passes/sensitive-data-in-log-pass.d.ts.map +1 -0
  76. package/dist/analysis/passes/sensitive-data-in-log-pass.js +462 -0
  77. package/dist/analysis/passes/sensitive-data-in-log-pass.js.map +1 -0
  78. package/dist/analysis/passes/sink-filter-pass.d.ts +7 -1
  79. package/dist/analysis/passes/sink-filter-pass.d.ts.map +1 -1
  80. package/dist/analysis/passes/sink-filter-pass.js +564 -22
  81. package/dist/analysis/passes/sink-filter-pass.js.map +1 -1
  82. package/dist/analysis/passes/taint-propagation-pass.d.ts +7 -3
  83. package/dist/analysis/passes/taint-propagation-pass.d.ts.map +1 -1
  84. package/dist/analysis/passes/taint-propagation-pass.js +464 -27
  85. package/dist/analysis/passes/taint-propagation-pass.js.map +1 -1
  86. package/dist/analysis/passes/xml-entity-expansion-pass.d.ts.map +1 -1
  87. package/dist/analysis/passes/xml-entity-expansion-pass.js +50 -6
  88. package/dist/analysis/passes/xml-entity-expansion-pass.js.map +1 -1
  89. package/dist/analysis/pep440-version.d.ts +40 -0
  90. package/dist/analysis/pep440-version.d.ts.map +1 -0
  91. package/dist/analysis/pep440-version.js +149 -0
  92. package/dist/analysis/pep440-version.js.map +1 -0
  93. package/dist/analysis/project-callee-escape-gate.js +1 -1
  94. package/dist/analysis/project-callee-escape-gate.js.map +1 -1
  95. package/dist/analysis/rules.d.ts.map +1 -1
  96. package/dist/analysis/rules.js +15 -0
  97. package/dist/analysis/rules.js.map +1 -1
  98. package/dist/analysis/sbom.d.ts +92 -4
  99. package/dist/analysis/sbom.d.ts.map +1 -1
  100. package/dist/analysis/sbom.js +390 -33
  101. package/dist/analysis/sbom.js.map +1 -1
  102. package/dist/analysis/taint-matcher.d.ts.map +1 -1
  103. package/dist/analysis/taint-matcher.js +124 -19
  104. package/dist/analysis/taint-matcher.js.map +1 -1
  105. package/dist/analysis/taint-propagation.d.ts +1 -0
  106. package/dist/analysis/taint-propagation.d.ts.map +1 -1
  107. package/dist/analysis/taint-propagation.js +32 -0
  108. package/dist/analysis/taint-propagation.js.map +1 -1
  109. package/dist/analysis/test-to-production-taint-gate.d.ts +13 -0
  110. package/dist/analysis/test-to-production-taint-gate.d.ts.map +1 -0
  111. package/dist/analysis/test-to-production-taint-gate.js +30 -0
  112. package/dist/analysis/test-to-production-taint-gate.js.map +1 -0
  113. package/dist/analyzer.d.ts +21 -3
  114. package/dist/analyzer.d.ts.map +1 -1
  115. package/dist/analyzer.js +83 -3
  116. package/dist/analyzer.js.map +1 -1
  117. package/dist/browser/circle-ir.js +8118 -2526
  118. package/dist/core/circle-ir-core.cjs +3098 -2280
  119. package/dist/core/circle-ir-core.js +3036 -2214
  120. package/dist/core/extractors/calls.d.ts +10 -1
  121. package/dist/core/extractors/calls.d.ts.map +1 -1
  122. package/dist/core/extractors/calls.js +148 -6
  123. package/dist/core/extractors/calls.js.map +1 -1
  124. package/dist/core/extractors/cfg.d.ts.map +1 -1
  125. package/dist/core/extractors/cfg.js +12 -0
  126. package/dist/core/extractors/cfg.js.map +1 -1
  127. package/dist/core/extractors/dfg.d.ts.map +1 -1
  128. package/dist/core/extractors/dfg.js +151 -18
  129. package/dist/core/extractors/dfg.js.map +1 -1
  130. package/dist/core/extractors/ts-declaration-detail.d.ts +8 -0
  131. package/dist/core/extractors/ts-declaration-detail.d.ts.map +1 -1
  132. package/dist/core/extractors/ts-declaration-detail.js +22 -0
  133. package/dist/core/extractors/ts-declaration-detail.js.map +1 -1
  134. package/dist/core/extractors/types.d.ts +5 -0
  135. package/dist/core/extractors/types.d.ts.map +1 -1
  136. package/dist/core/extractors/types.js +149 -4
  137. package/dist/core/extractors/types.js.map +1 -1
  138. package/dist/core/parser.d.ts.map +1 -1
  139. package/dist/core/parser.js +3 -1
  140. package/dist/core/parser.js.map +1 -1
  141. package/dist/core/ts-grammar-workarounds.d.ts +18 -0
  142. package/dist/core/ts-grammar-workarounds.d.ts.map +1 -0
  143. package/dist/core/ts-grammar-workarounds.js +40 -0
  144. package/dist/core/ts-grammar-workarounds.js.map +1 -0
  145. package/dist/facts/arrow.d.ts +106 -0
  146. package/dist/facts/arrow.d.ts.map +1 -0
  147. package/dist/facts/arrow.js +196 -0
  148. package/dist/facts/arrow.js.map +1 -0
  149. package/dist/facts/facts2.d.ts +68 -0
  150. package/dist/facts/facts2.d.ts.map +1 -0
  151. package/dist/facts/facts2.js +379 -0
  152. package/dist/facts/facts2.js.map +1 -0
  153. package/dist/facts/index.d.ts +22 -0
  154. package/dist/facts/index.d.ts.map +1 -0
  155. package/dist/facts/index.js +15 -0
  156. package/dist/facts/index.js.map +1 -0
  157. package/dist/facts/java-facts.d.ts +56 -0
  158. package/dist/facts/java-facts.d.ts.map +1 -0
  159. package/dist/facts/java-facts.js +250 -0
  160. package/dist/facts/java-facts.js.map +1 -0
  161. package/dist/facts/order.d.ts +39 -0
  162. package/dist/facts/order.d.ts.map +1 -0
  163. package/dist/facts/order.js +120 -0
  164. package/dist/facts/order.js.map +1 -0
  165. package/dist/facts/schema.d.ts +60 -0
  166. package/dist/facts/schema.d.ts.map +1 -0
  167. package/dist/facts/schema.js +126 -0
  168. package/dist/facts/schema.js.map +1 -0
  169. package/dist/facts/schema2.d.ts +47 -0
  170. package/dist/facts/schema2.d.ts.map +1 -0
  171. package/dist/facts/schema2.js +194 -0
  172. package/dist/facts/schema2.js.map +1 -0
  173. package/dist/facts/t6.d.ts +84 -0
  174. package/dist/facts/t6.d.ts.map +1 -0
  175. package/dist/facts/t6.js +226 -0
  176. package/dist/facts/t6.js.map +1 -0
  177. package/dist/facts/table.d.ts +80 -0
  178. package/dist/facts/table.d.ts.map +1 -0
  179. package/dist/facts/table.js +548 -0
  180. package/dist/facts/table.js.map +1 -0
  181. package/dist/graph-facts/dead-code.d.ts +2 -0
  182. package/dist/graph-facts/dead-code.d.ts.map +1 -1
  183. package/dist/graph-facts/dead-code.js +4 -3
  184. package/dist/graph-facts/dead-code.js.map +1 -1
  185. package/dist/graph-facts/index.d.ts +1 -1
  186. package/dist/graph-facts/index.d.ts.map +1 -1
  187. package/dist/graph-facts/index.js +1 -1
  188. package/dist/graph-facts/index.js.map +1 -1
  189. package/dist/graph-facts/reach.d.ts +53 -8
  190. package/dist/graph-facts/reach.d.ts.map +1 -1
  191. package/dist/graph-facts/reach.js +172 -16
  192. package/dist/graph-facts/reach.js.map +1 -1
  193. package/dist/graph-facts/removal-reach.d.ts +2 -0
  194. package/dist/graph-facts/removal-reach.d.ts.map +1 -1
  195. package/dist/graph-facts/removal-reach.js +1 -1
  196. package/dist/graph-facts/removal-reach.js.map +1 -1
  197. package/dist/index.d.ts +15 -7
  198. package/dist/index.d.ts.map +1 -1
  199. package/dist/index.js +19 -4
  200. package/dist/index.js.map +1 -1
  201. package/dist/navigation/index.d.ts +1 -0
  202. package/dist/navigation/index.d.ts.map +1 -1
  203. package/dist/navigation/index.js +1 -0
  204. package/dist/navigation/index.js.map +1 -1
  205. package/dist/navigation/java-graph.d.ts +47 -2
  206. package/dist/navigation/java-graph.d.ts.map +1 -1
  207. package/dist/navigation/java-graph.js +395 -18
  208. package/dist/navigation/java-graph.js.map +1 -1
  209. package/dist/navigation/java-registrations.d.ts +93 -0
  210. package/dist/navigation/java-registrations.d.ts.map +1 -0
  211. package/dist/navigation/java-registrations.js +254 -0
  212. package/dist/navigation/java-registrations.js.map +1 -0
  213. package/dist/navigation/navigation-index.d.ts +74 -3
  214. package/dist/navigation/navigation-index.d.ts.map +1 -1
  215. package/dist/navigation/navigation-index.js +206 -11
  216. package/dist/navigation/navigation-index.js.map +1 -1
  217. package/dist/navigation/ts-call-edges.d.ts +15 -0
  218. package/dist/navigation/ts-call-edges.d.ts.map +1 -1
  219. package/dist/navigation/ts-call-edges.js.map +1 -1
  220. package/dist/navigation/ts-entry-tables.d.ts +1 -1
  221. package/dist/navigation/ts-entry-tables.d.ts.map +1 -1
  222. package/dist/navigation/ts-entry-tables.js.map +1 -1
  223. package/dist/navigation/xml-scan.d.ts +40 -0
  224. package/dist/navigation/xml-scan.d.ts.map +1 -0
  225. package/dist/navigation/xml-scan.js +269 -0
  226. package/dist/navigation/xml-scan.js.map +1 -0
  227. package/dist/resolution/cross-file.d.ts +44 -0
  228. package/dist/resolution/cross-file.d.ts.map +1 -1
  229. package/dist/resolution/cross-file.js +259 -13
  230. package/dist/resolution/cross-file.js.map +1 -1
  231. package/dist/stable-ids/files.d.ts +22 -0
  232. package/dist/stable-ids/files.d.ts.map +1 -0
  233. package/dist/stable-ids/files.js +28 -0
  234. package/dist/stable-ids/files.js.map +1 -0
  235. package/dist/stable-ids/hash.d.ts +16 -4
  236. package/dist/stable-ids/hash.d.ts.map +1 -1
  237. package/dist/stable-ids/hash.js +266 -80
  238. package/dist/stable-ids/hash.js.map +1 -1
  239. package/dist/stable-ids/index.d.ts +6 -5
  240. package/dist/stable-ids/index.d.ts.map +1 -1
  241. package/dist/stable-ids/index.js +19 -6
  242. package/dist/stable-ids/index.js.map +1 -1
  243. package/dist/stable-ids/nodes.d.ts +61 -7
  244. package/dist/stable-ids/nodes.d.ts.map +1 -1
  245. package/dist/stable-ids/nodes.js +134 -21
  246. package/dist/stable-ids/nodes.js.map +1 -1
  247. package/dist/stable-ids/ts-parse-errors.d.ts +5 -1
  248. package/dist/stable-ids/ts-parse-errors.d.ts.map +1 -1
  249. package/dist/stable-ids/ts-parse-errors.js +55 -3
  250. package/dist/stable-ids/ts-parse-errors.js.map +1 -1
  251. package/dist/stable-ids/typescript.d.ts +5 -0
  252. package/dist/stable-ids/typescript.d.ts.map +1 -1
  253. package/dist/stable-ids/typescript.js +41 -8
  254. package/dist/stable-ids/typescript.js.map +1 -1
  255. package/dist/types/index.d.ts +21 -3
  256. package/dist/types/index.d.ts.map +1 -1
  257. package/dist/types/index.js +1 -0
  258. package/dist/types/index.js.map +1 -1
  259. package/docs/SPEC.md +9 -0
  260. package/package.json +9 -5
  261. package/schemas/facts@1.json +134 -0
  262. package/schemas/facts@2.json +216 -0
@@ -101,20 +101,32 @@ export function parseNpmDependencies(packageJson) {
101
101
  * Parse a single PEP 508 requirement string (`name[extras] (>=|==|~=…)ver ; marker`)
102
102
  * into `{ name, version }`, or `null` when no name can be read. Shared by the
103
103
  * `requirements.txt` and `pyproject.toml` parsers.
104
+ *
105
+ * The version is the declared spec verbatim (whitespace removed), as for npm
106
+ * and Poetry: `>=2.0` stays `>=2.0`, `>=2.28,<3` stays `>=2.28,<3`. Only one
107
+ * exact pin (`==2.0` or `===2.0`, no wildcard) becomes the bare version
108
+ * `2.0`. So a lower bound is never taken for the installed version (#1127).
104
109
  */
105
110
  function parsePep508(spec) {
106
111
  let s = spec.trim();
107
- s = s.split(';')[0].trim(); // strip environment marker
112
+ // The requirement ends at an environment marker (`;`), or at whitespace
113
+ // followed by pip's line continuation (`\`), a per-requirement option
114
+ // (`--hash=…`, `--global-option=…`) or a comment (`#`). This runs before
115
+ // whitespace is removed below, so `a==1.0 \` and `a==1.0 --hash=…` read as
116
+ // `1.0` (#1131 review). A `\` at the very end is a continuation too.
117
+ s = s.split(/;|\s+(?:\\|-{1,2}[A-Za-z]|#)/)[0].replace(/\\$/, '').trim();
108
118
  if (!s)
109
119
  return null;
110
120
  const m = s.match(/^([A-Za-z0-9._-]+)\s*(?:\[[^\]]*\])?\s*(.*)$/);
111
121
  if (!m)
112
122
  return null;
113
- const rest = m[2].trim();
114
- // First comparator clause's version (drop `,` compound ranges and `(` groups).
115
- const verMatch = rest.replace(/^\(/, '').match(/^(?:==|>=|<=|~=|!=|>|<|===)?\s*([^,\s)]+)/);
116
- const version = verMatch && verMatch[1] ? verMatch[1] : 'unknown';
117
- return { name: m[1], version };
123
+ // `name (>=1.0)` is the older parenthesised form of `name>=1.0`.
124
+ const rest = m[2].trim().replace(/^\((.*)\)$/, '$1').replace(/\s+/g, '');
125
+ // No spec, or a direct reference (`name @ https://…`): no version.
126
+ if (!rest || rest.startsWith('@'))
127
+ return { name: m[1], version: 'unknown' };
128
+ const pin = rest.match(/^={2,3}([^,*=<>~]+)$/);
129
+ return { name: m[1], version: pin ? pin[1] : rest };
118
130
  }
119
131
  /**
120
132
  * Parse an npm `package-lock.json` (or `npm-shrinkwrap.json`). Unlike
@@ -300,6 +312,37 @@ function importerVersion(entry) {
300
312
  function asRecord(v) {
301
313
  return v && typeof v === 'object' && !Array.isArray(v) ? v : undefined;
302
314
  }
315
+ /** The package graph of a parsed `pnpm-lock.yaml`, keyed `name@version` (peer variants collapsed). */
316
+ function pnpmLockNodes(root) {
317
+ const nodes = new Map();
318
+ const addNode = (rawKey, info) => {
319
+ const id = parsePnpmKey(rawKey);
320
+ if (!id)
321
+ return;
322
+ const key = `${id.name}@${id.version}`;
323
+ const node = nodes.get(key) ?? { name: id.name, version: id.version, deps: [] };
324
+ if (info) {
325
+ for (const section of ['dependencies', 'optionalDependencies']) {
326
+ for (const [n, ref] of Object.entries(asRecord(info[section]) ?? {})) {
327
+ const k = pnpmRef(n, ref);
328
+ if (k && !node.deps.includes(k))
329
+ node.deps.push(k);
330
+ }
331
+ }
332
+ if (info.dev === true)
333
+ node.flagDev = true;
334
+ if (info.optional === true)
335
+ node.flagOptional = true;
336
+ }
337
+ nodes.set(key, node);
338
+ };
339
+ for (const [k, v] of Object.entries(asRecord(root.packages) ?? {}))
340
+ addNode(k, asRecord(v));
341
+ // v9 keeps the graph in `snapshots`, identities in `packages`.
342
+ for (const [k, v] of Object.entries(asRecord(root.snapshots) ?? {}))
343
+ addNode(k, asRecord(v));
344
+ return nodes;
345
+ }
303
346
  /**
304
347
  * Parse a `pnpm-lock.yaml` (lockfile formats 5.x, 6.0 and 9.0) into exact
305
348
  * resolved npm dependencies, direct and transitive.
@@ -329,33 +372,7 @@ export function parsePnpmLockDependencies(pnpmLock) {
329
372
  }
330
373
  if (!root)
331
374
  return [];
332
- const nodes = new Map();
333
- const addNode = (rawKey, info) => {
334
- const id = parsePnpmKey(rawKey);
335
- if (!id)
336
- return;
337
- const key = `${id.name}@${id.version}`;
338
- const node = nodes.get(key) ?? { name: id.name, version: id.version, deps: [] };
339
- if (info) {
340
- for (const section of ['dependencies', 'optionalDependencies']) {
341
- for (const [n, ref] of Object.entries(asRecord(info[section]) ?? {})) {
342
- const k = pnpmRef(n, ref);
343
- if (k && !node.deps.includes(k))
344
- node.deps.push(k);
345
- }
346
- }
347
- if (info.dev === true)
348
- node.flagDev = true;
349
- if (info.optional === true)
350
- node.flagOptional = true;
351
- }
352
- nodes.set(key, node);
353
- };
354
- for (const [k, v] of Object.entries(asRecord(root.packages) ?? {}))
355
- addNode(k, asRecord(v));
356
- // v9 keeps the graph in `snapshots`, identities in `packages`.
357
- for (const [k, v] of Object.entries(asRecord(root.snapshots) ?? {}))
358
- addNode(k, asRecord(v));
375
+ const nodes = pnpmLockNodes(root);
359
376
  const roots = { required: [], optional: [], dev: [] };
360
377
  const importers = asRecord(root.importers);
361
378
  const projects = importers
@@ -397,6 +414,149 @@ export function pnpmLockImporters(pnpmLock) {
397
414
  const importers = asRecord(root.importers);
398
415
  return importers ? Object.keys(importers).sort() : ['.'];
399
416
  }
417
+ /** Resolve `rel` against importer `base` (both `/`-separated, `.` = lockfile directory). */
418
+ function joinImporterPath(base, rel) {
419
+ const out = [];
420
+ for (const seg of [...base.split('/'), ...rel.split('/')]) {
421
+ if (seg === '' || seg === '.')
422
+ continue;
423
+ if (seg === '..') {
424
+ if (out.length === 0)
425
+ return '';
426
+ out.pop();
427
+ }
428
+ else
429
+ out.push(seg);
430
+ }
431
+ return out.length === 0 ? '.' : out.join('/');
432
+ }
433
+ const SCOPE_RANK = { required: 0, optional: 1, dev: 2 };
434
+ const weaker = (a, b) => (SCOPE_RANK[a] >= SCOPE_RANK[b] ? a : b);
435
+ /**
436
+ * Parse a `pnpm-lock.yaml` (5.x / 6.0 / 9.0) into one dependency set per
437
+ * importer: what each workspace project reaches on its own, so an advisory
438
+ * match can name the projects it affects (`matchAdvisories` per set).
439
+ *
440
+ * Unlike `parsePnpmLockDependencies`, which merges every importer, a package
441
+ * appears in an importer's set only if that importer reaches it — through its
442
+ * own declarations or through a linked workspace package's production and
443
+ * optional dependencies (a linked package's `devDependencies` are not
444
+ * installed for its consumers). A single-project lockfile yields one set for
445
+ * `.`. Importers are in path order; malformed YAML yields `[]`.
446
+ */
447
+ export function parsePnpmLockImporterDependencies(pnpmLock) {
448
+ if (!pnpmLock)
449
+ return [];
450
+ let root;
451
+ try {
452
+ root = asRecord(parseYaml(pnpmLock, { uniqueKeys: false }));
453
+ }
454
+ catch {
455
+ return [];
456
+ }
457
+ if (!root)
458
+ return [];
459
+ const nodes = pnpmLockNodes(root);
460
+ const importerMap = asRecord(root.importers);
461
+ const projects = new Map();
462
+ if (importerMap) {
463
+ for (const [k, v] of Object.entries(importerMap)) {
464
+ const rec = asRecord(v);
465
+ if (rec)
466
+ projects.set(k, rec);
467
+ }
468
+ }
469
+ else {
470
+ projects.set('.', root);
471
+ }
472
+ const SECTIONS = [
473
+ ['dependencies', 'required'],
474
+ ['optionalDependencies', 'optional'],
475
+ ['devDependencies', 'dev'],
476
+ ];
477
+ const SCOPES = ['required', 'optional', 'dev'];
478
+ const out = [];
479
+ for (const importer of [...projects.keys()].sort()) {
480
+ const buckets = [[], [], []];
481
+ const push = (it) => {
482
+ const byLen = buckets[SCOPE_RANK[it.scope]];
483
+ (byLen[it.via.length] ??= []).push(it);
484
+ };
485
+ const settled = new Map();
486
+ const declared = new Set();
487
+ push({ node: `p:${importer}`, scope: 'required', via: [] });
488
+ for (const scope of SCOPES) {
489
+ const byLen = buckets[SCOPE_RANK[scope]];
490
+ for (let len = 0; len < byLen.length; len++) {
491
+ const bucket = byLen[len];
492
+ if (!bucket)
493
+ continue;
494
+ // Items pushed into this bucket while it is read are taken in this pass.
495
+ for (let i = 0; i < bucket.length; i++) {
496
+ const { node, via } = bucket[i];
497
+ const isProject = node.startsWith('p:');
498
+ const isImporter = isProject && node.slice(2) === importer;
499
+ const key = isProject && !isImporter ? `${node}@${scope}` : node;
500
+ if (settled.has(key))
501
+ continue;
502
+ settled.set(key, { scope, via });
503
+ if (isProject) {
504
+ const dir = node.slice(2);
505
+ const project = projects.get(dir);
506
+ if (!project)
507
+ continue;
508
+ for (const [section, sectionScope] of SECTIONS) {
509
+ // A linked package's own dev dependencies are not installed for its consumers.
510
+ if (!isImporter && section === 'devDependencies')
511
+ continue;
512
+ const next = weaker(scope, sectionScope);
513
+ for (const [n, entry] of Object.entries(asRecord(project[section]) ?? {})) {
514
+ const ref = importerVersion(entry);
515
+ if (typeof ref === 'string' && ref.startsWith('link:')) {
516
+ const target = joinImporterPath(dir, ref.slice('link:'.length));
517
+ if (projects.has(target))
518
+ push({ node: `p:${target}`, scope: next, via: [...via, n] });
519
+ continue;
520
+ }
521
+ const k = pnpmRef(n, ref);
522
+ if (!k || !nodes.has(k))
523
+ continue;
524
+ if (isImporter)
525
+ declared.add(k);
526
+ push({ node: `n:${k}`, scope: next, via });
527
+ }
528
+ }
529
+ }
530
+ else {
531
+ const pkg = nodes.get(node.slice(2));
532
+ for (const k of pkg.deps) {
533
+ if (nodes.has(k))
534
+ push({ node: `n:${k}`, scope, via: [...via, pkg.name] });
535
+ }
536
+ }
537
+ }
538
+ }
539
+ }
540
+ const reached = new Map();
541
+ for (const [node, r] of settled) {
542
+ if (!node.startsWith('n:'))
543
+ continue;
544
+ const key = node.slice(2);
545
+ reached.set(key, { scope: r.scope, via: r.via, direct: declared.has(key) });
546
+ }
547
+ const deps = [];
548
+ for (const [key, r] of reached) {
549
+ const n = nodes.get(key);
550
+ const d = dep('npm', n.name, n.version, r.scope);
551
+ d.direct = r.direct;
552
+ d.via = r.direct ? [] : r.via;
553
+ deps.push(d);
554
+ }
555
+ deps.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : a.version < b.version ? -1 : a.version > b.version ? 1 : 0));
556
+ out.push({ importer, dependencies: deps });
557
+ }
558
+ return out;
559
+ }
400
560
  /** Unquote a yarn v1 token: `"@babel/core@^7.0.0"` → `@babel/core@^7.0.0`. */
401
561
  function yarnUnquote(s) {
402
562
  const t = s.trim();
@@ -566,6 +726,7 @@ export function parsePoetryLockDependencies(poetryLock) {
566
726
  /**
567
727
  * Parse a pip `requirements.txt`. Handles `name==1.2`, `name>=1.2`, `name~=1`,
568
728
  * bare `name`, extras (`name[x]`), and environment markers (`; marker`).
729
+ * An exact pin's version is bare (`1.2`); any other spec is kept verbatim.
569
730
  * Skips comments, blank lines, and option lines (`-r`, `-e`, `--hash`, URLs).
570
731
  */
571
732
  export function parsePypiDependencies(requirementsTxt) {
@@ -729,6 +890,79 @@ export function parseMavenDependencies(pomXml) {
729
890
  const scope = mvnScope === 'test' || mvnScope === 'provided' ? 'dev' : optional ? 'optional' : 'required';
730
891
  out.push(dep('maven', `${gid}:${aid}`, version, scope));
731
892
  }
893
+ // cognium-dev#1077 — `maven-dependency-plugin` `<artifactItem>`s (`copy` / `unpack`)
894
+ // put third-party jars into a module (e.g. an OSGi bundle's `lib/` on
895
+ // `Bundle-ClassPath`). They ship with it, so they count as `required` declarations.
896
+ // A `${property}` version is resolved from this pom's own `<properties>`; one defined
897
+ // in a parent pom is not visible here and stays `unknown`.
898
+ const props = pomProperties(pomXml);
899
+ const itemRe = /<artifactItem>([\s\S]*?)<\/artifactItem>/g;
900
+ while ((m = itemRe.exec(pomXml)) !== null) {
901
+ const block = m[1];
902
+ const gid = block.match(/<groupId>\s*([^<\s]+)\s*<\/groupId>/)?.[1];
903
+ const aid = block.match(/<artifactId>\s*([^<\s]+)\s*<\/artifactId>/)?.[1];
904
+ if (!gid || !aid)
905
+ continue;
906
+ let version = block.match(/<version>\s*([^<\s]+)\s*<\/version>/)?.[1] ?? 'unknown';
907
+ const ref = /^\$\{([^}]+)\}$/.exec(version);
908
+ if (ref)
909
+ version = props.get(ref[1]) ?? 'unknown';
910
+ else if (version.includes('${'))
911
+ version = 'unknown';
912
+ out.push(dep('maven', `${gid}:${aid}`, version, 'required'));
913
+ }
914
+ return out;
915
+ }
916
+ /** A pom's own `<properties>` (name → literal value); values that reference another property are left out. */
917
+ function pomProperties(pomXml) {
918
+ const out = new Map();
919
+ for (const block of pomXml.match(/<properties>[\s\S]*?<\/properties>/g) ?? []) {
920
+ for (const p of block.matchAll(/<([A-Za-z_][\w.-]*)>\s*([^<]*?)\s*<\/\1>/g)) {
921
+ if (p[2] && !p[2].includes('${'))
922
+ out.set(p[1], p[2]);
923
+ }
924
+ }
925
+ return out;
926
+ }
927
+ /**
928
+ * cognium-dev#1077 — Maven locations of an Eclipse PDE / Tycho target platform
929
+ * (`*.target`): `<location type="Maven">` with either the flat `groupId` / `artifactId`
930
+ * / `version` form or a `<dependencies><dependency>` list. Tycho resolves the bundles of
931
+ * an Eclipse-based build from these, so on such a project they, not pom `<dependency>`
932
+ * rows, carry the third-party versions. Comments are ignored; `required` scope.
933
+ */
934
+ export function parseTychoTargetDependencies(targetXml) {
935
+ if (!targetXml)
936
+ return [];
937
+ const text = targetXml.replace(/<!--[\s\S]*?-->/g, '').replace(/<!\[CDATA\[[\s\S]*?\]\]>/g, '');
938
+ const out = [];
939
+ const coord = (block) => {
940
+ const gid = block.match(/<groupId>\s*([^<\s]+)\s*<\/groupId>/)?.[1];
941
+ const aid = block.match(/<artifactId>\s*([^<\s]+)\s*<\/artifactId>/)?.[1];
942
+ if (!gid || !aid)
943
+ return;
944
+ let version = block.match(/<version>\s*([^<\s]+)\s*<\/version>/)?.[1] ?? 'unknown';
945
+ if (version.includes('${'))
946
+ version = 'unknown';
947
+ out.push(dep('maven', `${gid}:${aid}`, version, 'required'));
948
+ };
949
+ // A self-closing `<location … />` (e.g. `type="Target"` or `type="Directory"`) has no
950
+ // body; it must not open a block that runs on into the next location's content.
951
+ const locRe = /<location\b([^>]*?)(?:\/>|>([\s\S]*?)<\/location>)/g;
952
+ let m;
953
+ while ((m = locRe.exec(text)) !== null) {
954
+ if (m[2] === undefined)
955
+ continue;
956
+ if (!/\btype\s*=\s*["']Maven["']/i.test(m[1]))
957
+ continue;
958
+ const body = m[2];
959
+ const deps = body.match(/<dependency>[\s\S]*?<\/dependency>/g);
960
+ if (deps)
961
+ for (const d of deps)
962
+ coord(d);
963
+ else
964
+ coord(body);
965
+ }
732
966
  return out;
733
967
  }
734
968
  /**
@@ -850,6 +1084,127 @@ export function parseMavenResolvedDependencies(output) {
850
1084
  }
851
1085
  return out;
852
1086
  }
1087
+ /** A tree's root (project) line: `groupId:artifactId:packaging[:classifier]:version`, no scope. */
1088
+ const MAVEN_MODULE_ROOT = /^([\w.-]+):([\w.-]+):([\w.-]+)(?::[\w.-]+)?:([^:\s()]+)$/;
1089
+ /** The plugin header Maven prints before each module's goal: `--- …:tree (default-cli) @ module ---`. */
1090
+ const MAVEN_GOAL_HEADER = /^-{3,}\s.*?:(?:tree|list)\b.*@\s*([\w.-]+)\s+-{3,}$/;
1091
+ /**
1092
+ * Parse `mvn dependency:tree` or `dependency:list` output of a reactor build
1093
+ * (several modules in one file or console log) into one resolved set per
1094
+ * module, in the order Maven printed them. A module boundary is a tree's root
1095
+ * line, or the plugin header that names the module (`--- …:tree … @ module ---`).
1096
+ *
1097
+ * Unlike {@link parseMavenResolvedDependencies}, which merges every module into
1098
+ * one set and keeps only the first of identical entries, each module keeps its
1099
+ * own entries with its own `direct` and `via`, so a match can say which modules
1100
+ * it reaches. Output with a single module gives one entry; output with no
1101
+ * module boundary gives one entry with `module: ""`.
1102
+ */
1103
+ export function parseMavenModuleDependencies(output) {
1104
+ if (!output)
1105
+ return [];
1106
+ const segments = [];
1107
+ let current;
1108
+ let headerModule;
1109
+ for (const raw of output.split(/\r?\n/)) {
1110
+ let line = raw.replace(/^\s*\[(?:INFO|WARNING|DEBUG)\]\s?/, '').trimEnd();
1111
+ // The module suffix newer plugins print (`… -- module x`), matched literally (linear).
1112
+ const suffix = line.lastIndexOf(' -- module ');
1113
+ if (suffix >= 0 && !/\s/.test(line.slice(suffix + 11)))
1114
+ line = line.slice(0, suffix);
1115
+ const header = MAVEN_GOAL_HEADER.exec(line.trim());
1116
+ if (header) {
1117
+ headerModule = header[1];
1118
+ current = { module: headerModule, lines: [] };
1119
+ segments.push(current);
1120
+ continue;
1121
+ }
1122
+ const rootMatch = /^[\s|+\\`-]/.test(line) ? null : MAVEN_MODULE_ROOT.exec(line.trim());
1123
+ // `g:a:jar:1.0:compile` is a list entry, not a root: a root line ends in a version, never a scope.
1124
+ const root = rootMatch && !new RegExp(`^(?:${MAVEN_SCOPES})$`).test(rootMatch[4]) ? rootMatch : null;
1125
+ if (root) {
1126
+ const module = `${root[1]}:${root[2]}`;
1127
+ // A root line right after its own plugin header belongs to that segment.
1128
+ if (current && current.lines.length === 0 && current.module === headerModule && headerModule === root[2]) {
1129
+ current.module = module;
1130
+ }
1131
+ else {
1132
+ current = { module, lines: [] };
1133
+ segments.push(current);
1134
+ }
1135
+ current.version = root[4];
1136
+ current.packaging = root[3];
1137
+ headerModule = undefined;
1138
+ current.lines.push(raw);
1139
+ continue;
1140
+ }
1141
+ if (!current) {
1142
+ current = { module: '', lines: [] };
1143
+ segments.push(current);
1144
+ }
1145
+ current.lines.push(raw);
1146
+ }
1147
+ return segments
1148
+ .map(seg => ({
1149
+ module: seg.module,
1150
+ ...(seg.version !== undefined ? { version: seg.version } : {}),
1151
+ ...(seg.packaging !== undefined ? { packaging: seg.packaging } : {}),
1152
+ dependencies: parseMavenResolvedDependencies(seg.lines.join('\n')),
1153
+ }))
1154
+ .filter(m => m.module !== '' || m.dependencies.length > 0);
1155
+ }
1156
+ /**
1157
+ * Group the Gradle lockfiles of a multi-project build into one resolved set
1158
+ * per project directory. `<project>/gradle.lockfile` is the project's lockfile;
1159
+ * the older `<project>/gradle/dependency-locks/<configuration>.lockfile` files
1160
+ * are read, with the configuration from the file name, only when that project
1161
+ * has no `gradle.lockfile`. Other paths (`buildscript-gradle.lockfile`, the
1162
+ * build's own classpath, among them) are ignored. Pure: the caller reads the
1163
+ * files and passes `{ path, text }`.
1164
+ */
1165
+ export function parseGradleProjectDependencies(files) {
1166
+ const byProject = new Map();
1167
+ const at = (project) => {
1168
+ let e = byProject.get(project);
1169
+ if (!e)
1170
+ byProject.set(project, (e = { legacy: [] }));
1171
+ return e;
1172
+ };
1173
+ for (const f of files) {
1174
+ const path = f.path.replace(/\\/g, '/').replace(/^\.\//, '');
1175
+ const single = /^(?:(.*)\/)?gradle\.lockfile$/.exec(path);
1176
+ if (single) {
1177
+ at(single[1] ?? '.').single = { path, text: f.text };
1178
+ continue;
1179
+ }
1180
+ const legacy = /^(?:(.*)\/)?gradle\/dependency-locks\/([^/]+)\.lockfile$/.exec(path);
1181
+ if (legacy)
1182
+ at(legacy[1] ?? '.').legacy.push({ path, text: f.text, configuration: legacy[2] });
1183
+ }
1184
+ const out = [];
1185
+ for (const [project, e] of [...byProject].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {
1186
+ if (e.single) {
1187
+ out.push({ project, lockfiles: [e.single.path], dependencies: parseGradleLockfile(e.single.text) });
1188
+ continue;
1189
+ }
1190
+ const legacy = [...e.legacy].sort((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
1191
+ // A coordinate on several configurations is `dev` only when every one of them is a test configuration.
1192
+ const configs = new Map();
1193
+ for (const l of legacy) {
1194
+ for (const d of parseGradleLockfile(l.text, l.configuration)) {
1195
+ const key = `${d.name}|${d.version}`;
1196
+ const seen = configs.get(key);
1197
+ if (seen)
1198
+ seen.configs.push(l.configuration);
1199
+ else
1200
+ configs.set(key, { dep: d, configs: [l.configuration] });
1201
+ }
1202
+ }
1203
+ const dependencies = [...configs.values()].map(({ dep: d, configs: c }) => ({ ...d, scope: (c.every(isGradleTestConfiguration) ? 'dev' : 'required') }));
1204
+ out.push({ project, lockfiles: legacy.map(l => l.path), dependencies });
1205
+ }
1206
+ return out;
1207
+ }
853
1208
  /**
854
1209
  * Parse a Cargo `Cargo.toml`. `[dependencies]` → required,
855
1210
  * `[dev-dependencies]` → dev, `[build-dependencies]` → optional. Handles both
@@ -969,6 +1324,8 @@ export function collectDependencies(ctx) {
969
1324
  all.push(...parseMavenResolvedDependencies(ctx.java.mavenResolved));
970
1325
  else if (ctx.java?.pomXml)
971
1326
  all.push(...parseMavenDependencies(ctx.java.pomXml));
1327
+ for (const t of ctx.java?.targetPlatforms ?? [])
1328
+ all.push(...parseTychoTargetDependencies(t));
972
1329
  if (ctx.java?.gradleLockfile)
973
1330
  all.push(...parseGradleLockfile(ctx.java.gradleLockfile));
974
1331
  else if (ctx.java?.buildGradle)