Commit 08bc0a5
fix: parse multi-module Maven TGF dependency trees
`mvn dependency:tree -DoutputType=tgf` on a multi-module reactor emits one
TGF block per module (nodes, then a `#` separator, then edges), all
concatenated on stdout. depGraphFromMavenTGF used a single nodes→edges flag
that flipped to "edges" on the first `#` and never reset, so every module
after the first had its node lines dropped and its edges then referenced ids
that were never registered — failing the whole scan with
"maven tgf references unknown package".
Classify each line by shape instead — a node line ("<id> <coords>") or an
edge line ("<from> <to> <scope>") — which handles any number of concatenated
blocks. This is safe because node ids are global object hashcodes, unique
across the reactor (verified against a real 13-module reactor: zero id was
reused for a different coordinate across blocks), and node vs edge lines are
unambiguous (a node's second field is a coordinate with colons; an edge's is
a numeric id).
Adds a 3-block testdata fixture + TestMavenTGFMultiModule covering nodes,
edges, and scopes from the 2nd and 3rd blocks (fails on the old parser with
the exact "unknown package" error). Verified end to end on the Internet2
Grouper 4.x reactor: the maven detector went from total failure to resolving
137 vulnerable packages / 191 findings.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 4697fc8 commit 08bc0a5
3 files changed
Lines changed: 80 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
245 | | - | |
246 | 245 | | |
247 | 246 | | |
248 | 247 | | |
| |||
252 | 251 | | |
253 | 252 | | |
254 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
255 | 268 | | |
256 | 269 | | |
257 | 270 | | |
258 | 271 | | |
259 | 272 | | |
260 | | - | |
261 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
262 | 277 | | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
| 278 | + | |
269 | 279 | | |
270 | 280 | | |
271 | 281 | | |
| |||
276 | 286 | | |
277 | 287 | | |
278 | 288 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
284 | 292 | | |
285 | | - | |
286 | | - | |
287 | 293 | | |
288 | 294 | | |
289 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
11 | 53 | | |
12 | 54 | | |
13 | 55 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments