From 82a94008e2c28361391107dbf3b0167a8042979f Mon Sep 17 00:00:00 2001 From: Reder9 Date: Fri, 17 Oct 2025 13:37:07 -0500 Subject: [PATCH] Removing all slashes from branch name in the custom workspaces for safer traversal --- .../main/kotlin/com/code42/jenkins/pipelinekt/core/Pipeline.kt | 3 ++- version.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/kotlin/com/code42/jenkins/pipelinekt/core/Pipeline.kt b/core/src/main/kotlin/com/code42/jenkins/pipelinekt/core/Pipeline.kt index f4507a3..7ee0677 100644 --- a/core/src/main/kotlin/com/code42/jenkins/pipelinekt/core/Pipeline.kt +++ b/core/src/main/kotlin/com/code42/jenkins/pipelinekt/core/Pipeline.kt @@ -81,7 +81,8 @@ data class Pipeline( writer.writeln("def customWorkspacePath = null") writer.writeln("if (env.BRANCH_NAME) {") val innerWriter = writer.inner() - innerWriter.writeln("def safeBranch = env.BRANCH_NAME.replaceAll(/[^A-Za-z0-9._-]/, '_')") + innerWriter.writeln("// Replace slashes and other special characters with underscores for safe filesystem paths") + innerWriter.writeln("def safeBranch = env.BRANCH_NAME.replaceAll('/', '_').replaceAll(/[^A-Za-z0-9._-]/, '_')") innerWriter.writeln("customWorkspacePath = \"./workspace//\${env.JOB_NAME}-\${safeBranch}\"") writer.writeln("}") writer.writeln("") diff --git a/version.txt b/version.txt index 4350a15..ebc9cc4 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.21.11 +0.21.12