You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We want to provide a set of curated / approved scripts which our users can include in their scripts. This could be some common JS libraries which will make the user's life easier when creating a Nashorn Script. One of the balancing points here is to only allow the scripts to be read from a "trusted" location, which in this case could be somewhere on the filesystem and the file can be loaded into a string and then loaded into the script, I've tried loading them how a lot of Nashorn example show, which looks like:
sandbox.eval("script code loaded to string from a file system object"); sandbox.eval("script code that makes use of the loaded script above");
The above works when not using the sandbox and just native Nashorn. However, using the delight sandbox, the script loaded using this mechanism does not have access to first script probably due to not being loaded into the same context.
Is there something that we can do here?
The text was updated successfully, but these errors were encountered:
- since the same script context is used for two different calls to eval, the variable initialised in the first is available in the second. And I would assume all that 'loads a library' means is to initialise variables that then can be used by other scripts?
ScriptContext newContext1 = new SimpleScriptContext();
sandbox.eval(librarySourceCode, newContext1);
sandbox.eval("jquery.doSomething()", newContext1);
Bindings could be used for a more explicit passing on of the variables initialised by loading the script, such as:
We want to provide a set of curated / approved scripts which our users can include in their scripts. This could be some common JS libraries which will make the user's life easier when creating a Nashorn Script. One of the balancing points here is to only allow the scripts to be read from a "trusted" location, which in this case could be somewhere on the filesystem and the file can be loaded into a string and then loaded into the script, I've tried loading them how a lot of Nashorn example show, which looks like:
sandbox.eval("script code loaded to string from a file system object"); sandbox.eval("script code that makes use of the loaded script above");
The above works when not using the sandbox and just native Nashorn. However, using the delight sandbox, the script loaded using this mechanism does not have access to first script probably due to not being loaded into the same context.
Is there something that we can do here?
The text was updated successfully, but these errors were encountered: