This is an automated email from the ASF dual-hosted git repository.

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-fury.git


The following commit(s) were added to refs/heads/main by this push:
     new a4356ebd chore(java): rename blacklist/whitelist to allowed/disallowed 
list (#1449)
a4356ebd is described below

commit a4356ebdbbc22cb6e96dad6ba12a28d3d60f5450
Author: Shawn Yang <[email protected]>
AuthorDate: Tue Apr 2 01:26:41 2024 +0800

    chore(java): rename blacklist/whitelist to allowed/disallowed list (#1449)
    
    Closes #1447
---
 docs/guide/java_object_graph_guide.md              |  2 +-
 .../graalvm_tests/native-image.properties          |  2 +-
 .../org/apache/fury/resolver/ClassResolver.java    |  2 +-
 .../{BlackList.java => DisallowedList.java}        | 26 +++++++++++-----------
 .../fury/{blacklist.txt => disallowed.txt}         |  0
 ...{BlackListTest.java => DisallowedListTest.java} | 24 +++++++++++---------
 6 files changed, 29 insertions(+), 27 deletions(-)

diff --git a/docs/guide/java_object_graph_guide.md 
b/docs/guide/java_object_graph_guide.md
index 2429932d..a4b32169 100644
--- a/docs/guide/java_object_graph_guide.md
+++ b/docs/guide/java_object_graph_guide.md
@@ -262,7 +262,7 @@ ThreadSafeFury fury = new ThreadLocalFury(classLoader -> {
 checker.allowClass("org.example.*");
 ```
 
-Fury also provided a `org.apache.fury.resolver.AllowListChecker` which is 
white/blacklist based checker to simplify
+Fury also provided a `org.apache.fury.resolver.AllowListChecker` which is 
allowed/disallowed list based checker to simplify
 the customization of class check mechanism. You can use this checker or 
implement more sophisticated checker by yourself.
 
 ### Serializer Registration
diff --git 
a/integration_tests/graalvm_tests/src/main/resources/META-INF/native-image/org.apache.fury/graalvm_tests/native-image.properties
 
b/integration_tests/graalvm_tests/src/main/resources/META-INF/native-image/org.apache.fury/graalvm_tests/native-image.properties
index 3300c941..aa544979 100644
--- 
a/integration_tests/graalvm_tests/src/main/resources/META-INF/native-image/org.apache.fury/graalvm_tests/native-image.properties
+++ 
b/integration_tests/graalvm_tests/src/main/resources/META-INF/native-image/org.apache.fury/graalvm_tests/native-image.properties
@@ -24,4 +24,4 @@ Args = -H:+ReportExceptionStackTraces \
   org.apache.fury.graalvm.ThreadSafeExample,\
   org.apache.fury.graalvm.ProxyExample,\
   org.apache.fury.graalvm.Benchmark,\
-  org.apache.fury.resolver.BlackList
+  org.apache.fury.resolver.DisallowedList
diff --git 
a/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java 
b/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java
index c4b18963..2994b928 100644
--- a/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java
+++ b/java/fury-core/src/main/java/org/apache/fury/resolver/ClassResolver.java
@@ -1137,7 +1137,7 @@ public class ClassResolver {
   }
 
   private Serializer createSerializer(Class<?> cls) {
-    BlackList.checkNotInBlackList(cls.getName());
+    DisallowedList.checkNotInDisallowedList(cls.getName());
     String msg =
         String.format(
             "%s is not registered, please check whether it's the type you want 
to serialize or "
diff --git 
a/java/fury-core/src/main/java/org/apache/fury/resolver/BlackList.java 
b/java/fury-core/src/main/java/org/apache/fury/resolver/DisallowedList.java
similarity index 64%
rename from java/fury-core/src/main/java/org/apache/fury/resolver/BlackList.java
rename to 
java/fury-core/src/main/java/org/apache/fury/resolver/DisallowedList.java
index 6231a5b3..e8f59360 100644
--- a/java/fury-core/src/main/java/org/apache/fury/resolver/BlackList.java
+++ b/java/fury-core/src/main/java/org/apache/fury/resolver/DisallowedList.java
@@ -29,39 +29,39 @@ import java.util.stream.Collectors;
 import org.apache.fury.exception.InsecureException;
 
 /** A class to record which classes are not allowed for serialization. */
-class BlackList {
-  private static final String BLACKLIST_TXT_PATH = "fury/blacklist.txt";
-  private static final Set<String> DEFAULT_BLACKLIST_SET;
+class DisallowedList {
+  private static final String DISALLOWED_LIST_TXT_PATH = "fury/disallowed.txt";
+  private static final Set<String> DEFAULT_DISALLOWED_LIST_SET;
 
   static {
     try (InputStream is =
-        
BlackList.class.getClassLoader().getResourceAsStream(BLACKLIST_TXT_PATH)) {
+        
DisallowedList.class.getClassLoader().getResourceAsStream(DISALLOWED_LIST_TXT_PATH))
 {
       if (is != null) {
-        DEFAULT_BLACKLIST_SET =
+        DEFAULT_DISALLOWED_LIST_SET =
             new BufferedReader(new InputStreamReader(is, 
StandardCharsets.UTF_8))
                 .lines()
                 .collect(Collectors.toSet());
       } else {
         throw new IllegalStateException(
-            String.format("Read blacklist %s failed", BLACKLIST_TXT_PATH));
+            String.format("Read disallowed list %s failed", 
DISALLOWED_LIST_TXT_PATH));
       }
     } catch (IOException e) {
       throw new IllegalStateException(
-          String.format("Read blacklist %s failed", BLACKLIST_TXT_PATH), e);
+          String.format("Read disallowed list %s failed", 
DISALLOWED_LIST_TXT_PATH), e);
     }
   }
 
   /**
-   * Determine whether the current Class is in the default blacklist.
+   * Determine whether the current Class is in the default disallowed list.
    *
-   * <p>Note that if Class exists in the blacklist, {@link InsecureException} 
will be thrown.
+   * <p>Note that if Class exists in the disallowed list, {@link 
InsecureException} will be thrown.
    *
    * @param clsName Class Name that needs to be judged.
-   * @throws InsecureException If the class is in the blacklist.
+   * @throws InsecureException If the class is in the disallowed list.
    */
-  static void checkNotInBlackList(String clsName) {
-    if (DEFAULT_BLACKLIST_SET.contains(clsName)) {
-      throw new InsecureException(String.format("%s hit blacklist", clsName));
+  static void checkNotInDisallowedList(String clsName) {
+    if (DEFAULT_DISALLOWED_LIST_SET.contains(clsName)) {
+      throw new InsecureException(String.format("%s hit disallowed list", 
clsName));
     }
   }
 }
diff --git a/java/fury-core/src/main/resources/fury/blacklist.txt 
b/java/fury-core/src/main/resources/fury/disallowed.txt
similarity index 100%
rename from java/fury-core/src/main/resources/fury/blacklist.txt
rename to java/fury-core/src/main/resources/fury/disallowed.txt
diff --git 
a/java/fury-core/src/test/java/org/apache/fury/resolver/BlackListTest.java 
b/java/fury-core/src/test/java/org/apache/fury/resolver/DisallowedListTest.java
similarity index 74%
rename from 
java/fury-core/src/test/java/org/apache/fury/resolver/BlackListTest.java
rename to 
java/fury-core/src/test/java/org/apache/fury/resolver/DisallowedListTest.java
index c8b36c8f..3005a8b0 100644
--- a/java/fury-core/src/test/java/org/apache/fury/resolver/BlackListTest.java
+++ 
b/java/fury-core/src/test/java/org/apache/fury/resolver/DisallowedListTest.java
@@ -28,30 +28,32 @@ import org.apache.fury.util.Platform;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-public class BlackListTest extends FuryTestBase {
+public class DisallowedListTest extends FuryTestBase {
 
   @Test
-  public void testCheckHitBlackList() {
-    // Hit the blacklist.
+  public void testCheckHitDisallowedList() {
+    // Hit the disallowed list.
     Assert.assertThrows(
         InsecureException.class,
-        () -> 
BlackList.checkNotInBlackList("java.rmi.server.UnicastRemoteObject"));
+        () -> 
DisallowedList.checkNotInDisallowedList("java.rmi.server.UnicastRemoteObject"));
     Assert.assertThrows(
         InsecureException.class,
-        () -> 
BlackList.checkNotInBlackList("com.sun.jndi.rmi.registry.BindingEnumeration"));
+        () ->
+            DisallowedList.checkNotInDisallowedList(
+                "com.sun.jndi.rmi.registry.BindingEnumeration"));
     Assert.assertThrows(
         InsecureException.class,
-        () -> 
BlackList.checkNotInBlackList(java.beans.Expression.class.getName()));
+        () -> 
DisallowedList.checkNotInDisallowedList(java.beans.Expression.class.getName()));
     Assert.assertThrows(
         InsecureException.class,
-        () -> 
BlackList.checkNotInBlackList(UnicastRemoteObject.class.getName()));
+        () -> 
DisallowedList.checkNotInDisallowedList(UnicastRemoteObject.class.getName()));
 
-    // Not in the blacklist.
-    BlackList.checkNotInBlackList("java.util.HashMap");
+    // Not in the disallowed list.
+    DisallowedList.checkNotInDisallowedList("java.util.HashMap");
   }
 
   @Test
-  public void testSerializeBlackListClass() {
+  public void testSerializeDisallowedClass() {
     Fury[] allFury = new Fury[3];
     for (int i = 0; i < 3; i++) {
       boolean requireClassRegistration = i % 2 == 0;
@@ -61,7 +63,7 @@ public class BlackListTest extends FuryTestBase {
               .requireClassRegistration(requireClassRegistration)
               .build();
       if (requireClassRegistration) {
-        // Registered or unregistered Classes should be subject to blacklist 
restrictions.
+        // Registered or unregistered Classes should be subject to disallowed 
list restrictions.
         fury.register(UnicastRemoteObject.class);
       }
       allFury[i] = fury;


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

Reply via email to