Skip to content

Commit

Permalink
SECURITY-3341
Browse files Browse the repository at this point in the history
  • Loading branch information
dwnusbaum authored and Kevin-CB committed Apr 16, 2024
1 parent 43db123 commit 7fc878b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</build>

<properties>
<groovy-sandbox.version>1.33</groovy-sandbox.version>
<groovy-sandbox.version>1.34</groovy-sandbox.version>
<no-test-jar>false</no-test-jar>
</properties>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,16 @@ public void assertEvaluate(Object expectedReturnValue, String script) {
// TODO: Refactor things so we can check evalCps as well.
}

public void assertIntercept(String script, Object expectedResult, String... expectedInterceptions) throws Throwable {
public void assertIntercept(String script, Object expectedResult, String... expectedCalls) throws Throwable {
assertEvaluate(expectedResult, script);
ec.checkThat(cr.toString().split("\n"), equalTo(expectedInterceptions));
String[] updatedExpectedCalls = expectedCalls;
// Insert SerializableScript constructor call automatically to avoid having to update all tests.
if (expectedCalls.length == 0 || (expectedCalls.length > 0 && !expectedCalls[0].equals("new SerializableScript()"))) {
updatedExpectedCalls = new String[expectedCalls.length + 1];
updatedExpectedCalls[0] = "new SerializableScript()";
System.arraycopy(expectedCalls, 0, updatedExpectedCalls, 1, expectedCalls.length);
}
ec.checkThat(cr.toString().split("\n"), equalTo(updatedExpectedCalls));
}

/**
Expand Down Expand Up @@ -566,7 +573,8 @@ public void nonCpsfinalizerForbidden() throws Throwable {
null,
"Script1.super(Script1).setBinding(Binding)",
"new Test()",
"System:getProperties()");
"System:getProperties()",
"new Test(Properties)");
}

@Ignore("Initial expressions for parameters in CPS-transformed closures are currently ignored")
Expand Down Expand Up @@ -636,6 +644,7 @@ public void sandboxInterceptsImplicitCastsArrayAssignment() throws Throwable {
"Script3.super(Script3).setBinding(Binding)",
"new Test()",
"new File(String)",
"new Test(File)",
"Test.x");
}

Expand Down
1 change: 1 addition & 0 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1336.vf33a_a_9863911</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
Expand Down

0 comments on commit 7fc878b

Please sign in to comment.