Skip to content

Commit

Permalink
[SECURITY-1538] Problems with method and property names and increment…
Browse files Browse the repository at this point in the history
…/decrement operators

(cherry picked from commit b28e4dc)
  • Loading branch information
dwnusbaum committed Sep 10, 2019
1 parent 7d906ff commit 915acaa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -50,7 +50,7 @@
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>groovy-sandbox</artifactId>
<version>1.22</version>
<version>1.23</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
Expand Down
Expand Up @@ -1163,4 +1163,38 @@ public void finalizer() throws Exception {
}
}

@Issue("SECURITY-1538")
@Test public void blockMethodNameInMethodCalls() throws Exception {
assertRejected(new GenericWhitelist(), "staticMethod jenkins.model.Jenkins getInstance",
"import jenkins.model.Jenkins\n" +
"1.({ Jenkins.getInstance(); 'toString' }())()");
}

@Issue("SECURITY-1538")
@Test public void blockPropertyNameInAssignment() throws Exception {
assertRejected(new GenericWhitelist(), "staticMethod jenkins.model.Jenkins getInstance",
"import jenkins.model.Jenkins\n" +
"class Test { def x = 0 }\n" +
"def t = new Test()\n" +
"t.({ Jenkins.getInstance(); 'x' }()) = 1\n");
}

@Issue("SECURITY-1538")
@Test public void blockPropertyNameInPrefixPostfixExpressions() throws Exception {
assertRejected(new GenericWhitelist(), "staticMethod jenkins.model.Jenkins getInstance",
"import jenkins.model.Jenkins\n" +
"class Test { def x = 0 }\n" +
"def t = new Test()\n" +
"t.({ Jenkins.getInstance(); 'x' }())++\n");
}

@Issue("SECURITY-1538")
@Test public void blockSubexpressionsInPrefixPostfixExpressions() throws Exception {
assertRejected(new GenericWhitelist(), "staticMethod jenkins.model.Jenkins getInstance",
"import jenkins.model.Jenkins\n" +
"++({ Jenkins.getInstance(); 1 }())\n");
assertRejected(new GenericWhitelist(), "staticMethod jenkins.model.Jenkins getInstance",
"import jenkins.model.Jenkins\n" +
"({ Jenkins.getInstance(); 1 }())++\n");
}
}

0 comments on commit 915acaa

Please sign in to comment.