Skip to content

Commit cfef3bf

Browse files
committed
MLE-30244 refine the changes as the copilot reviews
1 parent dd25628 commit cfef3bf

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

Jenkinsfile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,10 @@ pipeline {
187187
}
188188
}
189189
steps {
190-
withCredentials([usernamePassword(
191-
credentialsId: 'MLBUILD_USER',
192-
usernameVariable: 'DMC_USER',
193-
passwordVariable: 'DMC_PASSWORD'
194-
)]) {
190+
withCredentials([
191+
string(credentialsId: 'MLBUILD_USER', variable: 'DMC_USER'),
192+
string(credentialsId: 'MLBUILD_PASSWORD', variable: 'DMC_PASSWORD')
193+
]) {
195194
sh label: 'publish', script: '''#!/bin/bash
196195
export JAVA_HOME=$JAVA_HOME_DIR
197196
export GRADLE_USER_HOME=$WORKSPACE/$GRADLE_DIR
@@ -230,11 +229,14 @@ pipeline {
230229

231230
steps {
232231
script {
233-
// Validate MARKLOGIC_IMAGE_TAGS to prevent argument injection via user-supplied image tag values
234-
if (!(params.MARKLOGIC_IMAGE_TAGS ==~ /^[a-zA-Z0-9\-.:,\/ ]+$/)) {
235-
error("Invalid MARKLOGIC_IMAGE_TAGS parameter value: must match ^[a-zA-Z0-9\\-.:,\\/ ]+\$")
232+
// Validate MARKLOGIC_IMAGE_TAGS to prevent argument injection via user-supplied image tag values;
233+
// each entry is validated individually after trimming to reject empty values and tags
234+
// containing spaces or other shell-injectable characters
235+
def imageTags = params.MARKLOGIC_IMAGE_TAGS.split(',').collect { it.trim() }
236+
def invalidTags = imageTags.findAll { it.isEmpty() || !(it ==~ /^[A-Za-z0-9][A-Za-z0-9._-]*(\\/[A-Za-z0-9._-]*)*(?::[A-Za-z0-9._-]{0,127})?$/) }
237+
if (!invalidTags.isEmpty()) {
238+
error("Invalid MARKLOGIC_IMAGE_TAGS entries: ${invalidTags}. Expected comma-delimited docker image refs like 'marklogic-server-ubi:latest-12'")
236239
}
237-
def imageTags = params.MARKLOGIC_IMAGE_TAGS.split(',')
238240
def imagePrefix = 'ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/'
239241

240242
imageTags.each { tag ->

0 commit comments

Comments
 (0)