-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Security permissions for Groovy JsonSlurper #16808
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
Conversation
This commit adds the necessary class permissions and property permissions for basic Groovy JsonSlurper functionality.
why is json parsing necessary in scripts? I don't think we need to support this. Also this kind of serialization/deserialization tends to rely on I really do not think we should do this. Our scripts do not need to be parsing json. |
Separately, this PR is broken 80 ways from sunday. Lets try to enumerate everything wrong with it:
But again, we really should not make this change. Totally the wrong direction. No need for anybody to be serializing/deserializing json in scripts. Bringing in additional third party dependencies to do that, that's pure insanity. |
This dependency already exists in the 2.x line and I'm not sure if the fact that it was removed received any attention and certainly not the attention that it deserves. It did not even make the breaking changes doc. And I'm not adding
Can you please explain to me why it's wrong?
This is not grounded by the facts. In particular, the use of unsafe is disabled by default, it is only enabled if some system properties are intentionally set to true. The user has to go out of their way to enable these system properties.
Clearly there are users that think there is a need or there wouldn't be issues on GitHub and posts on Discourse about how it's broken in 2.2 right now.
I think that you're mischaracterizing this. Again, it's a dependency that was removed without broad (any?) awareness. |
I'm not mischaracterizing anything. This is a scripting engine, not a full blown programming language. What is the need to serialize/deserialize json? I'm strongly opposed to this change. |
Its one person basically. Its important to be able to distinguish non-usecases and esoteria from real use cases. |
I see why they are wrong, but note that the license and notice files are also wrong for the groovy artifact and have been since these license and notice files were committed in 180ab24. I've pushed 76e8a11 to fix this for all of these files. |
Just a few comments from the one esoteric guy (there is at least one more: #14787): In my case, I decide in the Groovy update-script whether to process the JSON document or process another argument. Only in the first case - which is very rare - the document needs to be parsed. Decision is based on the existing document being updated. Besides that,
|
There isn't support for stuff like this. Only just a few classes like Nobody needs to be parsing JSON here. Its not something we need to support, or add security holes or extra third party libraries for. I will do everything I can to prevent this. |
I'm siding with Robert here. Parsing JSON in a script just seems wrong. eg we don't support loading python modules in the python scripting plugin. We're certainly not going to support such things in Painless. I'd say that scripts that need to do stuff like this should be implemented in Java rather than Groovy. @fs-chris mentions in #14787 (comment) that:
... which indicates that this should be implemented in Java as well. |
I also agree with @clintongormley - yet the question is if we allow this backwards break in a minor release. On my end that's a case by case decision and for this one I am on the pro-break end. Especially since afaik @bleskes and @kimchy discussed some simple workaround related to passing the json string as a parameter but I don't recall the details. maybe @bleskes can elaborate? |
That was the option to parse the json client side and pass it as a map-of-maps parameter to the script. I mentioned it on the ticket |
Superseded by #16858. |
I see where this discussion leads to. |
If someone is using the Java API and wants to pass in json as a parameter (e.g. for updating the value of a nested object), using JsonSlurper seemed to be the accepted solution. Is there a workaround for this? |
@PeteyPabPro see @bleskes note here: #14787 (comment), you can pass a "map of maps" or the actual params in the parameters to the script, so you won't need to pass in JSON as a value within JSON. |
@PeteyPabPro: Have you tried the previous suggestion of parsing the JSON client side and passing it to the script as a map of maps? |
@kimchy @jasontedor Thanks for the suggestion, let me try that. |
Thanks @PeteyPabPro; please let us know how it turns out? |
@jasontedor Worked perfectly, thanks. |
@PeteyPabPro: Outstanding, thanks for reporting back! This means that we can consider this a viable replacement for the previous functionality. |
Excuse me, but this basically means that modifying nested data in place (without previously loading the content into the client) is no longer possible? Previously, always talking about nested data, with a script I could alter the content of a nested record and reassign it without knowing what was the whole content (an array of nested objects for instance), now seems that since the payload has to be supplied as a param to the script I have to load the whole array into the client and reassign it whole through the map trick |
This commit adds the necessary class permissions and property
permissions for basic Groovy JsonSlurper functionality.
Closes #14787