Restrict Files Access

abstract This section describes how we can restrict Sahi Pro's access to different files.
It is available since Sahi Pro V6.3.1.

Configure userdata_hidden.properties

By default, Sahi Pro's file manipulation APIs like _readFile,_writeFile,_deleteFile,_renameFile,_copyFileetc. have access to all the files on the file system. This can be restricted to only specific directories by configuring the property file.accessible.dir in <sahi_root>/userdata/config/userdata_hidden.properties file.

See the examples below :
// Use wildcard '*' to provide access to all the files.
file.accessible.dir=*;   // By default, Sahi Pro has access to all the files.
// Restrict Sahi Pro's access to only the files inside example directory and its sub-directories.
file.accessible.dir=D:/testing/example;   // Must use '\\' or '/' as file path separator.
// Restrict SahiPro's access to only the files inside Sahi Pro's default scripts directory and its sub-directories.
file.accessible.dir=userdata/scripts;   // The path here is relative to Sahi Pro installation directory
// Provide access to multiple directories by separating multiple directories with semi-colon.
// Restrict Sahi Pro's access to only the files inside 'scripts directory and its sub-directories' and 'example directory and its sub-directories'.
file.accessible.dir=userdata/scripts; D:/example;
// Restrict Sahi Pro's access to only the script directories configured in Sahi Pro.
file.accessible.dir=$scripts.dir;
info
  1. Restart Sahi Pro after updating userdata_hidden.properties.
  2. Ensure that Sahi Pro has access to all the files that will be accessed using file manipulation APIs during playback. If not, then Sahi Pro will show a message as "File Access is not allowed for <file-path>" in the logs and the script will fail.
  3. Note that these file restrictions are only applicable on file manipulation APIs of Sahi Pro. File access can still be accomplished by following ways :
Refer here for restricting remote access.