Hi! Is it possible to enforce script to use only K...
# scripting
b
Hi! Is it possible to enforce script to use only Kotlin’s Stdlib and avoid any Java/JS/Native classes? (While keeping JVM as a target)
i
No, at least not yet. In the future we plan to support restrictions of some sort.
a
@bsideup you can use Cuarantena if you compile the script, check it with that, then run. You can provide a whitelist of classes down to the method/member you allow access to: https://github.com/kohesive/cuarentena I haven't put it in a generic script engine, but I could add it to Keplin.
b
Hi @apatrida! Thanks, but all this classpath-based white listing solutions happen too late. I want to reject a script if it cannot be compiled because it uses any(!) JVM class (and not Kotlin’s stdlib)
a
@bsideup why is it too late? I can work directly from the compiled script class bytes before the class is loaded.
so it is at the end of compilation before any danger can happen, and you can report the errors as access violations to anything you want.
b
exactly. Before the class is loaded. While I want: fail compilation(!) when unwanted class is being used at a compilation time