-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Expose constant fields used by script #60001
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
Comments
Pinging @elastic/es-core-infra (:Core/Infra/Scripting) |
* Add DocFieldsPhase visitor during compilation * Fields are accessible via ScriptScope.docFields() Doc field accesses that are expressions, even constant expressions are not handled. Refs: elastic#60001
* Add DocFieldsPhase visitor during compilation * Fields are accessible via ScriptScope.docFields() Doc field accesses that are expressions, even constant expressions are not handled. Refs: #60001
Some notes based on @stu-elastic first PR: this covers simple doc usage in the main method only. This needs to be extended to track doc into user-defined methods. However, one very important note is we still need to check for cycles at runtime unless we prevent doc from assignment and restrict it to only methods we know are not using assignment. Otherwise, we can lose track if the user decides to assign doc to a data structure such as a List or Map. We must also only allow doc to be referenced by String constants. |
@stu-elastic we should be good for now, thanks! |
This will allows runtime fields to validate that scripts only use fields available and facilitate cycle detection.
One advanced feature here is users only see doc as part of the "main" method in Painless. If doc is passed into a user-defined function this must be tracked and the parameter in the function must also add constant fields used as part of doc.
Handle doc aliasing (
def foo = doc
).Related: #59332
The text was updated successfully, but these errors were encountered: