Improved: Rename some connoted words like blacklist and whitelist (OFBIZ-12168)

Renames respectively blacklist and whitelist to denylist and allowlist in
several places.

There are still a lot of master word which can be replaced by main, but not in
contexts where slave is also used. I'll discuss that on dev ML again...

Provides the migrateOldOrderBlacklistAndOldOrderBlacklistType service to migrate
records from OrderBlacklist and OrderBlacklistType entities to new OrderDenylist
and OrderDenylistType entities
This commit is contained in:
Jacques Le Roux
2021-02-09 09:55:39 +01:00
parent d61e0e7558
commit e7b3169d03
13 changed files with 173 additions and 75 deletions
@@ -36,14 +36,14 @@ import java.util.regex.Pattern;
* only authorized class can be read from it.
*/
public final class SafeObjectInputStream extends ObjectInputStream {
private static final String[] DEFAULT_WHITELIST_PATTERN = {
private static final String[] DEFAULT_ALLOWLIST_PATTERN = {
"byte\\[\\]", "foo", "SerializationInjector",
"\\[Z", "\\[B", "\\[S", "\\[I", "\\[J", "\\[F", "\\[D", "\\[C",
"java..*", "sun.util.calendar..*", "org.apache.ofbiz..*",
"org.codehaus.groovy.runtime.GStringImpl", "groovy.lang.GString"};
/** The regular expression used to match serialized types. */
private final Pattern whitelistPattern;
private final Pattern allowlistPattern;
/**
* Instantiates a safe object input stream.
@@ -53,8 +53,8 @@ public final class SafeObjectInputStream extends ObjectInputStream {
public SafeObjectInputStream(InputStream in) throws IOException {
super(in);
String safeObjectsProp = getPropertyValue("SafeObjectInputStream", "ListOfSafeObjectsForInputStream", "");
String[] whitelist = safeObjectsProp.isEmpty() ? DEFAULT_WHITELIST_PATTERN : safeObjectsProp.split(",");
whitelistPattern = Arrays.stream(whitelist)
String[] allowlist = safeObjectsProp.isEmpty() ? DEFAULT_ALLOWLIST_PATTERN : safeObjectsProp.split(",");
allowlistPattern = Arrays.stream(allowlist)
.map(String::trim)
.filter(str -> !str.isEmpty())
.collect(collectingAndThen(joining("|", "(", ")"), Pattern::compile));
@@ -63,7 +63,7 @@ public final class SafeObjectInputStream extends ObjectInputStream {
@Override
protected Class<?> resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException {
String className = classDesc.getName();
// BlackList exploits; eg: don't allow RMI here
// DenyList exploits; eg: don't allow RMI here
if (className.contains("java.rmi.server")) {
Debug.logWarning("***Incompatible class***: "
+ classDesc.getName()
@@ -71,7 +71,7 @@ public final class SafeObjectInputStream extends ObjectInputStream {
"SafeObjectInputStream");
return null;
}
if (!whitelistPattern.matcher(className).find()) {
if (!allowlistPattern.matcher(className).find()) {
// DiskFileItem, FileItemHeadersImpl are not serializable.
if (className.contains("org.apache.commons.fileupload")) {
return null;