Commit 46ad688
Preserve old exclusions and add sibling for new coordinates on dependency change (#6800)
* Add failing test for incorrect exclusion renaming
When ChangeDependencyGroupIdAndArtifactId renames commons-lang:commons-lang
to org.apache.commons:commons-lang3, it also incorrectly renames exclusions
for commons-lang:commons-lang in other dependencies. The exclusion should
remain unchanged because it blocks the old vulnerable transitive dependency.
* Do not auto-update exclusions when changing dependency coordinates
ChangeDependencyGroupIdAndArtifactId previously called ChangeExclusion to
rename all exclusions matching the old coordinates to the new ones. This is
incorrect because exclusions exist to block OLD transitive dependencies that
other libraries may still pull in. Changing the exclusion from the old to the
new coordinates means the old vulnerable artifact is no longer blocked.
A stale exclusion (excluding something no longer pulled in transitively) is
harmless, but an incorrect exclusion (no longer blocking a vulnerable
transitive dependency) causes real problems.
* Add sibling exclusion for new coordinates instead of replacing old ones
ChangeDependencyGroupIdAndArtifactId previously called ChangeExclusion to
rename exclusions matching the old coordinates to the new ones. This was
incorrect because the old exclusion exists to block the OLD vulnerable
transitive dependency that other libraries may still pull in.
Now, when changing dependency coordinates, existing exclusions for the old
coordinates are preserved and a sibling exclusion for the new coordinates
is added alongside them. This ensures both old and new transitive
dependencies are excluded.
* Use exclusion-scoped patterns in test assertions
Tighten pattern assertions to match within <exclusion> tags so they
don't accidentally match on direct dependency coordinates.
* Return early without checking second condition
---------
Co-authored-by: Tim te Beek <tim@moderne.io>1 parent 1a877b6 commit 46ad688
2 files changed
Lines changed: 97 additions & 9 deletions
File tree
- rewrite-maven/src
- main/java/org/openrewrite/maven
- test/java/org/openrewrite/maven
Lines changed: 32 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
274 | 274 | | |
275 | | - | |
276 | | - | |
277 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
278 | 305 | | |
279 | 306 | | |
280 | 307 | | |
| |||
Lines changed: 65 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3489 | 3489 | | |
3490 | 3490 | | |
3491 | 3491 | | |
3492 | | - | |
3493 | | - | |
3494 | | - | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
3495 | 3496 | | |
3496 | 3497 | | |
3497 | 3498 | | |
3498 | 3499 | | |
3499 | 3500 | | |
3500 | 3501 | | |
3501 | | - | |
| 3502 | + | |
3502 | 3503 | | |
3503 | 3504 | | |
3504 | 3505 | | |
| |||
3530 | 3531 | | |
3531 | 3532 | | |
3532 | 3533 | | |
| 3534 | + | |
| 3535 | + | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + | |
3533 | 3539 | | |
3534 | 3540 | | |
3535 | 3541 | | |
3536 | 3542 | | |
3537 | 3543 | | |
3538 | 3544 | | |
3539 | 3545 | | |
| 3546 | + | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
3540 | 3601 | | |
3541 | 3602 | | |
3542 | 3603 | | |
| |||
0 commit comments