Skip to content

GROOVY-12073: reject dot-dot segments in grape coordinate validation#2584

Merged
paulk-asert merged 1 commit into
apache:masterfrom
netliomax25-code:grape-coordinate-reject-dotdot
Jun 9, 2026
Merged

GROOVY-12073: reject dot-dot segments in grape coordinate validation#2584
paulk-asert merged 1 commit into
apache:masterfrom
netliomax25-code:grape-coordinate-reject-dotdot

Conversation

@netliomax25-code

Copy link
Copy Markdown
Contributor

createGrabRecord rejects path separators and shell metacharacters in coordinate values, but a value made only of dot segments still passes both the version blacklist and the group/module whitelist, so a version or group of '..' survives and is later interpolated into the ivy/maven cache file paths as a parent-directory hop. This adds a contains('..') guard next to the existing checks, after the backslash fix, and applies it to GrapeMaven too since it shares the same validation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens Grape coordinate validation to prevent .. path traversal via dependency coordinate components that are later used in Ivy/Maven cache path construction.

Changes:

  • Reject coordinate values containing .. in both GrapeIvy.createGrabRecord and GrapeMaven.createGrabRecord.
  • Add regression tests in GrapeIvyTest for .. in version and group.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
subprojects/groovy-grape-maven/src/main/groovy/groovy/grape/maven/GrapeMaven.groovy Adds a .. rejection check during Maven grab record validation.
subprojects/groovy-grape-ivy/src/main/groovy/groovy/grape/ivy/GrapeIvy.groovy Adds a .. rejection check during Ivy grab record validation.
subprojects/groovy-grape-ivy/src/test/groovy/groovy/grape/ivy/GrapeIvyTest.groovy Adds regression tests covering the new validation behavior for Ivy.

Comment on lines +429 to +445
@Test
void testInvalidVersionDotDot() {
def ex = shouldFail '''
groovy.grape.Grape.grab(group: 'org.ejml', module: 'ejml-simple', version: '..')
'''
assert ex.message.contains('for version')
assert ex.message.contains("should not contain '..'")
}

@Test
void testInvalidGroupDotDot() {
def ex = shouldFail '''
groovy.grape.Grape.grab(group: '..', module: 'ejml-simple', version: '0.41')
'''
assert ex.message.contains('for group')
assert ex.message.contains("should not contain '..'")
}
Comment on lines +589 to +591
if (v.toString().contains('..')) {
throw new RuntimeException("Grab: invalid value of '$v' for $k: should not contain '..'")
}
@testlens-app

This comment has been minimized.

@paulk-asert

paulk-asert commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for your on-going interest! Did you want to take a look at the Copilot suggestions?

@paulk-asert

Copy link
Copy Markdown
Contributor

I created this issue: https://issues.apache.org/jira/browse/GROOVY-12073

@netliomax25-code netliomax25-code force-pushed the grape-coordinate-reject-dotdot branch from 3168577 to 0d6e9d0 Compare June 9, 2026 11:41
@netliomax25-code

Copy link
Copy Markdown
Contributor Author

Done. Both Copilot points are covered:

  1. Added a module: '..' test to GrapeIvyTest so the check is pinned for all three coordinate keys, not just version and group.
  2. Added matching dot-dot tests (version, group, module) to GrapeMavenTest for the Maven engine. That needed a testImplementation projects.groovyTest dependency there so shouldFail resolves.

Also reworded the commit to reference GROOVY-12073. Ran both grape suites with -Djunit.network=true and the new tests pass.

@paulk-asert paulk-asert merged commit 1d465f4 into apache:master Jun 9, 2026
23 checks passed
@paulk-asert

Copy link
Copy Markdown
Contributor

Merged, thanks!

@paulk-asert paulk-asert changed the title reject dot-dot segments in grape coordinate validation GROOVY-12073: reject dot-dot segments in grape coordinate validation Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants