Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GroovyCollections to the sandbox whitelist #7250

Merged
merged 1 commit into from Aug 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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