imbajin commented on code in PR #2987:
URL: https://github.com/apache/hugegraph/pull/2987#discussion_r3062128820


##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/gremlin/GremlinQueryAPI.java:
##########
@@ -43,7 +43,8 @@ public class GremlinQueryAPI extends API {
             "java.util.concurrent.TimeoutException",
             "groovy.lang.",
             "org.codehaus.",
-            "org.apache.hugegraph."
+            "org.apache.hugegraph.",
+            "org.apache.tinkerpop."

Review Comment:
   ‼️ This package-wide allowlist is too broad. `matchBadRequestException()` 
would now classify classes such as 
`org.apache.tinkerpop.gremlin.server.auth.AuthenticationException` and 
`org.apache.tinkerpop.gremlin.server.authz.AuthorizationException` as 400, even 
though they carry 401/403 semantics. That changes the API contract for auth 
failures and hides security/server-side errors behind a generic bad request. 
Please whitelist only the concrete exception class(es) reproduced by #2986 
instead of the whole `org.apache.tinkerpop.` namespace.



##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/api/gremlin/GremlinQueryAPITest.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.hugegraph.unit.api.gremlin;
+
+import java.lang.reflect.Method;
+
+import org.apache.hugegraph.api.gremlin.GremlinQueryAPI;
+import org.apache.hugegraph.testutil.Assert;
+import org.apache.hugegraph.unit.BaseUnitTest;
+import org.junit.Test;
+
+public class GremlinQueryAPITest extends BaseUnitTest {
+
+    private static boolean matchBadRequest(String exClass) throws Exception {
+        Method m = GremlinQueryAPI.class.getDeclaredMethod(
+                "matchBadRequestException", String.class);
+        m.setAccessible(true);
+        return (boolean) m.invoke(null, exClass);
+    }
+
+    @Test
+    public void testMatchBadRequestExceptionWithTinkerpop() throws Exception {
+        Assert.assertTrue(matchBadRequest(
+                
"org.apache.tinkerpop.gremlin.structure.util.empty.EmptyProperty"));

Review Comment:
   ⚠️ `EmptyProperty` is not an exception type, so this test does not pin the 
reported bug. In TinkerPop 3.5.1, `EmptyProperty.value()` throws 
`Property.Exceptions.propertyDoesNotExist()` (`IllegalStateException`), which 
means this assertion can pass even if the real `Exception-Class` from Gremlin 
is still misclassified. Please assert against the actual class observed in 
#2986, and add a negative case for auth/authorization exceptions so the 
allowlist boundary is covered.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to