Deprecate Groovy, Python, and Javascript scripts.

This commit is contained in:
Jack Conradson 2016-08-30 09:06:18 -07:00
parent a132405642
commit 7930233527
7 changed files with 22 additions and 6 deletions

View File

@ -1,6 +1,8 @@
[[lang-javascript]]
=== JavaScript Language Plugin
deprecated[5.0.0,Javascript will be replaced by the new scripting language <<modules-scripting-painless, `Painless`>>]
The JavaScript language plugin enables the use of JavaScript in Elasticsearch
scripts, via Mozilla's
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Rhino[Rhino JavaScript] engine.

View File

@ -1,6 +1,8 @@
[[lang-python]]
=== Python Language Plugin
deprecated[5.0.0,Python will be replaced by the new scripting language <<modules-scripting-painless, `Painless`>>]
The Python language plugin enables the use of Python in Elasticsearch
scripts, via the http://www.jython.org/[Jython] Java implementation of Python.

View File

@ -5,12 +5,7 @@ The scripting module enables you to use scripts to evaluate custom
expressions. For example, you could use a script to return "script fields"
as part of a search request or evaluate a custom score for a query.
TIP: Elasticsearch now has a built-in scripting language called _Painless_
that provides a more secure alternative for implementing
scripts for Elasticsearch. We encourage you to try it out --
for more information, see <<modules-scripting-painless, Painless Scripting Language>>.
The default scripting language is http://groovy-lang.org/[groovy].
The default scripting language is <<modules-scripting-painless, `Painless`>>.
Additional `lang` plugins enable you to run scripts written in other languages.
Everywhere a script can be used, you can include a `lang` parameter
to specify the language of the script.

View File

@ -1,6 +1,8 @@
[[modules-scripting-groovy]]
=== Groovy Scripting Language
deprecated[5.0.0,Groovy will be replaced by the new scripting language <<modules-scripting-painless, `Painless`>>]
Groovy is the default scripting language available in Elasticsearch. Although
limited by the <<java-security-manager,Java Security Manager>>, it is not a
sandboxed language and only `file` scripts may be used by default.

View File

@ -68,6 +68,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import static java.util.Collections.emptyList;
@ -91,6 +92,11 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
*/
private final ClassLoader loader;
/**
* Ensures that the deprecation log entry for Groovy is only written on the first Groovy script compiled.
*/
private AtomicBoolean isDeprecationLogged = new AtomicBoolean(false);
public GroovyScriptEngineService(Settings settings) {
super(settings);
// Creates the classloader here in order to isolate Groovy-land code
@ -134,6 +140,10 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri
@Override
public Object compile(String scriptName, String scriptSource, Map<String, String> params) {
if (isDeprecationLogged.compareAndSet(false, true)) {
deprecationLogger.deprecated("Groovy scripts are deprecated. Use Painless scripts instead.");
}
// Create the script class name
String className = MessageDigests.toHexString(MessageDigests.sha1().digest(scriptSource.getBytes(StandardCharsets.UTF_8)));

View File

@ -25,6 +25,7 @@ import org.elasticsearch.SpecialPermission;
import org.elasticsearch.bootstrap.BootstrapInfo;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.script.ClassPermission;
import org.elasticsearch.script.CompiledScript;
@ -138,6 +139,8 @@ public class JavaScriptScriptEngineService extends AbstractComponent implements
public JavaScriptScriptEngineService(Settings settings) {
super(settings);
deprecationLogger.deprecated("Javascript scripts are deprecated. Use Painless scripts instead.");
Context ctx = Context.enter();
try {
globalScope = ctx.initStandardObjects(null, true);

View File

@ -62,6 +62,8 @@ public class PythonScriptEngineService extends AbstractComponent implements Scri
public PythonScriptEngineService(Settings settings) {
super(settings);
deprecationLogger.deprecated("Python scripts are deprecated. Use Painless scripts instead.");
// classloader created here
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {