Security settings for Scripting environment

Solved6.73K viewsScripting
0

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

1

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.

0

Hi Davide,

Functions work a little differently under the hood than actions, and this difference is the cause of your problem. We agree that external libraries can be applicable to functions, and we will look at correcting this in a future release. Sorry for any interim inconvenience.

Ben

0

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

0

Thanks, Ben. I reinstalled 4.0.46 and the library import worked perfectly.

0

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

0

[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

0

Ben,

Many thanks for making it possible to import external libraries in Quantrix. I will run some tests within next few days (dependent on the time available…).

Dominik

0

Thanks Ben. I understand the tradeoffs, and I think you’ve probably got it right at this stage. We’ll all need to see what situations might actually drive scripts to need file system access (for example). There is always more potential for future releases :)

0

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

0

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

0

Hi Ben,

I can give a reply from my side: It would be interesting if we can import external libraries (*.jar files) like Processing ([url:2cym9590]http://processing.org/[/url:2cym9590]) or numerical libraries like Colt ([url:2cym9590]http://acs.lbl.gov/software/colt/[/url:2cym9590]).

Dominik

0

Simon – Can you provide any examples of concrete use cases for this sort of functionality? They would aid us in evaluating ways of addressing the issue.

0

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