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
Create a new scripting language #13084
Comments
w00t |
w00t indeed |
this is super important aspect. beyond the basic native operations in the lang, the only other functions that will be available are those that we pre-register with the language (register in code that is). So this mechanism needs to be generic and not hard coded for the math/geo functions. |
Haven't commented on here in a while, so I thought I would give a quick update. The majority of the features are implemented as a first pass in a separate project. What needs to happen before a PR can really be made at this point --
This timeline may be a bit ambitious (again), but I'll update in another couple weeks. |
Awesome
Well that's going to push the delivery date out to 2019 :) |
I wonder if the language can continue to live outside of Elasticsearch? The reason we made it is because there isn't a good, safe, sandboxed scripting language in the JVM. So I imagine it'll be useful to other people. If it were easy to embed in other places that'd be good exposure for us and help the open source community. |
@nik9000 That's a cool thought, and maybe something to consider down the road, but it's beyond the scope of the initial project by quite a bit. I think the biggest limiter for doing something like that is the language really is designed to only allow scripts that are the equivalent of a single static Java method running on one thread, so for it to be effective outside ES it would certainly need to have it's feature set expanded significantly. |
I wanted to give an update about some of the features and the current state of the language: The prior list remains except for string features; however, after speaking with @rmuir and @rjernst I would like to take a week to explore the possibility of using invoke dynamic to offer a language that doesn't require casting. Currently the language has strict typing making it very similar to Java. However, given the languages that people are used to this may be an issue, longer term. It's likely I won't solve this in a week, but wanted to explore the possibility as something to do after the initial release with the need to make sure that it's at least possible with the current design. As it stands the following features exist:
A small example of the language definition: A small example of what a script will look like: list nums = input["inner"]["list"]; where the automatically generated signature for the script is Object execute(Map<String, Object> input); Note that this can be thought of as a single static Java method when writing the script. There is no way to script new functions/methods as if that's necessary, scripting may not be the best choice for the work that needs to be done in most cases. It may also be possible to add the ability to execute other scripts from the original script to make up for the lack of method calls, but will likely not be included in the initial release. |
Quick update: @rmuir has added ES plugin logic for the prototype language. This week will be about adding tests and fixing bugs as they arise. Not much else to add for now. |
I have removed all shortcuts for now to reduce the amount of debugging necessary for a first iteration. Shortcuts add a huge amount of complication and ambiguity to the language at this point in time. A second iteration somewhere down the road will have the goal of shortcuts, plus dynamic method calls, and inferred casting. The main goal of this project at this time is a simple language that can improve security needs to be safe enough to run dynamic scripts in ES. |
I see "+=", what about ".="? |
@eskibars To be clear is .= for string concatenation? If so, we have decided to use ..= as the (.) operator may end up overloaded with an alternative shortcut for reading through maps/lists at a later time and will be needed for that. We do not want to use += because that creates some possible ambiguities of it's own and is a math operator. (While this works in Java, some of the assumptions that need to be made may not be for the best in all situations.) |
@jdconrad yes, I was referring to string concatenation |
Great stuffs! One issue I have with scripting in Elasticsearch is that is really hard to test and debug a script; We need, IMO:
Maybe this new (un-named?) scripting language could fix or at least improve those points :) Cheers from Elastic{ON} Paris! 🍻 |
@damienalexandre Thanks for the feedback here. Points 1, 2, and 4 are all solid ideas, and hopefully somewhere down the road we will have time to spec and code some incarnation of them. For point 3, it's very unlikely that we will ever log anything from this language as we really don't want to write any files because it would mean that we have to open up security to allow this to happen. |
Closed by #15136 |
ElasticSearch needs a scripting language that can be used dynamically while remaining secure. While Lucene Expressions covers those two points it does not meet the needs of many scripts due the following behavior:
One of the main goals of this language is any somewhat experienced developer should be able to learn the entirety in about fifteen minutes. For this reason I'm going to keep the control flow simple by allowing only the equivalent of one linearly-run static Java function to be written in total for any given script. No multiple function/method scripts should be allowed, as at this point the users should be writing custom code for their application instead of leaning on scripting.
For the new language I intend to initially have the following:
This list will be updated as the project moves forward. To ensure the language does not hang due to an infinite loop or extremely long operational set, the number of instructions will be counted, and an exception will be thrown if a specified limit is reached.
I intend to build the language using ANTLR and ASM as the backbone. The following steps will be required for the language to be created.
The text was updated successfully, but these errors were encountered: