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
  • Loading branch information
dwnusbaum committed Sep 10, 2019
1 parent 1c98e6b commit b28e4dc
Show file tree
Hide file tree
Showing 2 changed files with 36 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 @@ -1226,4 +1226,39 @@ public void scriptInitializersClassSyntax() throws Exception {
" def run() { MyScript.foo }\n" +
"}\n");
}

@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 b28e4dc

Please sign in to comment.