You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/07/27 20:00:23 UTC

[3/9] incubator-tinkerpop git commit: Added a basic implemenation of the SandboxExtension to ship with Gremlin Server.

Added a basic implemenation of the SandboxExtension to ship with Gremlin Server.

Affords some basic out-of-the-box protection (but not much).


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/0c0aa358
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/0c0aa358
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/0c0aa358

Branch: refs/heads/master
Commit: 0c0aa358ad0495b4b6261279ef22e605adbb3ff5
Parents: c362669
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 24 12:54:59 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 24 12:54:59 2015 -0400

----------------------------------------------------------------------
 .../customizer/SimpleSandboxExtension.groovy    | 39 ++++++++++++++++++++
 1 file changed, 39 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/0c0aa358/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/SimpleSandboxExtension.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/SimpleSandboxExtension.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/SimpleSandboxExtension.groovy
new file mode 100644
index 0000000..111e363
--- /dev/null
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/jsr223/customizer/SimpleSandboxExtension.groovy
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.groovy.jsr223.customizer
+
+import org.codehaus.groovy.ast.MethodNode
+
+import java.util.function.BiPredicate
+
+/**
+ * Blacklists the {@code System} class to ensure that one can't call {@code System.exit()}.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+class SimpleSandboxExtension extends SandboxExtension {
+    SimpleSandboxExtension() {
+        gIsAlwaysGraphTraversalSource = false
+        graphIsAlwaysGraphInstance = false
+
+        methodFilter = (BiPredicate<String, MethodNode>) { descriptor, method ->
+            return method.declaringClass.name != 'java.lang.System'
+        }
+    }
+}