File system access: copy/move/delete files

Manipulating files from Sense load scripts in a secure yet flexible way.

Unrestricted file system access is a security risk

Qlik Sense locked down things quite a bit compared to its QlikView predecessor:

In QlikView your app scripts could do almost anything with any file on the server’s disks as long as the QlikView service account had access to the file.
This was not ideal from a security perspective and Qlik Sense therefore introduced the concept of folder data connetions and in general much stricter file system access restrictions.

With this change Qlik Sense had a much better position with respect to security, as access to files was now boxed by the folder data connection the access used (by means of lib:// statements).
It’s also possible to include .qvs script files via the same mechanism.

The problem now is that it’s no longer possible to do file level operations on individual or groups of files.
No more deleting, copying or moving of files from within the load script.

Now - there is a per-server setting that disables this new “standard mode” and reverts back to what’s known as “legacy mode”, which is essentially how QlikView worked (and still works). But then the Sense environment is once again vulerable to badly written or even malicious Sensse apps.

Butler adds controlled file system access to Qlik Sense Enterprise

Butler’s solution is to add a set of REST API endpoints for file copy/move/delete operations, but only allow these to operate on pre-defined folders.

For example, you might have a QVD folder at e:\data\qvd\sales\temp.
You also need to remove old QVDs from that folder.

This could be done with scheduled BAT/CMD files or PowerShell scripts, but it might be better/more flexible/easier to maintain to drive this cleanup from the load script of a Sense app.

The solution: Add e:\data\qvd\sales\temp to Butler’s list of folders in which files can be deleted, then call Butler’s /v4/filedelete API endpoint from within your app’s load script. Done!

Convenience subs

Butler includes a set of Subs that make it easy to use the file copy/move/delete APIs.
These subs are found in this .qvs file as well as embedded in the Butler demo app.

The examples section shows how to use these subs - or call the Butler APIs directly.

Last modified 2021-04-22: First commit (c105eb7)