You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "flyrain (via GitHub)" <gi...@apache.org> on 2025/09/02 00:38:23 UTC

[PR] Core: Prevent AIOOBE for negative policy codes in PredefinedPolicyType [polaris]

flyrain opened a new pull request, #2486:
URL: https://github.com/apache/polaris/pull/2486

   (no comment)


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Core: Prevent AIOOBE for negative policy codes in PredefinedPolicyType [polaris]

Posted by "adutra (via GitHub)" <gi...@apache.org>.
adutra commented on code in PR #2486:
URL: https://github.com/apache/polaris/pull/2486#discussion_r2315391400


##########
polaris-core/src/test/java/org/apache/polaris/core/policy/PredefinedPolicyTypesTest.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * 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.polaris.core.policy;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.Test;
+
+class PredefinedPolicyTypesTest {
+
+  @Test
+  void fromCodeReturnsNullForNegative() {

Review Comment:
   nit: these tests could be combined into a parameterized test (but they are fine as is).



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Core: Prevent AIOOBE for negative policy codes in PredefinedPolicyType [polaris]

Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #2486:
URL: https://github.com/apache/polaris/pull/2486#discussion_r2319855085


##########
polaris-core/src/test/java/org/apache/polaris/core/policy/PolicyTypeTest.java:
##########
@@ -53,4 +56,14 @@ public void testPredefinedPolicyTypeFromName(int code, String name, boolean isIn
     Assertions.assertThat(policyType.getName()).isEqualTo(name);
     Assertions.assertThat(policyType.isInheritable()).isEqualTo(isInheritable);
   }
+
+  @Test
+  void fromCodeReturnsNullForNegative() {
+    assertThat(PolicyType.fromCode(-1)).isNull();
+  }
+
+  @Test
+  void fromNameReturnsNullForUnknown() {
+    assertThat(PolicyType.fromName("__unknown__")).isNull();
+  }

Review Comment:
   Not necessarily related,  but good to have :)



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Core: Prevent AIOOBE for negative policy codes in PredefinedPolicyType [polaris]

Posted by "singhpk234 (via GitHub)" <gi...@apache.org>.
singhpk234 commented on code in PR #2486:
URL: https://github.com/apache/polaris/pull/2486#discussion_r2319729182


##########
polaris-core/src/test/java/org/apache/polaris/core/policy/PolicyTypeTest.java:
##########
@@ -53,4 +56,14 @@ public void testPredefinedPolicyTypeFromName(int code, String name, boolean isIn
     Assertions.assertThat(policyType.getName()).isEqualTo(name);
     Assertions.assertThat(policyType.isInheritable()).isEqualTo(isInheritable);
   }
+
+  @Test
+  void fromCodeReturnsNullForNegative() {
+    assertThat(PolicyType.fromCode(-1)).isNull();
+  }
+
+  @Test
+  void fromNameReturnsNullForUnknown() {
+    assertThat(PolicyType.fromName("__unknown__")).isNull();
+  }

Review Comment:
   is this test required for this fix ?



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Core: Prevent AIOOBE for negative policy codes in PredefinedPolicyType [polaris]

Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain merged PR #2486:
URL: https://github.com/apache/polaris/pull/2486


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Core: Prevent AIOOBE for negative policy codes in PredefinedPolicyType [polaris]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on code in PR #2486:
URL: https://github.com/apache/polaris/pull/2486#discussion_r2316244541


##########
polaris-core/src/test/java/org/apache/polaris/core/policy/PredefinedPolicyTypesTest.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * 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.polaris.core.policy;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.jupiter.api.Test;
+
+class PredefinedPolicyTypesTest {
+
+  @Test
+  void fromCodeReturnsNullForNegative() {

Review Comment:
   Could we merge this test file with https://github.com/apache/polaris/blob/main/polaris-core/src/test/java/org/apache/polaris/core/policy/PolicyTypeTest.java ? The existing one is parametrized.



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org