1

Is there a way to limit Gremlin expressions to just Gremlin API? I'd like to embed gremlin as a part of one rule engine, but the possibility to call whatever e.g. in filters is a risk.

g.v(1).outE.filter{ new Socket('localhost', 8080). ... }

Is there a way to limit the execution to some safe set of interfaces?

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277

1 Answers1

1

One method might be to look into what Groovy offers in controlling script execution via JVM security. Perhaps these links will be helpful:

http://groovy.codehaus.org/Security http://www.chrismoos.com/2010/03/24/groovy-scripts-and-jvm-security/

As an alternative to JVM security there is also this compilation customizer:

http://groovy-sandbox.kohsuke.org/

which would allow you to write filters that will prevent a script from getting reference to objects that they are not supposed to.

stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • Is this answer still up to date? – kaqqao Jun 28 '21 at 23:40
  • 1
    nowadays it depends on your graph provider. Amazon Neptune, for example, has no such worries as it only allows execution of Gremlin and DataStax Graph has its own method of sandboxing. For OSS Gremlin Server we have examples based on the sandbox in the link in my answer that might help inspire a solution. Going forward, TinkerPop expect to make groovy script processing optional and only process bytcode or Gremlin strings parsed to AST: https://issues.apache.org/jira/browse/TINKERPOP-2583 – stephen mallette Jul 02 '21 at 16:04