You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2018/09/27 15:05:25 UTC

[1/6] tinkerpop git commit: Apply StringEscapeUtils in GroovyTranslator#convertToString(String) [Forced Update!]

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-2025 1fb343191 -> 0278c1576 (forced update)


Apply StringEscapeUtils in GroovyTranslator#convertToString(String)


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

Branch: refs/heads/TINKERPOP-2025
Commit: aff2037b5973c62c0292ab3065761e923899aa57
Parents: 207c660
Author: Justin Chu <15...@users.noreply.github.com>
Authored: Fri Sep 21 15:12:26 2018 -0400
Committer: Justin Chu <15...@users.noreply.github.com>
Committed: Mon Sep 24 11:22:52 2018 -0400

----------------------------------------------------------------------
 .../groovy/jsr223/GroovyTranslatorTest.java     | 69 ++++++++++++++++++++
 .../gremlin/groovy/jsr223/GroovyTranslator.java |  4 +-
 2 files changed, 72 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aff2037b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java
index 56f9699..942f1a5 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslatorTest.java
@@ -30,7 +30,10 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.SubgraphStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.TranslationStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
+import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import org.apache.tinkerpop.gremlin.util.function.Lambda;
 import org.junit.Test;
 
@@ -116,6 +119,17 @@ public class GroovyTranslatorTest extends AbstractGremlinTest {
         assertEquals(7, sacks.get(5).intValue());
         //
         assertEquals(24, t.getSideEffects().<Number>get("lengthSum").intValue());
+
+        final String script = GroovyTranslator.of("g").translate(t.getBytecode());
+        assertEquals("g.withSideEffect(\"lengthSum\",(int) 0).withSack((int) 1)" +
+                        ".V()" +
+                        ".filter({it.get().label().equals('person')})" +
+                        ".flatMap({it.get().vertices(Direction.OUT)})" +
+                        ".map({it.get().value('name').length()})" +
+                        ".sideEffect({ x -> x.sideEffects(\"lengthSum\", x.<Integer>sideEffects('lengthSum') + x.get()) })" +
+                        ".order().by({a,b -> a <=> b})" +
+                        ".sack({ a,b -> a + b })",
+                script);
     }
 
     @Test
