From 60195a2c1b76fd0e2599d31f40ff531bb5bb07c7 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Mon, 4 Nov 2024 16:53:51 +0100 Subject: [PATCH] Adjust for script security 246c6351e5db updates the bom which updates script security plugin from 1366 to 1367 and it can now throw a FormException. --- .../plugins/postbuildscript/service/GroovyScriptExecutor.java | 4 +++- .../postbuildscript/service/GroovyScriptExecutorFactory.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/postbuildscript/service/GroovyScriptExecutor.java b/src/main/java/org/jenkinsci/plugins/postbuildscript/service/GroovyScriptExecutor.java index 4ae82b4..dedc2b7 100644 --- a/src/main/java/org/jenkinsci/plugins/postbuildscript/service/GroovyScriptExecutor.java +++ b/src/main/java/org/jenkinsci/plugins/postbuildscript/service/GroovyScriptExecutor.java @@ -5,6 +5,8 @@ import hudson.FilePath; import hudson.Util; import hudson.model.AbstractBuild; +import hudson.model.Descriptor.FormException; + import java.io.File; import java.util.ArrayList; import java.util.List; @@ -20,7 +22,7 @@ public class GroovyScriptExecutor { private final Logger log; private final SecureGroovyScript secureGroovyScript; - public GroovyScriptExecutor(Script script, List arguments, AbstractBuild build, Logger log) { + public GroovyScriptExecutor(Script script, List arguments, AbstractBuild build, Logger log) throws FormException { this.arguments = new ArrayList<>(arguments); this.build = build; this.log = log; diff --git a/src/main/java/org/jenkinsci/plugins/postbuildscript/service/GroovyScriptExecutorFactory.java b/src/main/java/org/jenkinsci/plugins/postbuildscript/service/GroovyScriptExecutorFactory.java index 4a1db2a..52cdd35 100644 --- a/src/main/java/org/jenkinsci/plugins/postbuildscript/service/GroovyScriptExecutorFactory.java +++ b/src/main/java/org/jenkinsci/plugins/postbuildscript/service/GroovyScriptExecutorFactory.java @@ -1,6 +1,8 @@ package org.jenkinsci.plugins.postbuildscript.service; import hudson.model.AbstractBuild; +import hudson.model.Descriptor.FormException; + import java.util.List; import org.jenkinsci.plugins.postbuildscript.logging.Logger; import org.jenkinsci.plugins.postbuildscript.model.Script; @@ -16,7 +18,7 @@ public GroovyScriptExecutorFactory(AbstractBuild build, Logger logger) { this.logger = logger; } - public GroovyScriptExecutor create(Script script, List arguments) { + public GroovyScriptExecutor create(Script script, List arguments) throws FormException { return new GroovyScriptExecutor(script, arguments, build, logger); } }