You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2020/06/12 14:41:34 UTC

[commons-jexl] branch master updated (826d3d3 -> 356e806)

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

henrib pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git.


    from 826d3d3  JEXL-333: added namespace handling to pragma processing; added test Task #JEXL-333 - Allow declaration of namespace within script
     new f30b88f  JEXL-334: changed API in sandbox to use allow/block instead of white/black Task #JEXL-334 - Remove offensive terminology from code and API
     new 356e806  JEXL-333: documentation, javadoc & checkstyle nitpicks Task #JEXL-333 - Allow declaration of namespace within script

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 RELEASE-NOTES.txt                                  |   1 +
 .../org/apache/commons/jexl3/JexlArithmetic.java   |   3 +-
 .../java/org/apache/commons/jexl3/JexlOptions.java |   2 +-
 .../org/apache/commons/jexl3/internal/Engine.java  |  27 ++-
 .../commons/jexl3/introspection/JexlSandbox.java   | 181 ++++++++++++---------
 src/site/xdoc/changes.xml                          |   3 +
 src/site/xdoc/reference/syntax.xml                 |  12 ++
 .../commons/jexl3/introspection/SandboxTest.java   |  46 +++---
 8 files changed, 161 insertions(+), 114 deletions(-)


[commons-jexl] 02/02: JEXL-333: documentation, javadoc & checkstyle nitpicks Task #JEXL-333 - Allow declaration of namespace within script

Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git

commit 356e806eb5a3c845ecf7a9339fa750c5838ba7e2
Author: henrib <he...@apache.org>
AuthorDate: Fri Jun 12 16:41:15 2020 +0200

    JEXL-333: documentation, javadoc & checkstyle nitpicks
    Task #JEXL-333 - Allow declaration of namespace within script
---
 .../org/apache/commons/jexl3/JexlArithmetic.java   |  3 ++-
 .../org/apache/commons/jexl3/internal/Engine.java  | 27 +++++++++++-----------
 src/site/xdoc/reference/syntax.xml                 | 12 ++++++++++
 3 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
