Skip to content

Commit

Permalink
Replacing the exclusionary word whitelist that won't impact the compa…
Browse files Browse the repository at this point in the history
…tibility.

Signed-off-by: Andreas Pre <[email protected]>
  • Loading branch information
aponb committed Jan 12, 2022
1 parent 0887ac6 commit 68f09ef
Show file tree
Hide file tree
Showing 58 changed files with 308 additions and 308 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* a thread must have {@code modifyThread} to even terminate its own pool, leaving
* system threads unprotected.
* </ul>
* This class throws exception on {@code exitVM} calls, and provides a whitelist where calls
* This class throws exception on {@code exitVM} calls, and provides an allowlist where calls
* from exit are allowed.
* <p>
* Additionally it enforces threadgroup security with the following rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@

public class AnalysisPainlessExtension implements PainlessExtension {

private static final Whitelist WHITELIST = WhitelistLoader.loadFromResourceFiles(
private static final Whitelist ALLOWLIST = WhitelistLoader.loadFromResourceFiles(
AnalysisPainlessExtension.class,
"painless_whitelist.txt"
);

@Override
public Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists() {
return Collections.singletonMap(AnalysisPredicateScript.CONTEXT, Collections.singletonList(WHITELIST));
return Collections.singletonMap(AnalysisPredicateScript.CONTEXT, Collections.singletonList(ALLOWLIST));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@

public class ProcessorsWhitelistExtension implements PainlessExtension {

private static final Whitelist WHITELIST = WhitelistLoader.loadFromResourceFiles(
private static final Whitelist ALLOWLIST = WhitelistLoader.loadFromResourceFiles(
ProcessorsWhitelistExtension.class,
"processors_whitelist.txt"
);

@Override
public Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists() {
return Collections.singletonMap(IngestScript.CONTEXT, Collections.singletonList(WHITELIST));
return Collections.singletonMap(IngestScript.CONTEXT, Collections.singletonList(ALLOWLIST));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# under the License.
#

# This file contains a whitelist of static processor methods that can be accessed from painless
# This file contains a allowlist of static processor methods that can be accessed from painless

class org.opensearch.ingest.common.Processors {
long bytes(String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@
import java.util.Objects;

/**
* Whitelist contains data structures designed to be used to generate a whitelist of Java classes,
* Allowlist contains data structures designed to be used to generate an allowlist of Java classes,
* constructors, methods, and fields that can be used within a Painless script at both compile-time
* and run-time.
*
* A whitelist consists of several pieces with {@link WhitelistClass}s as the top level. Each
* A Allowlist consists of several pieces with {@link WhitelistClass}s as the top level. Each
* {@link WhitelistClass} will contain zero-to-many {@link WhitelistConstructor}s, {@link WhitelistMethod}s, and
* {@link WhitelistField}s which are what will be available with a Painless script. See each individual
* whitelist object for more detail.
* allowlist object for more detail.
*/
public final class Whitelist {

private static final String[] BASE_WHITELIST_FILES = new String[] {
private static final String[] BASE_ALLOWLIST_FILES = new String[] {
"org.opensearch.txt",
"java.lang.txt",
"java.math.txt",
Expand All @@ -66,37 +66,37 @@ public final class Whitelist {
"java.util.stream.txt" };

public static final List<Whitelist> BASE_WHITELISTS = Collections.singletonList(
WhitelistLoader.loadFromResourceFiles(Whitelist.class, WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS, BASE_WHITELIST_FILES)
WhitelistLoader.loadFromResourceFiles(Whitelist.class, WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS, BASE_ALLOWLIST_FILES)
);

/** The {@link ClassLoader} used to look up the whitelisted Java classes, constructors, methods, and fields. */
/** The {@link ClassLoader} used to look up the allowlisted Java classes, constructors, methods, and fields. */
public final ClassLoader classLoader;

/** The {@link List} of all the whitelisted Painless classes. */
/** The {@link List} of all the allowlisted Painless classes. */
public final List<WhitelistClass> whitelistClasses;

/** The {@link List} of all the whitelisted static Painless methods. */
/** The {@link List} of all the allowlisted static Painless methods. */
public final List<WhitelistMethod> whitelistImportedMethods;

/** The {@link List} of all the whitelisted Painless class bindings. */
/** The {@link List} of all the allowlisted Painless class bindings. */
public final List<WhitelistClassBinding> whitelistClassBindings;

/** The {@link List} of all the whitelisted Painless instance bindings. */
/** The {@link List} of all the allowlisted Painless instance bindings. */
public final List<WhitelistInstanceBinding> whitelistInstanceBindings;

/** Standard constructor. All values must be not {@code null}. */
public Whitelist(
ClassLoader classLoader,
List<WhitelistClass> whitelistClasses,
List<WhitelistMethod> whitelistImportedMethods,
List<WhitelistClassBinding> whitelistClassBindings,
List<WhitelistInstanceBinding> whitelistInstanceBindings
List<WhitelistClass> allowlistClasses,
List<WhitelistMethod> allowlistImportedMethods,
List<WhitelistClassBinding> allowlistClassBindings,
List<WhitelistInstanceBinding> allowlistInstanceBindings
) {

this.classLoader = Objects.requireNonNull(classLoader);
this.whitelistClasses = Collections.unmodifiableList(Objects.requireNonNull(whitelistClasses));
this.whitelistImportedMethods = Collections.unmodifiableList(Objects.requireNonNull(whitelistImportedMethods));
this.whitelistClassBindings = Collections.unmodifiableList(Objects.requireNonNull(whitelistClassBindings));
this.whitelistInstanceBindings = Collections.unmodifiableList(Objects.requireNonNull(whitelistInstanceBindings));
this.whitelistClasses = Collections.unmodifiableList(Objects.requireNonNull(allowlistClasses));
this.whitelistImportedMethods = Collections.unmodifiableList(Objects.requireNonNull(allowlistImportedMethods));
this.whitelistClassBindings = Collections.unmodifiableList(Objects.requireNonNull(allowlistClassBindings));
this.whitelistInstanceBindings = Collections.unmodifiableList(Objects.requireNonNull(allowlistInstanceBindings));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
/**
* Class represents the equivalent of a Java class in Painless complete with super classes,
* constructors, methods, and fields. There must be a one-to-one mapping of class names to Java
* classes. Though, since multiple whitelists may be combined into a single whitelist for a
* classes. Though, since multiple allowlists may be combined into a single allowlist for a
* specific context, as long as multiple classes representing the same Java class have the same
* class name and have legal constructor/method overloading they can be merged together.
*
Expand All @@ -51,7 +51,7 @@
* number of parameters, and multiples methods with the same name are allowed for a single class
* as long as they have the same return type and a different number of parameters.
*
* Classes will automatically extend other whitelisted classes if the Java class they represent is a
* Classes will automatically extend other allowlisted classes if the Java class they represent is a
* subclass of other classes including Java interfaces.
*/
public final class WhitelistClass {
Expand All @@ -62,13 +62,13 @@ public final class WhitelistClass {
/** The Java class name this class represents. */
public final String javaClassName;

/** The {@link List} of whitelisted ({@link WhitelistConstructor}s) available to this class. */
/** The {@link List} of allowlisted ({@link WhitelistConstructor}s) available to this class. */
public final List<WhitelistConstructor> whitelistConstructors;

/** The {@link List} of whitelisted ({@link WhitelistMethod}s) available to this class. */
/** The {@link List} of allowlisted ({@link WhitelistMethod}s) available to this class. */
public final List<WhitelistMethod> whitelistMethods;

/** The {@link List} of whitelisted ({@link WhitelistField}s) available to this class. */
/** The {@link List} of allowlisted ({@link WhitelistField}s) available to this class. */
public final List<WhitelistField> whitelistFields;

/** The {@link Map} of annotations for this class. */
Expand All @@ -78,18 +78,18 @@ public final class WhitelistClass {
public WhitelistClass(
String origin,
String javaClassName,
List<WhitelistConstructor> whitelistConstructors,
List<WhitelistMethod> whitelistMethods,
List<WhitelistField> whitelistFields,
List<WhitelistConstructor> allowlistConstructors,
List<WhitelistMethod> allowlistMethods,
List<WhitelistField> allowlistFields,
List<Object> painlessAnnotations
) {

this.origin = Objects.requireNonNull(origin);
this.javaClassName = Objects.requireNonNull(javaClassName);

this.whitelistConstructors = Collections.unmodifiableList(Objects.requireNonNull(whitelistConstructors));
this.whitelistMethods = Collections.unmodifiableList(Objects.requireNonNull(whitelistMethods));
this.whitelistFields = Collections.unmodifiableList(Objects.requireNonNull(whitelistFields));
this.whitelistConstructors = Collections.unmodifiableList(Objects.requireNonNull(allowlistConstructors));
this.whitelistMethods = Collections.unmodifiableList(Objects.requireNonNull(allowlistMethods));
this.whitelistFields = Collections.unmodifiableList(Objects.requireNonNull(allowlistFields));

if (painlessAnnotations.isEmpty()) {
this.painlessAnnotations = Collections.emptyMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
*/
public class WhitelistClassBinding {

/** Information about where this constructor was whitelisted from. */
/** Information about where this constructor was allowlisted from. */
public final String origin;

/** The Java class name this class binding targets. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
import java.util.stream.Collectors;

/**
* Constructor represents the equivalent of a Java constructor available as a whitelisted class
* Constructor represents the equivalent of a Java constructor available as a allowlisted class
* constructor within Painless. Constructors for Painless classes may be accessed exactly as
* constructors for Java classes are using the 'new' keyword. Painless classes may have multiple
* constructors as long as they comply with arity overloading described for {@link WhitelistClass}.
*/
public final class WhitelistConstructor {

/** Information about where this constructor was whitelisted from. */
/** Information about where this constructor was allowlisted from. */
public final String origin;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
import java.util.stream.Collectors;

/**
* Field represents the equivalent of a Java field available as a whitelisted class field
* Field represents the equivalent of a Java field available as an allowlisted class field
* within Painless. Fields for Painless classes may be accessed exactly as fields for Java classes
* are using the '.' operator on an existing class variable/field.
*/
public class WhitelistField {

/** Information about where this method was whitelisted from. */
/** Information about where this method was allowlisted from. */
public final String origin;

/** The field name used to look up the field reflection object. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*/
public class WhitelistInstanceBinding {

/** Information about where this constructor was whitelisted from. */
/** Information about where this constructor was allowlisted from. */
public final String origin;

/** The Java instance this instance binding targets. */
Expand Down
Loading

0 comments on commit 68f09ef

Please sign in to comment.