public class SandboxRules
extends java.lang.Object
The sandbox keeps whitelist rules for the Java Interop and blacklist rules for the Venice functions.
| Modifier and Type | Field and Description |
|---|---|
static java.util.Set<java.lang.String> |
DEFAULT_SYSTEM_ENVS |
static java.util.Set<java.lang.String> |
DEFAULT_SYSTEM_PROPERTIES |
static java.util.Set<java.lang.String> |
DEFAULT_WHITELISTED_MODULES |
| Constructor and Description |
|---|
SandboxRules() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.List<java.lang.String> |
getDefaultRules()
Returns the default rules used for Venice sandboxes.
|
java.lang.Integer |
getMaxExecTimeSeconds() |
java.lang.Integer |
getMaxFutureThreadPoolSize() |
java.util.List<java.lang.String> |
getRules() |
SandboxRules |
merge(SandboxRules other)
Merges this
SandboxRules with the passed other
SandboxRules |
static SandboxRules |
noDefaults()
Creates new SandboxRules starting without any defaults.
|
SandboxRules |
rejectAllConcurrencyFunctions()
Reject access to all concurrency related functions
agents
futures
promises
thread
thread local
watches
parallel processing
scheduler
|
SandboxRules |
rejectAllJavaCalls()
Reject access to all Java related functions
|
SandboxRules |
rejectAllJavaFunctions()
Reject access to all Java related functions
|
SandboxRules |
rejectAllSenstiveSpecialForms()
Reject access to all sensitive special forms
dynamic code loading
ns manipulation
var manipulation
benchmark
profiling
|
SandboxRules |
rejectAllSystemFunctions()
Reject access to all system related functions
|
SandboxRules |
rejectAllUnsafeFunctions()
Reject access to all unsafe functions
|
SandboxRules |
rejectAllVeniceIoFunctions()
Reject access to all Venice I/O related functions
|
SandboxRules |
rejectVeniceFunctions(java.util.Collection<java.lang.String> rules)
Reject Venice function rules to the sandbox.
|
SandboxRules |
rejectVeniceFunctions(java.lang.String... rules)
Reject Venice function rules to the sandbox.
|
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String prefix) |
SandboxRules |
unique()
Remove duplicate rules from these
SandboxRules |
SandboxRules |
whitelistVeniceFunctions(java.util.Collection<java.lang.String> rules)
Whitelist Venice function rules to the sandbox.
|
SandboxRules |
whitelistVeniceFunctions(java.lang.String... rules)
Whitelist Venice function rules to the sandbox.
|
SandboxRules |
withAllSystemEnvs()
Allow access to all system environment variables
|
SandboxRules |
withAllSystemProperties()
Allow access to all Java system properties
|
SandboxRules |
withClasses(java.lang.Class<?>... classes)
Add a rule for classes to the sandbox, whitelisting the class and all its
methods and fields
|
SandboxRules |
withClasses(java.util.Collection<java.lang.Class<?>> classes)
Add a rule for classes to the sandbox, whitelisting the class and all its
methods and fields
|
SandboxRules |
withClasses(java.util.List<java.lang.String> rules)
Add whitelisted class rules to the sandbox.
|
SandboxRules |
withClasses(java.lang.String... rules)
Add whitelisted class rules to the sandbox.
|
SandboxRules |
withClasspathResources(java.util.Collection<java.lang.String> rules)
Add whitelisted classpath resource rules to the sandbox.
|
SandboxRules |
withClasspathResources(java.lang.String... rules)
Add whitelisted classpath resource rules to the sandbox.
|
SandboxRules |
withDefaultClasses() |
SandboxRules |
withDefaultVeniceModules() |
SandboxRules |
withMaxExecTimeSeconds(int maxExecTimeSeconds)
Sets the max execution time in seconds a Venice script under this
SandboxRules is allowed to run. |
SandboxRules |
withMaxFutureThreadPoolSize(int maximumPoolSize)
Sets the max thread pool size for futures a Venice script under this
SandboxRules is allowed to use. |
SandboxRules |
withStandardSystemEnvs()
Allow access to all standard system environment variables
|
SandboxRules |
withStandardSystemProperties()
Allow access to all standard Java system properties
|
SandboxRules |
withSystemEnvs(java.util.Collection<java.lang.String> rules)
Add whitelisted system environment variable rules to the sandbox.
|
SandboxRules |
withSystemEnvs(java.lang.String... rules)
Add whitelisted system environment variable rules to the sandbox.
|
SandboxRules |
withSystemProperties(java.util.Collection<java.lang.String> rules)
Add whitelisted system property rules to the sandbox.
|
SandboxRules |
withSystemProperties(java.lang.String... rules)
Add whitelisted system property rules to the sandbox.
|
SandboxRules |
withVeniceModules(java.util.Collection<java.lang.String> rules)
Add rules for whitelisted Venice modules.
|
SandboxRules |
withVeniceModules(java.lang.String... rules)
Add rules for whitelisted Venice modules.
|
public static final java.util.Set<java.lang.String> DEFAULT_SYSTEM_PROPERTIES
public static final java.util.Set<java.lang.String> DEFAULT_SYSTEM_ENVS
public static java.util.Set<java.lang.String> DEFAULT_WHITELISTED_MODULES
public static SandboxRules noDefaults()
SandboxRulespublic SandboxRules withClasses(java.lang.String... rules)
Java whitelist rules for class/instance accessor follow the schema: '{package}.{className}:{methodName | fieldName}'. The asterix may be used as a wildcard
E.g:
rules - rulesSandboxRulespublic SandboxRules withClasses(java.util.List<java.lang.String> rules)
Java whitelist rules for class/instance accessor follow the schema: '{package}.{className}:{methodName | fieldName}'. The asterix may be used as a wildcard
E.g:
rules - rulesSandboxRulespublic SandboxRules withClasses(java.lang.Class<?>... classes)
Adds a class rule "x.y.classname:*" for each class
classes - classesSandboxRulespublic SandboxRules withClasses(java.util.Collection<java.lang.Class<?>> classes)
Adds a class rule "x.y.classname:*" for each class
classes - classesSandboxRulespublic SandboxRules withDefaultClasses()
public SandboxRules withClasspathResources(java.lang.String... rules)
rules - rulesSandboxRulespublic SandboxRules withClasspathResources(java.util.Collection<java.lang.String> rules)
rules - rulesSandboxRulespublic SandboxRules withSystemProperties(java.lang.String... rules)
E.g: white listing Java system properties
rules - rulesSandboxRulespublic SandboxRules withSystemProperties(java.util.Collection<java.lang.String> rules)
E.g: white listing Java system properties
rules - rulesSandboxRulespublic SandboxRules withSystemEnvs(java.lang.String... rules)
E.g: white listing environment variable
rules - rulesSandboxRulespublic SandboxRules withSystemEnvs(java.util.Collection<java.lang.String> rules)
E.g: white listing environment variable
rules - rulesSandboxRulespublic SandboxRules rejectVeniceFunctions(java.lang.String... rules)
E.g:
rules - rulesSandboxRulespublic SandboxRules rejectVeniceFunctions(java.util.Collection<java.lang.String> rules)
E.g:
rules - rulesSandboxRulespublic SandboxRules whitelistVeniceFunctions(java.lang.String... rules)
E.g:
rules - rulesSandboxRulespublic SandboxRules whitelistVeniceFunctions(java.util.Collection<java.lang.String> rules)
E.g:
rules - rulesSandboxRulespublic SandboxRules withVeniceModules(java.lang.String... rules)
rules - rulesSandboxRulespublic SandboxRules withVeniceModules(java.util.Collection<java.lang.String> rules)
rules - rulesSandboxRulespublic SandboxRules withDefaultVeniceModules()
public SandboxRules withMaxExecTimeSeconds(int maxExecTimeSeconds)
SandboxRules is allowed to run.maxExecTimeSeconds - the max exec time in secondsSandboxRulespublic SandboxRules withMaxFutureThreadPoolSize(int maximumPoolSize)
SandboxRules is allowed to use.maximumPoolSize - the max thread pool sizeSandboxRulespublic SandboxRules rejectAllVeniceIoFunctions()
SandboxRulespublic SandboxRules rejectAllConcurrencyFunctions()
SandboxRulespublic SandboxRules rejectAllSystemFunctions()
SandboxRulespublic SandboxRules rejectAllJavaCalls()
SandboxRulespublic SandboxRules rejectAllJavaFunctions()
SandboxRulespublic SandboxRules rejectAllSenstiveSpecialForms()
SandboxRulespublic SandboxRules rejectAllUnsafeFunctions()
SandboxRulespublic SandboxRules withStandardSystemProperties()
Standard system properties:
SandboxRulespublic SandboxRules withAllSystemProperties()
SandboxRulespublic SandboxRules withStandardSystemEnvs()
Standard system environment variables:
SandboxRulespublic SandboxRules withAllSystemEnvs()
SandboxRulespublic SandboxRules merge(SandboxRules other)
SandboxRules with the passed other
SandboxRules
Note: merges only the rules but not 'maxExecTimeSeconds' and 'maxFutureThreadPoolSize' !!
Note: you may end up with duplicates rules. For better
performance use SandboxRules.unique() to get a new
deduplicated SandboxRules.
other - the other SandboxRules to merge withSandboxRulespublic SandboxRules unique()
SandboxRulesSandboxRulespublic java.util.List<java.lang.String> getRules()
SandboxRulespublic java.lang.Integer getMaxExecTimeSeconds()
SandboxRules is allowed to run.public java.lang.Integer getMaxFutureThreadPoolSize()
SandboxRules is allowed to use.public static java.util.List<java.lang.String> getDefaultRules()
Note: The default rules can be omitted by calling
SandboxRules
.noDefaults()
.withClasses(
"java.lang.Math",
"java.math.BigDecimal");
Sandboxpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(java.lang.String prefix)