Security settings for Scripting environment
This arose in another context and I haven’t seen a response from the Quantrix side, so surfacing it here to make visible.
The current environment for scripting appears to use the default Java Security Policy i.e. scripts are treated as though they were applets in a browser. This means scripts have no access to the local machine i.e. they can’t load or save files, etc.
Is this intended to be the case? If so it would be highly desirable if it were possible to set an alternative security policy as an option. This would probably require a user warning/confirmation to be issued when loading such a script – similar to loading VBA scripts in Excel.
Thanks
Simon
Here is the full response to this question:
Scripts in Quantrix do run under a restricted security policy. It’s not merely a default Java policy; it is something we cooked up ourselves. However, as with applets, the overall aim is to create a sandbox.
The flexibility you have proposed is something we’re willing to consider, and I have logged it as a feature request.
Hi,
I need to import an external library that should be used in a script function (not in an action). I put the jar file in the ScriptingLibs folder, but when I import that class in the functions list (Edit functions…) I got the error “unable to resolve class …”.
With actions the import works perfectly.
Thanks,
Davide
Hi Luca,
I was able to make it work on our OS X test machine here using 4.0.46. The path you gave for ScriptingLibs on a Mac is the correct one, so it should be working for you as well. If you haven’t already, one thing to try would be a complete removal and fresh reinstall of 4.0.46. If you’ve already done that or you do it and it doesn’t help, is it possible that the problem could be explained by anything other than failure to locate the library?
Regards,
Ben
[quote="Ben G":2scwg1er]
External JARs can be imported as of 4.0.42. For security reasons, we decided to use a single blessed location for external libraries rather than making the entire class path available to scripting. To install a library for use with scripting, follow these steps:
1) Open the folder on your hard drive where Quantrix is installed, and within that folder create a subfolder called “ScriptingLibs”.
2) Place any JARs you need to use within the ScriptingLibs folder.
3) Restart Quantrix if necessary. In your script, import the classes you would like to use as you would in normal Groovy or Java source.
Ben[/quote:2scwg1er]
On a Mac I have tried to create a folder named ScriptingLibs under:
/Applications/Quantrix Modeler.app/Contents/Resources/Java/ScriptingLibs
It doesn’t seem to access jar libraries placed in such folder. Any hint on the location of ScriptingLibs?
Thanks in advance
Dominik:
External JARs can be imported as of 4.0.42. For security reasons, we decided to use a single blessed location for external libraries rather than making the entire class path available to scripting. To install a library for use with scripting, follow these steps:
1) Open the folder on your hard drive where Quantrix is installed, and within that folder create a subfolder called “ScriptingLibs”.
2) Place any JARs you need to use within the ScriptingLibs folder.
3) Restart Quantrix if necessary. In your script, import the classes you would like to use as you would in normal Groovy or Java source.
Simon:
We’re reluctant to expand scripting capabilities hastily, for two reasons. First, scripting is mainly intended as a tool for automating routine tasks within a model. We would like scripting to be robust, but also simple to use and not so powerful that it blurs the line between an accessible feature and something more heavy duty. The second consideration is security. Allowing file system access, even with user consent, is problematic because a naive user may not always understand what they are consenting to.
We feel that if you need to perform file system operations beyond opening, closing, and exporting models, you may be better off going with the QDK. For routine operations on model files, the [font=”Courier New”]quantrix[/font] global object provides the following methods for creating, opening and navigating models:
[code:3w0m4lfk]
createModel
openModel
getModelNamed
openModels [a property]
[/code:3w0m4lfk]
And the [font=”Courier New”]model[/font] global object offers the following methods for saving, exporting, or closing an open model:
[code:3w0m4lfk]
save
saveAs
exportExcel
exportHTML
close[/code:3w0m4lfk]
Correct me if I’m wrong, but printing seems less like something you would need particular permissions for, and more like something we would incorporate into the scripting API as a method on printable objects (which we are willing to look into).
I realize this might not be exactly the answer you’re looking for, but hopefully it’s somewhat helpful.
Regards,
Ben
In addition to the classloader capability Dominik mentions, I’d suggest that scripts could reasonably expect to access the filesystem (after all the Quantrix model can) and to print. Maybe not by default, but it should be possible by some level of configuration, and/or user prompting&acknowledgment.
Thanks
Simon
Hi Simon,
I want to acknowledge your post so you’re not left hanging. However, I will need to check with some higher-ups before I can give you a definitive verdict on our rationale and future plans in this regard. My aim is to reply fully on Monday morning. Sorry for the delay and thanks for your patience.
Ben