@@ -141,4 +155,59 @@ public class GroovyTranslatorTest extends AbstractGremlinTest {
     public void shouldHaveValidToString() {
         assertEquals("translator[h:gremlin-groovy]", GroovyTranslator.of("h").toString());
     }
+
+    @Test
+    public void shouldEscapeStrings() {
+        final GraphTraversalSource g = graph.traversal();
+        final String script = GroovyTranslator.of("g").translate(g.addV("customer")
+                .property("customer_id", 501L)
+                .property("name", "Foo\u0020Bar")
+                .property("age", 25)
+                .property("special", "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?")
+                .asAdmin().getBytecode());
+
+        assertEquals("g.addV(\"customer\")" +
+                        ".property(\"customer_id\",501L)" +
+                        ".property(\"name\",\"Foo Bar\")" +
+                        ".property(\"age\",(int) 25)" +
+                        ".property(\"special\",\"\"\"`~!@#\\$%^&*()-_=+[{]}\\\\|;:'\\\",<.>/?\"\"\")",
+                script);
+    }
+
+    @Test
+    public void shouldHandleVertexAndEdge() {
+        final GraphTraversalSource g = graph.traversal();
+
+        final Object id1 = "customer:10:foo\u0020bar\u0020\u0024100#90"; // customer:10:foo bar $100#90
+        final Vertex vertex1 = DetachedVertex.build().setLabel("customer").setId(id1)
+                .create();
+        final String script1 = GroovyTranslator.of("g").translate(g.V(vertex1).asAdmin().getBytecode());
+        assertEquals("g.V(new org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex(" +
+                        "\"customer:10:foo bar \\$100#90\"," +
+                        "\"customer\", Collections.emptyMap()))",
+                script1);
+
+        final Object id2 = "user:20:foo\\u0020bar\\u005c\\u0022mr\\u005c\\u0022\\u00241000#50"; // user:20:foo\u0020bar\u005c\u0022mr\u005c\u0022\u00241000#50
+        final Vertex vertex2 = DetachedVertex.build().setLabel("user").setId(id2)
+                .create();
+        final String script2 = GroovyTranslator.of("g").translate(g.V(vertex2).asAdmin().getBytecode());
+        assertEquals("g.V(new org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex(" +
+                        "\"user:20:foo\\\\u0020bar\\\\u005c\\\\u0022mr\\\\u005c\\\\u0022\\\\u00241000#50\"," +
+                        "\"user\", Collections.emptyMap()))",
+                script2);
+
+        final Object id3 = "knows:30:foo\u0020bar\u0020\u0024100:\\u0020\\u0024500#70";
+        final Edge edge = DetachedEdge.build().setLabel("knows").setId(id3)
+                .setOutV((DetachedVertex) vertex1)
+                .setInV((DetachedVertex) vertex2)
+                .create();
+        final String script3 = GroovyTranslator.of("g").translate(g.E(edge).asAdmin().getBytecode());
+        assertEquals("g.E(new org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge(" +
+                        "\"knows:30:foo bar \\$100:\\\\u0020\\\\u0024500#70\"," +
+                        "\"knows\",Collections.emptyMap()," +
+                        "\"customer:10:foo bar \\$100#90\",\"customer\"," +
+                        "\"user:20:foo\\\\u0020bar\\\\u005c\\\\u0022mr\\\\u005c\\\\u0022\\\\u00241000#50\",\"user\"))",
+                script3);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/aff2037b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslator.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslator.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslator.java
index 6e86ce9..0452e0b 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslator.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GroovyTranslator.java
@@ -19,6 +19,7 @@
 
 package org.apache.tinkerpop.gremlin.groovy.jsr223;
 
+import groovy.json.StringEscapeUtils;
 import org.apache.commons.configuration.ConfigurationConverter;
 import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
@@ -115,7 +116,8 @@ public final class GroovyTranslator implements Translator.ScriptTranslator {
         else if (object instanceof Traversal)
             return convertToString(((Traversal) object).asAdmin().getBytecode());
         else if (object instanceof String) {
-            return (((String) object).contains("\"") ? "\"\"\"" + object + "\"\"\"" : "\"" + object + "\"").replace("$", "\\$");
+            return (((String) object).contains("\"") ? "\"\"\"" + StringEscapeUtils.escapeJava((String) object) + "\"\"\"" : "\"" + StringEscapeUtils.escapeJava((String) object) + "\"")
+                    .replace("$", "\\$");
         } else if (object instanceof Set) {
             final Set<String> set = new HashSet<>(((Set) object).size());
             for (final Object item : (Set) object) {


[4/6] tinkerpop git commit: Merge branch 'TINKERPOP-2035' into tp32

Posted by dk...@apache.org.
Merge branch 'TINKERPOP-2035' into tp32


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

Branch: refs/heads/TINKERPOP-2025
Commit: d516c68289c666a1b8f11dc3fe9dd1e75315596f
Parents: abfe968 54ad5f4
Author: Jorge Bay Gondra <jo...@gmail.com>
Authored: Thu Sep 27 12:59:31 2018 +0200
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Thu Sep 27 12:59:31 2018 +0200

----------------------------------------------------------------------
 .../gremlin-javascript/lib/driver/driver-remote-connection.js      | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------



[5/6] tinkerpop git commit: Updated nuget URL CTR

Posted by dk...@apache.org.
Updated nuget URL CTR


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

Branch: refs/heads/TINKERPOP-2025
Commit: 07ab226ce2b7a5357a8367ccefadf959c2c07ec7
Parents: d516c68
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Sep 27 11:01:28 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Sep 27 11:01:45 2018 -0400

----------------------------------------------------------------------
 gremlin-dotnet/src/pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/07ab226c/gremlin-dotnet/src/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-dotnet/src/pom.xml b/gremlin-dotnet/src/pom.xml
index 664522a..aca3875 100644
--- a/gremlin-dotnet/src/pom.xml
+++ b/gremlin-dotnet/src/pom.xml
@@ -186,10 +186,10 @@ limitations under the License.
                                         the "ConfigFile" option to nuget.
                                         -->
                                         <exec executable="mono" failonerror="true">
-                                            <arg line="${nugetExe} push Gremlin.Net/bin/Gremlin.Net.*.nupkg -Source https://www.nuget.org/api/v2/package -ConfigFile ${user.home}/.config/NuGet/NuGet.Config"/>
+                                            <arg line="${nugetExe} push Gremlin.Net/bin/Gremlin.Net.*.nupkg -Source https://api.nuget.org/v3/index.json -ConfigFile ${user.home}/.config/NuGet/NuGet.Config"/>
                                         </exec>
                                         <exec executable="mono" failonerror="true">
-                                            <arg line="${nugetExe} push Gremlin.Net.Template.*.nupkg -Source https://www.nuget.org/api/v2/package -ConfigFile ${user.home}/.config/NuGet/NuGet.Config"/>
+                                            <arg line="${nugetExe} push Gremlin.Net.Template.*.nupkg -Source https://api.nuget.org/v3/index.json -ConfigFile ${user.home}/.config/NuGet/NuGet.Config"/>
                                         </exec>
                                     </tasks>
                                 </configuration>


[6/6] tinkerpop git commit: Remove release artifact SHA1 checksums and generate SHA512 checksums instead.

Posted by dk...@apache.org.
Remove release artifact SHA1 checksums and generate SHA512 checksums instead.


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

Branch: refs/heads/TINKERPOP-2025
Commit: 0278c1576c165ec1217eb616995e9280509c8e67
Parents: 07ab226
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Mon Sep 24 08:47:27 2018 -0700
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Thu Sep 27 08:05:18 2018 -0700

----------------------------------------------------------------------
 bin/validate-distribution.sh            | 3 ++-
 docs/src/dev/developer/release.asciidoc | 3 ++-
 pom.xml                                 | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0278c157/bin/validate-distribution.sh
----------------------------------------------------------------------
diff --git a/bin/validate-distribution.sh b/bin/validate-distribution.sh
index 3622905..1fff5b5 100755
--- a/bin/validate-distribution.sh
+++ b/bin/validate-distribution.sh
@@ -85,11 +85,12 @@ fi
 
 echo -n "* downloading ${COMPONENT} (${ZIP_FILENAME})... "
 curl -Lsf ${URL} -o ${ZIP_FILENAME} || { echo "Failed to download ${COMPONENT}" ; exit 1; }
-for ext in "asc" "sha1"
+for ext in "asc" "sha512"
 do
   curl -Lsf ${URL}.${ext} -o ${ZIP_FILENAME}.${ext} || { echo "Failed to download ${COMPONENT} (${ext})" ; exit 1 ; }
 done
 curl -Lsf ${URL}.md5 -o ${ZIP_FILENAME}.md5 && { echo "MD5 checksums should not be released (${ZIP_FILENAME}.md5)" ; exit 1 ; }
+curl -Lsf ${URL}.sha1 -o ${ZIP_FILENAME}.sha1 && { echo "SHA1 checksums should not be released (${ZIP_FILENAME}.sha1)" ; exit 1 ; }
 echo "OK"
 
 # validate zip file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0278c157/docs/src/dev/developer/release.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/developer/release.asciidoc b/docs/src/dev/developer/release.asciidoc
index eeb4679..f48e20c 100644
--- a/docs/src/dev/developer/release.asciidoc
+++ b/docs/src/dev/developer/release.asciidoc
@@ -215,8 +215,9 @@ for generating javadoc and without that the binary distributions won't contain t
 .. `cp ~/.m2/repository/org/apache/tinkerpop/gremlin-console/xx.yy.zz/gremlin-console-xx.yy.zz-distribution.zip* dev/xx.yy.zz`
 .. `cp ~/.m2/repository/org/apache/tinkerpop/gremlin-server/xx.yy.zz/gremlin-server-xx.yy.zz-distribution.zip* dev/xx.yy.zz`
 .. `cp ~/.m2/repository/org/apache/tinkerpop/tinkerpop/xx.yy.zz/tinkerpop-xx.yy.zz-source-release.zip* dev/xx.yy.zz`
-.. `rm -f dev/*.md5`
 .. `cd dev/xx.yy.zz`
+.. `rm -f *.md5`
+.. `for file in *.sha1 ; do artifact=$(basename ${file} .sha1); sha512sum $artifact | awk '{print $1}' > ${artifact}.sha512; rm ${file}; done`
 .. pass:[<code>ls * | xargs -n1 -I {} echo "mv apache-tinkerpop-{} {}" | sed -e 's/distribution/bin/' -e 's/source-release/src/' -e 's/tinkerpop-tinkerpop/tinkerpop/' -e s'/^\(.*\) \(.*\) \(.*\)$/\1 \3 \2/' | /bin/bash</code>]
 .. `cd ..; svn add xx.yy.zz/; svn ci -m "TinkerPop xx.yy.zz release"`
 . Execute `bin/validate-distribution.sh` and any other relevant testing.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0278c157/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d13f60e..6b254a2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@ limitations under the License.
     <parent>
         <groupId>org.apache</groupId>
         <artifactId>apache</artifactId>
-        <version>19</version>
+        <version>21</version>
     </parent>
     <groupId>org.apache.tinkerpop</groupId>
     <artifactId>tinkerpop</artifactId>


[2/6] tinkerpop git commit: Updated changelog CTR

Posted by dk...@apache.org.
Updated changelog CTR


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

Branch: refs/heads/TINKERPOP-2025
Commit: abfe968c762199ef5fa6b8f300c9de060ef75a24
Parents: aff2037
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Sep 24 16:13:39 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Sep 24 16:13:39 2018 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/abfe968c/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 9431d98..6d9770f 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -36,6 +36,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 * Added support for GraphSON serialization of `Date` in Javascript.
 * Added synchronized `Map` to Gryo 1.0 registrations.
 * Added `Triple` to Gryo 1.0 registrations.
+* Improved escaping of special characters in strings passed to the `GroovyTranslator`.
 * Added better internal processing of `Column` in `by(Function)`.
 * Added `hasNext()` support on `Traversal` for `gremlin-python`.
 * Added support for additional extended types in Gremlin.Net with `decimal`, `TimeSpan`, `BigInteger`, `byte`, `byte[]`, `char` and `short`.


[3/6] tinkerpop git commit: Pass custom headers to the websocket connection

Posted by dk...@apache.org.
Pass custom headers to the websocket connection

In order to authorize to the gremlin server (in this case AWS Neptune) i need to pass custom headers for authorization to the service. the PR will allow to send any headers (like an API key or signature) and pass them to the Websocket function.
While there can be many use cases for this, in my case i pass the Authorization & x-amz-date required for Signature V4 (IAM) authentication.


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

Branch: refs/heads/TINKERPOP-2025
Commit: 54ad5f45e73bae05b957b89539cb6a61d557f445
Parents: abfe968
Author: Lior Pollack <de...@gmail.com>
Authored: Mon Sep 10 22:16:38 2018 +0300
Committer: Jorge Bay Gondra <jo...@gmail.com>
Committed: Thu Sep 27 12:58:44 2018 +0200

----------------------------------------------------------------------
 .../gremlin-javascript/lib/driver/driver-remote-connection.js      | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/54ad5f45/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
----------------------------------------------------------------------
diff --git a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
index 15836ba..ca059cf 100644
--- a/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
+++ b/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/driver/driver-remote-connection.js
@@ -49,12 +49,14 @@ class DriverRemoteConnection extends RemoteConnection {
    * @param {String} [options.traversalSource] The traversal source. Defaults to: 'g'.
    * @param {GraphSONWriter} [options.writer] The writer to use.
    * @param {Authenticator} [options.authenticator] The authentication handler to use.
+   * @param {Object} [options.headers] An associative array containing the additional header key/values for the initial request.
    * @constructor
    */
   constructor(url, options) {
     super(url);
     options = options || {};
     this._ws = new WebSocket(url, {
+      headers: options.headers,
       ca: options.ca,
       cert: options.cert,
       pfx: options.pfx,