index 5b1c4a2..f23b427 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlArithmetic.java
@@ -211,7 +211,8 @@ public class JexlArithmetic {
         if (ctor != null) {
             try {
                 return ctor.newInstance(astrict, bigdContext, bigdScale);
-            } catch (IllegalAccessException | IllegalArgumentException | InstantiationException | InvocationTargetException xany) {
+            } catch (IllegalAccessException | IllegalArgumentException
+                    | InstantiationException | InvocationTargetException xany) {
                 // it was worth the try
             }
         }
diff --git a/src/main/java/org/apache/commons/jexl3/internal/Engine.java b/src/main/java/org/apache/commons/jexl3/internal/Engine.java
index d458139..ec8484f 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/Engine.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/Engine.java
@@ -389,22 +389,21 @@ public class Engine extends JexlEngine {
             for(Map.Entry<String, Object> pragma : pragmas.entrySet()) {
                 String key = pragma.getKey();
                 Object value = pragma.getValue();
-                if (PRAGMA_OPTIONS.equals(key)) {
-                    // jexl.options
-                    if (value instanceof String) {
-                        String[] vs = ((String) value).split(" ");
+                if (value instanceof String) {
+                    if (PRAGMA_OPTIONS.equals(key)) {
+                        // jexl.options
+                        String[] vs = value.toString().split(" ");
                         opts.setFlags(vs);
-                    }
-                }
-                else if (key.startsWith(PRAGMA_JEXLNS) && value instanceof String) {
-                    // jexl.namespace.***
-                    String nsname = key.substring(PRAGMA_JEXLNS.length());
-                    if (nsname != null && !nsname.isEmpty()) {
-                        String nsclass = value.toString();
-                        if (ns == null) {
-                            ns = new HashMap<>(functions);
+                    } else if (key.startsWith(PRAGMA_JEXLNS)) {
+                        // jexl.namespace.***
+                        String nsname = key.substring(PRAGMA_JEXLNS.length());
+                        if (nsname != null && !nsname.isEmpty()) {
+                            String nsclass = value.toString();
+                            if (ns == null) {
+                                ns = new HashMap<>(functions);
+                            }
+                            ns.put(nsname, nsclass);
                         }
-                        ns.put(nsname, nsclass);
                     }
                 }
                 if (processor != null) {
diff --git a/src/site/xdoc/reference/syntax.xml b/src/site/xdoc/reference/syntax.xml
index 720c5a5..bdae6d7 100644
--- a/src/site/xdoc/reference/syntax.xml
+++ b/src/site/xdoc/reference/syntax.xml
@@ -135,6 +135,18 @@
                         <p>Although pragmas are statements, they are <em>not</em> evaluated at runtime; they are constants
                             associated to the script after parsing. It is expected that user code accesses the pragma map from 
                             scripts to alter some functions behavior.</p>
+                        <p>The are two built-in pragmas:</p>
+                        <p>
+                            <b>jexl.options</b> overrides the evaluation options using the option-flags syntax.
+                            <code>#pragma jexl.options "+strict -safe +lexical +lexicalShade"</code> will let the script run with
+                            the options strict being true, safe false, lexical true and lexical-shade true.</p>
+                                
+                        <p>
+                            <b>jexl.namespace.<i>ns_prefix</i></b> declares a namespace valid for the script
+                            execution lifetime, the value being the fully-qualified namespace class-name.
+                            <code>#pragma jexl.namespace.str java.lang.String</code> declare 'str' as the namespace using
+                            the String class.
+                        </p>
                     </td>
                 </tr>
                 <tr>


[commons-jexl] 01/02: JEXL-334: changed API in sandbox to use allow/block instead of white/black Task #JEXL-334 - Remove offensive terminology from code and API

Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git

commit f30b88fd670a5215ca9002c254bc2dda19f3e6cb
Author: henrib <he...@apache.org>
AuthorDate: Fri Jun 12 16:39:59 2020 +0200

    JEXL-334: changed API in sandbox to use allow/block instead of white/black
    Task #JEXL-334 - Remove offensive terminology from code and API
---
 RELEASE-NOTES.txt                                  |   1 +
 .../java/org/apache/commons/jexl3/JexlOptions.java |   2 +-
 .../commons/jexl3/introspection/JexlSandbox.java   | 181 ++++++++++++---------
 src/site/xdoc/changes.xml                          |   3 +
 .../commons/jexl3/introspection/SandboxTest.java   |  46 +++---
 5 files changed, 134 insertions(+), 99 deletions(-)

diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index ae6f5e3..0572372 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -48,6 +48,7 @@ What's new in 3.2:
 
 New Features in 3.2:
 ====================
+* JEXL-334:      Remove offensive terminology from code and API
 * JEXL-333:      Allow declaration of namespace within script
 * JEXL-317:      Support script cancellation through less invasive API
 * JEXL-307:      Variable redeclaration option
diff --git a/src/main/java/org/apache/commons/jexl3/JexlOptions.java b/src/main/java/org/apache/commons/jexl3/JexlOptions.java
index cf316e1..78e274c 100644
--- a/src/main/java/org/apache/commons/jexl3/JexlOptions.java
+++ b/src/main/java/org/apache/commons/jexl3/JexlOptions.java
@@ -393,7 +393,7 @@ public final class JexlOptions {
     }
 
     /**
-     * Sets the optional map of namespaces
+     * Sets the optional map of namespaces.
      * @param ns a namespaces map
      */
     public void setNamespaces(Map<String, Object> ns) {
diff --git a/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java b/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java
index 178e95b..8fd8198 100644
--- a/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java
+++ b/src/main/java/org/apache/commons/jexl3/introspection/JexlSandbox.java
@@ -25,34 +25,34 @@ import java.util.concurrent.ConcurrentHashMap;
 
 /**
  * A sandbox describes permissions on a class by explicitly allowing or forbidding
- * access to methods and properties through "whitelists" and "blacklists".
+ * access to methods and properties through "allowlists" and "blocklists".
  *
- * <p>A <b>whitelist</b> explicitly allows methods/properties for a class;</p>
+ * <p>A <b>allowlist</b> explicitly allows methods/properties for a class;</p>
  *
  * <ul>
- *   <li>If a whitelist is empty and thus does not contain any names,
+ *   <li>If a allowlist is empty and thus does not contain any names,
  *       all properties/methods are allowed for its class.</li>
  *   <li>If it is not empty, the only allowed properties/methods are the ones contained.</li>
  * </ul>
  *
- * <p>A <b>blacklist</b> explicitly forbids methods/properties for a class;</p>
+ * <p>A <b>blocklist</b> explicitly forbids methods/properties for a class;</p>
  *
  * <ul>
- *   <li>If a blacklist is empty and thus does not contain any names,
+ *   <li>If a blocklist is empty and thus does not contain any names,
  *       all properties/methods are forbidden for its class.</li>
  *   <li>If it is not empty, the only forbidden properties/methods are the ones contained.</li>
  * </ul>
  *
  * <p>Permissions are composed of three lists, read, write, execute, each being
- * "white" or "black":</p>
+ * "allow" or "block":</p>
  *
  * <ul>
  *   <li><b>read</b> controls readable properties </li>
  *   <li><b>write</b> controls writable properties</li>
  *   <li><b>execute</b> controls executable methods and constructor</li>
  * </ul>
- * 
- * <p>When specified, permissions - white or black lists - can be created inheritable
+ *
+ * <p>When specified, permissions - allow or block lists - can be created inheritable
  * on interfaces or classes and thus applicable to their implementations or derived
  * classes; the sandbox must be created with the 'inheritable' flag for this behavior
  * to be triggered. Note that even in this configuration, it is still possible to
@@ -75,14 +75,14 @@ public final class JexlSandbox {
      */
     private final boolean inherit;
     /**
-     * Default behavior, black or white.
+     * Default behavior, block or allow.
      */
-    private final boolean white;
+    private final boolean allow;
 
     /**
      * Creates a new default sandbox.
      * <p>In the absence of explicit permissions on a class, the
-     * sandbox is a white-box, white-listing that class for all permissions (read, write and execute).
+     * sandbox is a allow-box, allow-listing that class for all permissions (read, write and execute).
      */
     public JexlSandbox() {
         this(true, false, null);
@@ -90,24 +90,24 @@ public final class JexlSandbox {
 
     /**
      * Creates a new default sandbox.
-     * <p>A white-box considers no permissions as &quot;everything is allowed&quot; when
-     * a black-box considers no permissions as &quot;nothing is allowed&quot;.
-     * @param wb whether this sandbox is white (true) or black (false)
+     * <p>A allow-box considers no permissions as &quot;everything is allowed&quot; when
+     * a block-box considers no permissions as &quot;nothing is allowed&quot;.
+     * @param ab whether this sandbox is allow (true) or block (false)
      * if no permission is explicitly defined for a class.
      * @since 3.1
      */
-    public JexlSandbox(boolean wb) {
-        this(wb, false, null);
+    public JexlSandbox(boolean ab) {
+        this(ab, false, null);
     }
-    
+
     /**
      * Creates a sandbox.
-     * @param wb whether this sandbox is white (true) or black (false)
+     * @param ab whether this sandbox is allow (true) or block (false)
      * @param inh whether permissions on interfaces and classes are inherited (true) or not (false)
      * @since 3.2
      */
-    public JexlSandbox(boolean wb, boolean inh) {
-        this(wb, inh, null);
+    public JexlSandbox(boolean ab, boolean inh) {
+        this(ab, inh, null);
     }
 
     /**
@@ -121,26 +121,26 @@ public final class JexlSandbox {
 
     /**
      * Creates a sandbox based on an existing permissions map.
-     * @param wb whether this sandbox is white (true) or black (false)
+     * @param ab whether this sandbox is allow (true) or block (false)
      * @param map the permissions map
      * @since 3.1
      */
     @Deprecated
-    protected JexlSandbox(boolean wb, Map<String, Permissions> map) {
-        this(wb, false, map);
+    protected JexlSandbox(boolean ab, Map<String, Permissions> map) {
+        this(ab, false, map);
     }
 
     /**
      * Creates a sandbox based on an existing permissions map.
-     * @param wb whether this sandbox is white (true) or black (false)
+     * @param ab whether this sandbox is allow (true) or block (false)
      * @param inh whether permissions are inherited, default false
      * @param map the permissions map
      * @since 3.2
      */
-    protected JexlSandbox(boolean wb, boolean inh, Map<String, Permissions> map) {
-        white = wb;
+    protected JexlSandbox(boolean ab, boolean inh, Map<String, Permissions> map) {
+        allow = ab;
         inherit = inh;
-        sandbox = map != null? map : new HashMap<String, Permissions>();
+        sandbox = map != null? map : new HashMap<>();
     }
 
     /**
@@ -148,11 +148,11 @@ public final class JexlSandbox {
      */
     public JexlSandbox copy() {
         // modified concurently at runtime so...
-        Map<String, Permissions> map = new ConcurrentHashMap<String, Permissions>();
+        Map<String, Permissions> map = new ConcurrentHashMap<>();
         for (Map.Entry<String, Permissions> entry : sandbox.entrySet()) {
             map.put(entry.getKey(), entry.getValue().copy());
         }
-        return new JexlSandbox(white, inherit, map);
+        return new JexlSandbox(allow, inherit, map);
     }
 
     /**
@@ -254,7 +254,7 @@ public final class JexlSandbox {
 
         /**
          * Adds an alias to a name to this set.
-         * <p>This only has an effect on white lists.</p>
+         * <p>This only has an effect on allow lists.</p>
          *
          * @param name the name to alias
          * @param alias the alias
@@ -285,7 +285,7 @@ public final class JexlSandbox {
     /**
      * The pass-thru name set.
      */
-    private static final Names WHITE_NAMES = new Names() {
+    private static final Names ALLOW_NAMES = new Names() {
         @Override
         public boolean add(String name) {
             return false;
@@ -300,7 +300,7 @@ public final class JexlSandbox {
     /**
      * The block-all name set.
      */
-    private static final Names BLACK_NAMES = new Names() {
+    private static final Names BLOCK_NAMES = new Names() {
         @Override
         public boolean add(String name) {
             return false;
@@ -318,23 +318,23 @@ public final class JexlSandbox {
     };
 
     /**
-     * A white set of names.
+     * A allow set of names.
      */
-    public static final class WhiteSet extends Names {
+    static class AllowSet extends Names {
         /** The map of controlled names and aliases. */
         private Map<String, String> names = null;
 
         @Override
         protected Names copy() {
-            WhiteSet copy = new WhiteSet();
-            copy.names = names == null ? null : new HashMap<String, String>(names);
+            AllowSet copy = new AllowSet();
+            copy.names = names == null ? null : new HashMap<>(names);
             return copy;
         }
 
         @Override
         public boolean add(String name) {
             if (names == null) {
-                names = new HashMap<String, String>();
+                names = new HashMap<>();
             }
             return names.put(name, name) == null;
         }
@@ -342,7 +342,7 @@ public final class JexlSandbox {
         @Override
         public boolean alias(String name, String alias) {
             if (names == null) {
-                names = new HashMap<String, String>();
+                names = new HashMap<>();
             }
             return names.put(alias, name) == null;
         }
@@ -354,23 +354,23 @@ public final class JexlSandbox {
     }
 
     /**
-     * A black set of names.
+     * A block set of names.
      */
-    public static final class BlackSet extends Names {
+    static class BlockSet extends Names {
         /** The set of controlled names. */
         private Set<String> names = null;
 
         @Override
         protected Names copy() {
-            BlackSet copy = new BlackSet();
-            copy.names = names == null ? null : new HashSet<String>(names);
+            BlockSet copy = new BlockSet();
+            copy.names = names == null ? null : new HashSet<>(names);
             return copy;
         }
 
         @Override
         public boolean add(String name) {
             if (names == null) {
-                names = new HashSet<String>();
+                names = new HashSet<>();
             }
             return names.add(name);
         }
@@ -380,9 +380,21 @@ public final class JexlSandbox {
             return names != null && !names.contains(name) ? name : null;
         }
     }
-
+    
+    /**
+     * Unused.
+     */
+    @Deprecated
+    public static final class WhiteSet extends AllowSet {}
+    
+    /**
+     * Unused.
+     */
+    @Deprecated
+    public static final class BlackSet extends BlockSet {}
+    
     /**
-     * Contains the white or black lists for properties and methods for a given class.
+     * Contains the allow or block lists for properties and methods for a given class.
      */
     public static final class Permissions {
         /** Whether these permissions are inheritable, ie can be used by derived classes. */
@@ -398,15 +410,15 @@ public final class JexlSandbox {
          * Creates a new permissions instance.
          *
          * @param inherit whether these permissions are inheritable
-         * @param readFlag whether the read property list is white or black
-         * @param writeFlag whether the write property list is white or black
-         * @param executeFlag whether the method list is white of black
+         * @param readFlag whether the read property list is allow or block
+         * @param writeFlag whether the write property list is allow or block
+         * @param executeFlag whether the method list is allow of block
          */
         Permissions(boolean inherit, boolean readFlag, boolean writeFlag, boolean executeFlag) {
             this(inherit,
-                    readFlag ? new WhiteSet() : new BlackSet(),
-                    writeFlag ? new WhiteSet() : new BlackSet(),
-                    executeFlag ? new WhiteSet() : new BlackSet());
+                    readFlag ? new AllowSet() : new BlockSet(),
+                    writeFlag ? new AllowSet() : new BlockSet(),
+                    executeFlag ? new AllowSet() : new BlockSet());
         }
 
         /**
@@ -418,9 +430,9 @@ public final class JexlSandbox {
          * @param nexecute the method set
          */
         Permissions(boolean inherit, Names nread, Names nwrite, Names nexecute) {
-            this.read = nread != null ? nread : WHITE_NAMES;
-            this.write = nwrite != null ? nwrite : WHITE_NAMES;
-            this.execute = nexecute != null ? nexecute : WHITE_NAMES;
+            this.read = nread != null ? nread : ALLOW_NAMES;
+            this.write = nwrite != null ? nwrite : ALLOW_NAMES;
+            this.execute = nexecute != null ? nexecute : ALLOW_NAMES;
             this.inheritable = inherit;
         }
 
@@ -509,20 +521,20 @@ public final class JexlSandbox {
     /**
      * The pass-thru permissions.
      */
-    private static final Permissions ALL_WHITE = new Permissions(false, WHITE_NAMES, WHITE_NAMES, WHITE_NAMES);
+    private static final Permissions ALLOW_ALL = new Permissions(false, ALLOW_NAMES, ALLOW_NAMES, ALLOW_NAMES);
     /**
      * The block-all permissions.
      */
-    private static final Permissions ALL_BLACK = new Permissions(false, BLACK_NAMES, BLACK_NAMES, BLACK_NAMES);
+    private static final Permissions BLOCK_ALL = new Permissions(false, BLOCK_NAMES, BLOCK_NAMES, BLOCK_NAMES);
 
     /**
      * Creates the set of permissions for a given class.
      * <p>The sandbox inheritance property will apply to the permissions created by this method
      *
      * @param clazz the class for which these permissions apply
-     * @param readFlag whether the readable property list is white - true - or black - false -
-     * @param writeFlag whether the writable property list is white - true - or black - false -
-     * @param executeFlag whether the executable method list is white white - true - or black - false -
+     * @param readFlag whether the readable property list is allow - true - or block - false -
+     * @param writeFlag whether the writable property list is allow - true - or block - false -
+     * @param executeFlag whether the executable method list is allow allow - true - or block - false -
      * @return the set of permissions
      */
     public Permissions permissions(String clazz, boolean readFlag, boolean writeFlag, boolean executeFlag) {
@@ -534,9 +546,9 @@ public final class JexlSandbox {
      *
      * @param clazz the class for which these permissions apply
      * @param inhf whether these permissions are inheritable
-     * @param readf whether the readable property list is white - true - or black - false -
-     * @param writef whether the writable property list is white - true - or black - false -
-     * @param execf whether the executable method list is white white - true - or black - false -
+     * @param readf whether the readable property list is allow - true - or block - false -
+     * @param writef whether the writable property list is allow - true - or block - false -
+     * @param execf whether the executable method list is allow allow - true - or block - false -
      * @return the set of permissions
      */
     public Permissions permissions(String clazz, boolean inhf,  boolean readf, boolean writef, boolean execf) {
@@ -546,32 +558,51 @@ public final class JexlSandbox {
     }
 
     /**
-     * Creates a new set of permissions based on white lists for methods and properties for a given class.
+     * Creates a new set of permissions based on allow lists for methods and properties for a given class.
      * <p>The sandbox inheritance property will apply to the permissions created by this method
      * 
-     * @param clazz the whitened class name
+     * @param clazz the allowed class name
      * @return the permissions instance
      */
-    public Permissions white(String clazz) {
+    public Permissions allow(String clazz) {
         return permissions(clazz, true, true, true);
     }
+    /** 
+     * Use allow() instead.
+     * @param clazz the allowed class name
+     * @return the permissions instance
+     */
+    @Deprecated
+    public Permissions white(String clazz) {
+        return allow(clazz);
+    }
 
     /**
-     * Creates a new set of permissions based on black lists for methods and properties for a given class.
+     * Creates a new set of permissions based on block lists for methods and properties for a given class.
      * <p>The sandbox inheritance property will apply to the permissions created by this method
      *
-     * @param clazz the blackened class name
+     * @param clazz the blocked class name
      * @return the permissions instance
      */
-    public Permissions black(String clazz) {
+    public Permissions block(String clazz) {
         return permissions(clazz, false, false, false);
     }
+        
+    /** 
+     * Use block() instead.
+     * @param clazz the allowed class name
+     * @return the permissions instance
+     */
+    @Deprecated
+    public Permissions black(String clazz) {
+        return block(clazz);
+    }
 
     /**
      * Gets the set of permissions associated to a class.
      *
      * @param clazz the class name
-     * @return the defined permissions or an all-white permission instance if none were defined
+     * @return the defined permissions or an all-allow permission instance if none were defined
      */
     public Permissions get(String clazz) {
         if (inherit) {
@@ -579,7 +610,7 @@ public final class JexlSandbox {
         }
         Permissions permissions = sandbox.get(clazz);
         if (permissions == null) {
-            return white ? ALL_WHITE : ALL_BLACK;
+            return allow ? ALLOW_ALL : BLOCK_ALL;
         } else {
             return permissions;
         }
@@ -590,9 +621,9 @@ public final class JexlSandbox {
      * @param clazz the class
      * @return the permissions
      */
-    @SuppressWarnings("null") // clazz can not be null since permissions would be not null and black;
+    @SuppressWarnings("null") // clazz can not be null since permissions would be not null and block;
     public Permissions get(Class<?> clazz) {
-        Permissions permissions = clazz == null ? ALL_BLACK : sandbox.get(clazz.getName());
+        Permissions permissions = clazz == null ? BLOCK_ALL : sandbox.get(clazz.getName());
         if (permissions == null) {
             if (inherit) {
                 // find first inherited interface that defines permissions
@@ -617,15 +648,15 @@ public final class JexlSandbox {
                 }
                 // nothing was inheritable
                 if (permissions == null) {
-                    permissions = white ? ALL_WHITE : ALL_BLACK;
+                    permissions = allow ? ALLOW_ALL : BLOCK_ALL;
                 }
                 // store the info to avoid doing this costly look up
                 sandbox.put(clazz.getName(), permissions);
             } else {
-                permissions = white ? ALL_WHITE : ALL_BLACK;
+                permissions = allow ? ALLOW_ALL : BLOCK_ALL;
             }
         }
         return permissions;
     }
 
-}
+}
\ No newline at end of file
diff --git a/src/site/xdoc/changes.xml b/src/site/xdoc/changes.xml
index ef34341..4dbd90e 100644
--- a/src/site/xdoc/changes.xml
+++ b/src/site/xdoc/changes.xml
@@ -26,6 +26,9 @@
     </properties>
     <body>
         <release version="3.2" date="unreleased">
+            <action dev="henrib" type="add" issue="JEXL-334">
+                Remove offensive terminology from code and API
+            </action>
             <action dev="henrib" type="add" issue="JEXL-333">
                 Allow declaration of namespace within script
             </action>
diff --git a/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java b/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java
index 473c834..b255aac 100644
--- a/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java
+++ b/src/test/java/org/apache/commons/jexl3/introspection/SandboxTest.java
@@ -122,7 +122,7 @@ public class SandboxTest extends JexlTestCase {
     }
 
     @Test
-    public void testCtorBlack() throws Exception {
+    public void testCtorBlock() throws Exception {
         String expr = "new('" + Foo.class.getName() + "', '42')";
         JexlScript script = JEXL.createScript(expr);
         Object result;
@@ -130,7 +130,7 @@ public class SandboxTest extends JexlTestCase {
         Assert.assertEquals("42", ((Foo) result).getName());
 
         JexlSandbox sandbox = new JexlSandbox();
-        sandbox.black(Foo.class.getName()).execute("");
+        sandbox.block(Foo.class.getName()).execute("");
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).safe(false).create();
 
         script = sjexl.createScript(expr);
@@ -144,7 +144,7 @@ public class SandboxTest extends JexlTestCase {
     }
 
     @Test
-    public void testMethodBlack() throws Exception {
+    public void testMethodBlock() throws Exception {
         String expr = "foo.Quux()";
         JexlScript script = JEXL.createScript(expr, "foo");
         Foo foo = new Foo("42");
@@ -153,7 +153,7 @@ public class SandboxTest extends JexlTestCase {
         Assert.assertEquals(foo.Quux(), result);
 
         JexlSandbox sandbox = new JexlSandbox();
-        sandbox.black(Foo.class.getName()).execute("Quux");
+        sandbox.block(Foo.class.getName()).execute("Quux");
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).safe(false).create();
 
         script = sjexl.createScript(expr, "foo");
@@ -167,7 +167,7 @@ public class SandboxTest extends JexlTestCase {
     }
 
     @Test
-    public void testGetBlack() throws Exception {
+    public void testGetBlock() throws Exception {
         String expr = "foo.alias";
         JexlScript script = JEXL.createScript(expr, "foo");
         Foo foo = new Foo("42");
@@ -176,7 +176,7 @@ public class SandboxTest extends JexlTestCase {
         Assert.assertEquals(foo.alias, result);
 
         JexlSandbox sandbox = new JexlSandbox();
-        sandbox.black(Foo.class.getName()).read("alias");
+        sandbox.block(Foo.class.getName()).read("alias");
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).safe(false).create();
 
         script = sjexl.createScript(expr, "foo");
@@ -190,7 +190,7 @@ public class SandboxTest extends JexlTestCase {
     }
 
     @Test
-    public void testSetBlack() throws Exception {
+    public void testSetBlock() throws Exception {
         String expr = "foo.alias = $0";
         JexlScript script = JEXL.createScript(expr, "foo", "$0");
         Foo foo = new Foo("42");
@@ -199,7 +199,7 @@ public class SandboxTest extends JexlTestCase {
         Assert.assertEquals("43", result);
 
         JexlSandbox sandbox = new JexlSandbox();
-        sandbox.black(Foo.class.getName()).write("alias");
+        sandbox.block(Foo.class.getName()).write("alias");
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).safe(false).create();
 
         script = sjexl.createScript(expr, "foo", "$0");
@@ -220,7 +220,7 @@ public class SandboxTest extends JexlTestCase {
         Object result = null;
 
         JexlSandbox sandbox = new JexlSandbox(false);
-        sandbox.white(Foo.class.getName());
+        sandbox.allow(Foo.class.getName());
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).safe(false).create();
 
         jc.set("foo", new CantSeeMe());
@@ -237,13 +237,13 @@ public class SandboxTest extends JexlTestCase {
     }
 
     @Test
-    public void testCtorWhite() throws Exception {
+    public void testCtorAllow() throws Exception {
         String expr = "new('" + Foo.class.getName() + "', '42')";
         JexlScript script;
         Object result;
 
         JexlSandbox sandbox = new JexlSandbox();
-        sandbox.white(Foo.class.getName()).execute("");
+        sandbox.allow(Foo.class.getName()).execute("");
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).safe(false).create();
 
         script = sjexl.createScript(expr);
@@ -252,14 +252,14 @@ public class SandboxTest extends JexlTestCase {
     }
 
     @Test
-    public void testMethodWhite() throws Exception {
+    public void testMethodAllow() throws Exception {
         Foo foo = new Foo("42");
         String expr = "foo.Quux()";
         JexlScript script;
         Object result;
 
         JexlSandbox sandbox = new JexlSandbox();
-        sandbox.white(Foo.class.getName()).execute("Quux");
+        sandbox.allow(Foo.class.getName()).execute("Quux");
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).strict(true).safe(false).create();
 
         script = sjexl.createScript(expr, "foo");
@@ -295,14 +295,14 @@ public class SandboxTest extends JexlTestCase {
     }
 
     @Test
-    public void testGetWhite() throws Exception {
+    public void testGetAllow() throws Exception {
         Foo foo = new Foo("42");
         String expr = "foo.alias";
         JexlScript script;
         Object result;
 
         JexlSandbox sandbox = new JexlSandbox();
-        sandbox.white(Foo.class.getName()).read("alias");
+        sandbox.allow(Foo.class.getName()).read("alias");
         sandbox.get(Foo.class.getName()).read().alias("alias", "ALIAS");
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).safe(false).strict(true).create();
 
@@ -316,14 +316,14 @@ public class SandboxTest extends JexlTestCase {
     }
 
     @Test
-    public void testSetWhite() throws Exception {
+    public void testSetAllow() throws Exception {
         Foo foo = new Foo("42");
         String expr = "foo.alias = $0";
         JexlScript script;
         Object result;
 
         JexlSandbox sandbox = new JexlSandbox();
-        sandbox.white(Foo.class.getName()).write("alias");
+        sandbox.allow(Foo.class.getName()).write("alias");
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).safe(false).strict(true).create();
 
         script = sjexl.createScript(expr, "foo", "$0");
@@ -338,9 +338,9 @@ public class SandboxTest extends JexlTestCase {
         context.set("System", System.class);
         JexlSandbox sandbox = new JexlSandbox();
         // only allow call to currentTimeMillis (avoid exit, gc, loadLibrary, etc)
-        sandbox.white(System.class.getName()).execute("currentTimeMillis");
+        sandbox.allow(System.class.getName()).execute("currentTimeMillis");
         // can not create a new file
-        sandbox.black(java.io.File.class.getName()).execute("");
+        sandbox.block(java.io.File.class.getName()).execute("");
 
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).safe(false).strict(true).create();
 
@@ -384,7 +384,7 @@ public class SandboxTest extends JexlTestCase {
         JexlContext ctxt = null;
         List<String> foo = new ArrayList<String>();
         JexlSandbox sandbox = new JexlSandbox(false, true);
-        sandbox.white(java.util.List.class.getName());
+        sandbox.allow(java.util.List.class.getName());
         
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).safe(false).strict(true).create();
         JexlScript method = sjexl.createScript("foo.add(y)", "foo", "y");
@@ -437,9 +437,9 @@ public class SandboxTest extends JexlTestCase {
         JexlContext ctxt = null;
         Operation2 foo = new Operation2(12);
         JexlSandbox sandbox = new JexlSandbox(false, true);
-        sandbox.white(Operation.class.getName());
-        sandbox.black(Operation.class.getName()).execute("nonCallable");
-        //sandbox.black(Foo.class.getName()).execute();
+        sandbox.allow(Operation.class.getName());
+        sandbox.block(Operation.class.getName()).execute("nonCallable");
+        //sandbox.block(Foo.class.getName()).execute();
         JexlEngine sjexl = new JexlBuilder().sandbox(sandbox).safe(false).strict(true).create();
         JexlScript someOp = sjexl.createScript("foo.someOp(y)", "foo", "y");
         result = someOp.execute(ctxt, foo, 30);