Skip to content

Commit b0ead48

Browse files
committed
Use GroovySourceFileAllowlist to adapt to SECURITY-359 changes
1 parent c7dedef commit b0ead48

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

pom.xml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
<properties>
3232
<revision>1.29</revision>
3333
<changelist>-SNAPSHOT</changelist>
34-
<jenkins.version>2.222.4</jenkins.version>
34+
<jenkins.version>2.332.1</jenkins.version>
3535
<java.level>8</java.level>
36-
<pipeline-model-definition-plugin.version>1.8.1</pipeline-model-definition-plugin.version>
36+
<pipeline-model-definition-plugin.version>2.2082.v70b_19a_c38c26</pipeline-model-definition-plugin.version> <!-- TODO: https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/529 -->
37+
<workflow-cps-plugin.version>2699.v7231c3b_4a_231</workflow-cps-plugin.version> <!-- TODO: https://github.com/jenkinsci/workflow-cps-plugin/pull/538 -->
3738
</properties>
3839
<repositories>
3940
<repository>
@@ -51,12 +52,17 @@
5152
<dependencies>
5253
<dependency>
5354
<groupId>io.jenkins.tools.bom</groupId>
54-
<artifactId>bom-2.222.x</artifactId>
55-
<version>887.vae9c8ac09ff7</version>
55+
<artifactId>bom-2.332.x</artifactId>
56+
<version>1382.v7d694476f340</version>
5657
<scope>import</scope>
5758
<type>pom</type>
5859
</dependency>
59-
60+
<dependency>
61+
<!-- TODO: Remove once this version is included in BOM -->
62+
<groupId>org.jenkins-ci.plugins</groupId>
63+
<artifactId>script-security</artifactId>
64+
<version>1172.v35f6a_0b_8207e</version>
65+
</dependency>
6066
</dependencies>
6167
</dependencyManagement>
6268
<dependencies>
@@ -68,6 +74,7 @@
6874
<dependency>
6975
<groupId>org.jenkins-ci.plugins.workflow</groupId>
7076
<artifactId>workflow-cps</artifactId>
77+
<version>${workflow-cps-plugin.version}</version>
7178
</dependency>
7279
<dependency>
7380
<groupId>org.jenkins-ci.plugins.workflow</groupId>
@@ -100,6 +107,7 @@
100107
<dependency>
101108
<groupId>org.jenkins-ci.plugins.workflow</groupId>
102109
<artifactId>workflow-cps</artifactId>
110+
<version>${workflow-cps-plugin.version}</version>
103111
<classifier>tests</classifier>
104112
<scope>test</scope>
105113
</dependency>

src/main/java/org/jenkinsci/plugins/docker/workflow/declarative/AbstractDockerAgent.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828

2929
import edu.umd.cs.findbugs.annotations.CheckForNull;
3030
import edu.umd.cs.findbugs.annotations.Nullable;
31+
import hudson.Extension;
3132
import org.jenkinsci.plugins.pipeline.modeldefinition.agent.DeclarativeAgent;
3233
import org.jenkinsci.plugins.pipeline.modeldefinition.options.DeclarativeOption;
34+
import org.jenkinsci.plugins.workflow.cps.GroovySourceFileAllowlist;
3335
import org.kohsuke.stapler.DataBoundSetter;
3436

3537
public abstract class AbstractDockerAgent<D extends AbstractDockerAgent<D>> extends DeclarativeAgent<D> {
@@ -123,4 +125,18 @@ public boolean reuseRootAgent(Map<String, DeclarativeOption> options) {
123125
return options.get(ContainerPerStage.SYMBOL) != null;
124126
}
125127

128+
/**
129+
* AbstractDockerPipelineScript.groovy is a superclass of the Groovy scripts for subclasses of
130+
* {@link AbstractDockerAgent}, but does not have any direct equivalent Java class, so we just allow it here.
131+
*/
132+
@Extension
133+
public static class ChangelogConditionalScriptAllowlist extends GroovySourceFileAllowlist {
134+
private final String scriptUrl = AbstractDockerAgent.class.getResource("/org/jenkinsci/plugins/docker/workflow/declarative/AbstractDockerPipelineScript.groovy").toString();
135+
136+
@Override
137+
public boolean isAllowed(String groovyResourceUrl) {
138+
return groovyResourceUrl.equals(scriptUrl);
139+
}
140+
}
141+
126142
}

0 commit comments

Comments
 (0)