Skip to content

Commit

Permalink
Add GroovyCollections to the sandbox whitelist
Browse files Browse the repository at this point in the history
Also clarify in the docs that changing the whitelist/blacklist settings
replace the list, they don't add to it.

Fixes #7089
Fixes #7088
  • Loading branch information
dakrone authored and areek committed Sep 8, 2014
1 parent 73b1ead commit 205179c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/reference/modules/scripting.asciidoc
Expand Up @@ -233,6 +233,9 @@ that can be used for configuring this sandbox:
Flag to disable the sandbox (defaults to `true` meaning the sandbox is
enabled).

When specifying whitelist or blacklist settings for the groovy sandbox, all
options replace the current whitelist, they are not additive.

[float]
=== Automatic Script Reloading

Expand Down
Expand Up @@ -88,6 +88,7 @@ public GroovySandboxExpressionChecker(Settings settings) {

// Default whitelisted receiver classes for the Groovy sandbox
private final static String[] defaultReceiverWhitelist = new String [] {
groovy.util.GroovyCollections.class.getName(),
java.lang.Math.class.getName(),
java.lang.Integer.class.getName(), "[I", "[[I", "[[[I",
java.lang.Float.class.getName(), "[F", "[[F", "[[[F",
Expand Down
Expand Up @@ -47,6 +47,8 @@ public void testSandboxedGroovyScript() {
testSuccess("def v = doc['foo'].value; def m = [:]; m.put(\\\"value\\\", v)");
// Times
testSuccess("def t = Instant.now().getMillis()");
// GroovyCollections
testSuccess("def n = [1,2,3]; GroovyCollections.max(n)");

// Fail cases
testFailure("pr = Runtime.getRuntime().exec(\\\"touch /tmp/gotcha\\\"); pr.waitFor()",
Expand Down

0 comments on commit 205179c

Please sign in to comment.