use of net.robinfriedli.aiode.boot.configurations.GroovySandboxComponent in project aiode by robinfriedli.
the class ScriptCommand method executeScript.
private void executeScript(Aiode aiode, CommandContext context, Session session) {
GroovySandboxComponent groovySandboxComponent = aiode.getGroovySandboxComponent();
GroovyVariableManager groovyVariableManager = aiode.getGroovyVariableManager();
SafeGroovyScriptRunner groovyScriptRunner = new SafeGroovyScriptRunner(context, groovySandboxComponent, groovyVariableManager, aiode.getSecurityManager(), argumentSet("privileged"));
StoredScript script;
if (this.script != null) {
script = this.script;
} else {
String identifier = getArgumentValue("invoke");
Optional<StoredScript> storedScript = SearchEngine.searchScript(identifier, "script", session);
if (storedScript.isPresent()) {
script = storedScript.get();
} else {
throw new InvalidCommandException(String.format("No such script '%s'", identifier));
}
}
if (!script.isActive()) {
throw new InvalidCommandException(String.format("Script '%s' has been deactivated. Use the active argument to reactivate the script.", script.getIdentifier()));
}
groovyScriptRunner.runAndSendResult(script.getScript(), 10, TimeUnit.SECONDS);
}
use of net.robinfriedli.aiode.boot.configurations.GroovySandboxComponent in project aiode by robinfriedli.
the class EvalCommand method doRun.
@Override
public void doRun() {
CommandContext context = getContext();
Aiode aiode = Aiode.get();
SecurityManager securityManager = aiode.getSecurityManager();
GroovySandboxComponent groovySandboxComponent = aiode.getGroovySandboxComponent();
GroovyVariableManager groovyVariableManager = aiode.getGroovyVariableManager();
SafeGroovyScriptRunner groovyScriptRunner = new SafeGroovyScriptRunner(context, groovySandboxComponent, groovyVariableManager, securityManager, argumentSet("privileged"));
groovyScriptRunner.runAndSendResult(getCommandInput(), 10, TimeUnit.SECONDS);
}
Aggregations