Closed thimo-seitz closed 4 years ago
Hi @thimo-seitz
thanks for your question. If you use our Polyglot Context
instead of ScriptEngine
, then you can set the respective flag allowIO
(and others) directly:
import org.graalvm.polyglot.Context;
Context context = Context.newBuilder("js").allowIO(true).build();
context.eval("js", "load('test.js');");
context.close();
This could be an option for you, unless you strictly need compatibility with ScriptEngine
.
Our ScriptEngine
implementation is just a wrapper around the Context
API, but we currently offer no possibility to set flags like allowIO
. This leaves it at its secure default "no access allowed", thus the error that you experience. We are investigating whether we can lift the restrictions a bit or pass in that information over the ScriptEngine API (as a binding for instance) - but this might take a while to get pulled off.
Best, Christian
Tnx @wirthi
How about the Property js.home
? I've seen that this will evaluated first and used as language-home. Setting this to my scriptroot directory also works. Is that property stable for usage?
Best Regards, Thimo
Sorry, I don't get what option you mean. I don't think we have a js.home
flag in either the launcher or our ScriptEngine implementation.
Indeed.
Maybe it is a sideeffect while loading the various "languages" by truffle-polyglot.
When filling the LanguageCache in com.oracle.truffle.polyglot.LanguageCache.collectLanguages(ClassLoader, List<LanguageCache>)
there will be determined the languageHome
of the defined Language. First of all there will be checked the SystemProperties: String languageHome = System.getProperty(id + ".home");
.
In the case for graal-js the id is "js".
I'm using this behaviour to get the Truffle-DeniedIOFileSystem to allow my js-files, located in a specific folder.
Beste Regards Thimo
In case someone else stumbles across this in the future, it is now possible to set options when using the script engine: https://www.graalvm.org/reference-manual/js/ScriptEngine/
Hello.
I'm trying to use graaljs as drop-in-replacement for nashorn using the vm-parameters:
-Dgraaljs.RegisterGraalJSAsNashorn -Dpolyglot.js.nashorn-compat=true
But this results in a "Operation not allowed Error":Using nashorn this works and the js-file is executed.
My js-entry is very simple:
The test.js contains:
The test2.js contains:
Is there futher configuration need? Maybe declaring a root for safe js-files?