Skip to content

reject dot-dot segments in grape coordinate validation#2584

Open
netliomax25-code wants to merge 1 commit into
apache:masterfrom
netliomax25-code:grape-coordinate-reject-dotdot
Open

reject dot-dot segments in grape coordinate validation#2584
netliomax25-code wants to merge 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
Copy link
Copy Markdown

testlens-app Bot commented Jun 3, 2026

✅ All tests passed ✅

🏷️ Commit: 3168577
▶️ Tests: 50186 executed
⚪️ Checks: 22/22 completed


Learn more about TestLens at testlens.app.

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.

2 participants