From a37cc7232976ba34e64e4fb26b0f3a13361055c3 Mon Sep 17 00:00:00 2001 From: Daniel Mitterdorfer Date: Fri, 13 May 2016 14:26:14 +0200 Subject: [PATCH 1/6] Exclude specific transport actions from request size limit check Relates elastic/elasticsearchelastic/elasticsearch#17951 Original commit: elastic/x-pack-elasticsearch@07d216564347a6981fedb3f2b2fdbfc5927734e1 --- .../shield/transport/ShieldServerTransportService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java index 33a7ae27cb1..8f5baa4ae33 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java @@ -107,11 +107,11 @@ public class ShieldServerTransportService extends TransportService { @Override public void registerRequestHandler(String action, Supplier request, String executor, - boolean forceExecution, + boolean forceExecution, boolean canTripCircuitBreaker, TransportRequestHandler handler) { TransportRequestHandler wrappedHandler = new ProfileSecuredRequestHandler<>(action, handler, profileFilters, licenseState, threadPool.getThreadContext()); - super.registerRequestHandler(action, request, executor, forceExecution, wrappedHandler); + super.registerRequestHandler(action, request, executor, forceExecution, canTripCircuitBreaker, wrappedHandler); } protected Map initializeProfileFilters() { From 6e70856cf54a9b9e40a8c579b4c8f487f5609659 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Mon, 9 May 2016 15:49:52 -0600 Subject: [PATCH 2/6] Fix Watcher tests for 'sandbox' option removal Relates to https://github.com/elastic/elasticsearch/pull/18226 Original commit: elastic/x-pack-elasticsearch@b30d623dfbd542333b95302419a752d80d66b50e --- .../java/org/elasticsearch/script/SleepScriptEngine.java | 5 ----- .../watcher/test/AbstractWatcherIntegrationTestCase.java | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java index 2a1cfcdd893..e8764f2ec98 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java @@ -54,11 +54,6 @@ public class SleepScriptEngine implements ScriptEngineService { return TYPES; } - @Override - public boolean isSandboxed() { - return true; - } - @Override public Object compile(String script, Map params) { return script; diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java index 7ce32199a56..86a16d50abf 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/AbstractWatcherIntegrationTestCase.java @@ -136,6 +136,7 @@ public abstract class AbstractWatcherIntegrationTestCase extends ESIntegTestCase .put("xpack.watcher.watch.scroll.size", randomIntBetween(1, 100)) .put(ShieldSettings.settings(shieldEnabled)) .put("xpack.watcher.trigger.schedule.engine", scheduleImplName) + .put("script.inline", "true") .build(); } From fd6cf7d3d3d021e4a5dd3df8a250f1367660bbe8 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Tue, 10 May 2016 12:10:12 -0600 Subject: [PATCH 3/6] Register engines with a default of `ScriptMode.ON` Original commit: elastic/x-pack-elasticsearch@d367b4028e0f5a30b5158740b62a6a21c365ec13 --- .../org/elasticsearch/script/MockMustacheScriptEngine.java | 3 ++- .../test/java/org/elasticsearch/script/SleepScriptEngine.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java index c0d1c7bce39..17db57da230 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.script; +import org.elasticsearch.script.ScriptMode; import org.elasticsearch.xpack.common.text.DefaultTextTemplateEngine; import java.util.Collections; @@ -29,7 +30,7 @@ public class MockMustacheScriptEngine extends MockScriptEngine { public void onModule(ScriptModule module) { module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(MockMustacheScriptEngine.class, - Collections.singletonList(NAME))); + Collections.singletonList(NAME), ScriptMode.ON)); } } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java index e8764f2ec98..dadaee3024d 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java @@ -7,6 +7,7 @@ package org.elasticsearch.script; import org.elasticsearch.common.Nullable; import org.elasticsearch.plugins.Plugin; +import org.elasticsearch.script.ScriptMode; import org.elasticsearch.search.lookup.SearchLookup; import java.io.IOException; @@ -39,7 +40,7 @@ public class SleepScriptEngine implements ScriptEngineService { } public void onModule(ScriptModule module) { - module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(SleepScriptEngine.class, SleepScriptEngine.TYPES)); + module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(SleepScriptEngine.class, SleepScriptEngine.TYPES, ScriptMode.ON)); } } From 91f2e94ac7b4598b7975b9c699c4eb4f24550ff8 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 11 May 2016 10:12:55 -0600 Subject: [PATCH 4/6] Fix scripting engines for singular type Original commit: elastic/x-pack-elasticsearch@ed014cefc31fc8980fc6b67e10d7b60392414b0d --- .../org/elasticsearch/messy/tests/MessyTestUtils.java | 2 +- .../org/elasticsearch/smoketest/WatcherTemplateTests.java | 2 +- .../elasticsearch/script/MockMustacheScriptEngine.java | 8 ++++---- .../java/org/elasticsearch/script/SleepScriptEngine.java | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java index 05330ac5ad0..c4bbc2186b9 100644 --- a/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java +++ b/elasticsearch/qa/messy-test-watcher-with-groovy/src/test/java/org/elasticsearch/messy/tests/MessyTestUtils.java @@ -42,7 +42,7 @@ public final class MessyTestUtils { engineServiceSet.add(groovyScriptEngineService); ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry( Arrays.asList( - new ScriptEngineRegistry.ScriptEngineRegistration(GroovyScriptEngineService.class, GroovyScriptEngineService.TYPES) + new ScriptEngineRegistry.ScriptEngineRegistration(GroovyScriptEngineService.class, GroovyScriptEngineService.NAME) ) ); ScriptContextRegistry scriptContextRegistry = new ScriptContextRegistry(Arrays.asList(ScriptServiceProxy.INSTANCE)); diff --git a/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java b/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java index 8665dd318a3..efe00900d07 100644 --- a/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java +++ b/elasticsearch/qa/smoke-test-watcher-with-mustache/src/test/java/org/elasticsearch/smoketest/WatcherTemplateTests.java @@ -56,7 +56,7 @@ public class WatcherTemplateTests extends ESTestCase { ScriptEngineRegistry scriptEngineRegistry = new ScriptEngineRegistry( Arrays.asList( new ScriptEngineRegistry.ScriptEngineRegistration(MustacheScriptEngineService.class, - MustacheScriptEngineService.TYPES) + MustacheScriptEngineService.NAME) ) ); ScriptSettings scriptSettings = new ScriptSettings(scriptEngineRegistry, registry); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java index 17db57da230..a1fd6ca0fa2 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java @@ -30,19 +30,19 @@ public class MockMustacheScriptEngine extends MockScriptEngine { public void onModule(ScriptModule module) { module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(MockMustacheScriptEngine.class, - Collections.singletonList(NAME), ScriptMode.ON)); + NAME, ScriptMode.ON)); } } @Override - public List getTypes() { - return Collections.singletonList(NAME); + public String getType() { + return NAME; } @Override public List getExtensions() { - return getTypes(); + return Collections.singletonList(NAME); } @Override diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java index dadaee3024d..c79ebec978a 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java @@ -40,14 +40,15 @@ public class SleepScriptEngine implements ScriptEngineService { } public void onModule(ScriptModule module) { - module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(SleepScriptEngine.class, SleepScriptEngine.TYPES, ScriptMode.ON)); + module.addScriptEngine(new ScriptEngineRegistry.ScriptEngineRegistration(SleepScriptEngine.class, + SleepScriptEngine.NAME, ScriptMode.ON)); } } @Override - public List getTypes() { - return TYPES; + public String getType() { + return NAME; } @Override From 2f43179ddae5029324aaa7514ad0b3bc46baa21c Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 13 May 2016 10:29:35 -0600 Subject: [PATCH 5/6] Fix compilation for only one script language extension Relates to https://github.com/elastic/elasticsearch/pull/18332 Original commit: elastic/x-pack-elasticsearch@32f0bd6c4fdfc65227827c92faf3ae9dc450a9e8 --- .../org/elasticsearch/script/MockMustacheScriptEngine.java | 4 ++-- .../java/org/elasticsearch/script/SleepScriptEngine.java | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java index a1fd6ca0fa2..0ffebd20223 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java @@ -41,8 +41,8 @@ public class MockMustacheScriptEngine extends MockScriptEngine { } @Override - public List getExtensions() { - return Collections.singletonList(NAME); + public String getExtension() { + return NAME; } @Override diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java index c79ebec978a..54e5512e551 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java @@ -22,8 +22,6 @@ public class SleepScriptEngine implements ScriptEngineService { public static final String NAME = "sleep"; - public static final List TYPES = Collections.singletonList(NAME); - public static class TestPlugin extends Plugin { public TestPlugin() { @@ -52,8 +50,8 @@ public class SleepScriptEngine implements ScriptEngineService { } @Override - public List getExtensions() { - return TYPES; + public String getExtension() { + return NAME; } @Override From 91426062c18572f851acbbab5d6d4de227c36018 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 13 May 2016 15:42:23 -0400 Subject: [PATCH 6/6] update mock script engines to take name parameter Original commit: elastic/x-pack-elasticsearch@c6c48eca3901fee6f64716ea68548a0d27bfd645 --- .../org/elasticsearch/script/MockMustacheScriptEngine.java | 5 ++--- .../java/org/elasticsearch/script/SleepScriptEngine.java | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java index 0ffebd20223..bd9cb51019d 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/MockMustacheScriptEngine.java @@ -46,12 +46,11 @@ public class MockMustacheScriptEngine extends MockScriptEngine { } @Override - public Object compile(String script, Map params) { + public Object compile(String name, String script, Map params) { if (script.contains("{{") && script.contains("}}")) { throw new IllegalArgumentException("Fix your test to not rely on mustache"); } - return script; + return super.compile(name, script, params); } - } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java index 54e5512e551..fe34b142ad3 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java @@ -55,8 +55,8 @@ public class SleepScriptEngine implements ScriptEngineService { } @Override - public Object compile(String script, Map params) { - return script; + public Object compile(String scriptName, String scriptSource, Map params) { + return scriptSource; } @Override