I am thinking of using Rhino as a scripting language but would like to add a layer to prevent scripts from doing anything and everything.
In java one could verify classes and complain if one spots an api that we wish to prevent. Eg if you dnot want users to touch the filesystem complain if one spots calls to java.io.File etc.
Class file verification equivalent
- Is there a phase where one can verify a script once it has been loaded but before it is executed ?
- Is the same callback called when eval is given a String ?
This would be preferred as each script or scriptlet is only checked once and after that it is trusted.
Runtime interception of all java method calls
- Does Rhino call some callback with each attempt to execute a function call ?
- Is it possible to only install this checker on certain apis such as when one is attempting to access a java class.
This would allow other true javascript objects to execute without the barrier...
Is there some other way of preventing calls to java objects to do stuff that i wish to sandbox ?
Rhino SecurityController
Im not quite sure and will have to try the callWithDomain() method.