From 82a94008e2c28361391107dbf3b0167a8042979f Mon Sep 17 00:00:00 2001 From: Reder9 Date: Fri, 17 Oct 2025 13:37:07 -0500 Subject: [PATCH 1/2] 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 From 73d2e36b9ee76a7502ea1fd178c36d0dc41b26a5 Mon Sep 17 00:00:00 2001 From: Reder9 Date: Fri, 17 Oct 2025 14:12:30 -0500 Subject: [PATCH 2/2] Removing job name from multibranch custom workspace path --- .../main/kotlin/com/code42/jenkins/pipelinekt/core/Pipeline.kt | 2 +- version.txt | 2 +- 2 files changed, 2 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 7ee0677..2c1f7d8 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 @@ -83,7 +83,7 @@ data class Pipeline( val innerWriter = writer.inner() 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}\"") + innerWriter.writeln("customWorkspacePath = \"./workspace//\${safeBranch}\"") writer.writeln("}") writer.writeln("") } diff --git a/version.txt b/version.txt index ebc9cc4..f302267 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.21.12 +0.21.13