Replace 'whitelist' terminology in Java API (#3350)

Signed-off-by: Tianli Feng <ftianli@amazon.com>
This commit is contained in:
Tianli Feng 2022-05-17 13:34:05 -07:00 committed by GitHub
parent 00c0bf2dd9
commit 8f8909fd54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
62 changed files with 293 additions and 293 deletions

View File

@ -529,7 +529,7 @@ updates:
package-ecosystem: gradle
schedule:
interval: weekly
- directory: /plugins/examples/painless-whitelist/
- directory: /plugins/examples/painless-allowlist/
open-pull-requests-limit: 1
package-ecosystem: gradle
schedule:

View File

@ -103,7 +103,7 @@ configure([
project(":example-plugins:custom-settings"),
project(":example-plugins:custom-significance-heuristic"),
project(":example-plugins:custom-suggester"),
project(":example-plugins:painless-whitelist"),
project(":example-plugins:painless-allowlist"),
project(":example-plugins:rescore"),
project(":example-plugins:rest-handler"),
project(":example-plugins:script-expert-scoring"),

View File

@ -33,8 +33,8 @@
package org.opensearch.analysis.common;
import org.opensearch.painless.spi.PainlessExtension;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.WhitelistLoader;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.spi.AllowlistLoader;
import org.opensearch.script.ScriptContext;
import java.util.Collections;
@ -43,13 +43,13 @@ import java.util.Map;
public class AnalysisPainlessExtension implements PainlessExtension {
private static final Whitelist ALLOWLIST = WhitelistLoader.loadFromResourceFiles(
private static final Allowlist ALLOWLIST = AllowlistLoader.loadFromResourceFiles(
AnalysisPainlessExtension.class,
"painless_whitelist.txt"
"painless_allowlist.txt"
);
@Override
public Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists() {
public Map<ScriptContext<?>, List<Allowlist>> getContextAllowlists() {
return Collections.singletonMap(AnalysisPredicateScript.CONTEXT, Collections.singletonList(ALLOWLIST));
}
}

View File

@ -33,8 +33,8 @@
package org.opensearch.ingest.common;
import org.opensearch.painless.spi.PainlessExtension;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.WhitelistLoader;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.spi.AllowlistLoader;
import org.opensearch.script.IngestScript;
import org.opensearch.script.ScriptContext;
@ -42,15 +42,15 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
public class ProcessorsWhitelistExtension implements PainlessExtension {
public class ProcessorsAllowlistExtension implements PainlessExtension {
private static final Whitelist ALLOWLIST = WhitelistLoader.loadFromResourceFiles(
ProcessorsWhitelistExtension.class,
"processors_whitelist.txt"
private static final Allowlist ALLOWLIST = AllowlistLoader.loadFromResourceFiles(
ProcessorsAllowlistExtension.class,
"processors_allowlist.txt"
);
@Override
public Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists() {
public Map<ScriptContext<?>, List<Allowlist>> getContextAllowlists() {
return Collections.singletonMap(IngestScript.CONTEXT, Collections.singletonList(ALLOWLIST));
}
}

View File

@ -1 +1 @@
org.opensearch.ingest.common.ProcessorsWhitelistExtension
org.opensearch.ingest.common.ProcessorsAllowlistExtension

View File

@ -32,7 +32,7 @@
package org.opensearch.painless.spi;
import org.opensearch.painless.spi.annotation.WhitelistAnnotationParser;
import org.opensearch.painless.spi.annotation.AllowlistAnnotationParser;
import java.util.Collections;
import java.util.List;
@ -43,12 +43,12 @@ import java.util.Objects;
* constructors, methods, and fields that can be used within a Painless script at both compile-time
* and run-time.
*
* 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
* A Allowlist consists of several pieces with {@link AllowlistClass}s as the top level. Each
* {@link AllowlistClass} will contain zero-to-many {@link AllowlistConstructor}s, {@link AllowlistMethod}s, and
* {@link AllowlistField}s which are what will be available with a Painless script. See each individual
* allowlist object for more detail.
*/
public final class Whitelist {
public final class Allowlist {
private static final String[] BASE_ALLOWLIST_FILES = new String[] {
"org.opensearch.txt",
@ -65,38 +65,38 @@ public final class Whitelist {
"java.util.regex.txt",
"java.util.stream.txt" };
public static final List<Whitelist> BASE_WHITELISTS = Collections.singletonList(
WhitelistLoader.loadFromResourceFiles(Whitelist.class, WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS, BASE_ALLOWLIST_FILES)
public static final List<Allowlist> BASE_ALLOWLISTS = Collections.singletonList(
AllowlistLoader.loadFromResourceFiles(Allowlist.class, AllowlistAnnotationParser.BASE_ANNOTATION_PARSERS, BASE_ALLOWLIST_FILES)
);
/** 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 allowlisted Painless classes. */
public final List<WhitelistClass> whitelistClasses;
public final List<AllowlistClass> allowlistClasses;
/** The {@link List} of all the allowlisted static Painless methods. */
public final List<WhitelistMethod> whitelistImportedMethods;
public final List<AllowlistMethod> allowlistImportedMethods;
/** The {@link List} of all the allowlisted Painless class bindings. */
public final List<WhitelistClassBinding> whitelistClassBindings;
public final List<AllowlistClassBinding> allowlistClassBindings;
/** The {@link List} of all the allowlisted Painless instance bindings. */
public final List<WhitelistInstanceBinding> whitelistInstanceBindings;
public final List<AllowlistInstanceBinding> allowlistInstanceBindings;
/** Standard constructor. All values must be not {@code null}. */
public Whitelist(
public Allowlist(
ClassLoader classLoader,
List<WhitelistClass> allowlistClasses,
List<WhitelistMethod> allowlistImportedMethods,
List<WhitelistClassBinding> allowlistClassBindings,
List<WhitelistInstanceBinding> allowlistInstanceBindings
List<AllowlistClass> allowlistClasses,
List<AllowlistMethod> allowlistImportedMethods,
List<AllowlistClassBinding> allowlistClassBindings,
List<AllowlistInstanceBinding> allowlistInstanceBindings
) {
this.classLoader = Objects.requireNonNull(classLoader);
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));
this.allowlistClasses = Collections.unmodifiableList(Objects.requireNonNull(allowlistClasses));
this.allowlistImportedMethods = Collections.unmodifiableList(Objects.requireNonNull(allowlistImportedMethods));
this.allowlistClassBindings = Collections.unmodifiableList(Objects.requireNonNull(allowlistClassBindings));
this.allowlistInstanceBindings = Collections.unmodifiableList(Objects.requireNonNull(allowlistInstanceBindings));
}
}

View File

@ -54,42 +54,42 @@ import java.util.stream.Collectors;
* 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 {
public final class AllowlistClass {
/** Information about where this class was white-listed from. */
/** Information about where this class was allow-listed from. */
public final String origin;
/** The Java class name this class represents. */
public final String javaClassName;
/** The {@link List} of allowlisted ({@link WhitelistConstructor}s) available to this class. */
public final List<WhitelistConstructor> whitelistConstructors;
/** The {@link List} of allowlisted ({@link AllowlistConstructor}s) available to this class. */
public final List<AllowlistConstructor> allowlistConstructors;
/** The {@link List} of allowlisted ({@link WhitelistMethod}s) available to this class. */
public final List<WhitelistMethod> whitelistMethods;
/** The {@link List} of allowlisted ({@link AllowlistMethod}s) available to this class. */
public final List<AllowlistMethod> allowlistMethods;
/** The {@link List} of allowlisted ({@link WhitelistField}s) available to this class. */
public final List<WhitelistField> whitelistFields;
/** The {@link List} of allowlisted ({@link AllowlistField}s) available to this class. */
public final List<AllowlistField> allowlistFields;
/** The {@link Map} of annotations for this class. */
public final Map<Class<?>, Object> painlessAnnotations;
/** Standard constructor. All values must be not {@code null}. */
public WhitelistClass(
public AllowlistClass(
String origin,
String javaClassName,
List<WhitelistConstructor> allowlistConstructors,
List<WhitelistMethod> allowlistMethods,
List<WhitelistField> allowlistFields,
List<AllowlistConstructor> allowlistConstructors,
List<AllowlistMethod> allowlistMethods,
List<AllowlistField> allowlistFields,
List<Object> painlessAnnotations
) {
this.origin = Objects.requireNonNull(origin);
this.javaClassName = Objects.requireNonNull(javaClassName);
this.whitelistConstructors = Collections.unmodifiableList(Objects.requireNonNull(allowlistConstructors));
this.whitelistMethods = Collections.unmodifiableList(Objects.requireNonNull(allowlistMethods));
this.whitelistFields = Collections.unmodifiableList(Objects.requireNonNull(allowlistFields));
this.allowlistConstructors = Collections.unmodifiableList(Objects.requireNonNull(allowlistConstructors));
this.allowlistMethods = Collections.unmodifiableList(Objects.requireNonNull(allowlistMethods));
this.allowlistFields = Collections.unmodifiableList(Objects.requireNonNull(allowlistFields));
if (painlessAnnotations.isEmpty()) {
this.painlessAnnotations = Collections.emptyMap();

View File

@ -48,7 +48,7 @@ import java.util.stream.Collectors;
* arguments passed into the constructor. The method for a binding class will be called each time
* the binding method is called and may use the previously stored state.
*/
public class WhitelistClassBinding {
public class AllowlistClassBinding {
/** Information about where this constructor was allowlisted from. */
public final String origin;
@ -72,7 +72,7 @@ public class WhitelistClassBinding {
public final Map<Class<?>, Object> painlessAnnotations;
/** Standard constructor. All values must be not {@code null}. */
public WhitelistClassBinding(
public AllowlistClassBinding(
String origin,
String targetJavaClassName,
String methodName,

View File

@ -43,9 +43,9 @@ import java.util.stream.Collectors;
* 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}.
* constructors as long as they comply with arity overloading described for {@link AllowlistClass}.
*/
public final class WhitelistConstructor {
public final class AllowlistConstructor {
/** Information about where this constructor was allowlisted from. */
public final String origin;
@ -60,7 +60,7 @@ public final class WhitelistConstructor {
public final Map<Class<?>, Object> painlessAnnotations;
/** Standard constructor. All values must be not {@code null}. */
public WhitelistConstructor(String origin, List<String> canonicalTypeNameParameters, List<Object> painlessAnnotations) {
public AllowlistConstructor(String origin, List<String> canonicalTypeNameParameters, List<Object> painlessAnnotations) {
this.origin = Objects.requireNonNull(origin);
this.canonicalTypeNameParameters = Collections.unmodifiableList(Objects.requireNonNull(canonicalTypeNameParameters));

View File

@ -44,7 +44,7 @@ import java.util.stream.Collectors;
* 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 {
public class AllowlistField {
/** Information about where this method was allowlisted from. */
public final String origin;
@ -59,7 +59,7 @@ public class WhitelistField {
public final Map<Class<?>, Object> painlessAnnotations;
/** Standard constructor. All values must be not {@code null}. */
public WhitelistField(String origin, String fieldName, String canonicalTypeNameParameter, List<Object> painlessAnnotations) {
public AllowlistField(String origin, String fieldName, String canonicalTypeNameParameter, List<Object> painlessAnnotations) {
this.origin = Objects.requireNonNull(origin);
this.fieldName = Objects.requireNonNull(fieldName);
this.canonicalTypeNameParameter = Objects.requireNonNull(canonicalTypeNameParameter);

View File

@ -44,7 +44,7 @@ import java.util.stream.Collectors;
* exactly one public method name. The canonical type name parameters provided must match those of the
* method. The method for an instance binding will target the specified Java instance.
*/
public class WhitelistInstanceBinding {
public class AllowlistInstanceBinding {
/** Information about where this constructor was allowlisted from. */
public final String origin;
@ -68,7 +68,7 @@ public class WhitelistInstanceBinding {
public final Map<Class<?>, Object> painlessAnnotations;
/** Standard constructor. All values must be not {@code null}. */
public WhitelistInstanceBinding(
public AllowlistInstanceBinding(
String origin,
Object targetInstance,
String methodName,

View File

@ -32,7 +32,7 @@
package org.opensearch.painless.spi;
import org.opensearch.painless.spi.annotation.WhitelistAnnotationParser;
import org.opensearch.painless.spi.annotation.AllowlistAnnotationParser;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
@ -49,20 +49,20 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** Loads and creates a {@link Whitelist} from one to many text files. */
public final class WhitelistLoader {
/** Loads and creates a {@link Allowlist} from one to many text files. */
public final class AllowlistLoader {
/**
* Loads and creates a {@link Whitelist} from one to many text files using only the base annotation parsers.
* Loads and creates a {@link Allowlist} from one to many text files using only the base annotation parsers.
* See {@link #loadFromResourceFiles(Class, Map, String...)} for information on how to structure an allowlist
* text file.
*/
public static Whitelist loadFromResourceFiles(Class<?> resource, String... filepaths) {
return loadFromResourceFiles(resource, WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS, filepaths);
public static Allowlist loadFromResourceFiles(Class<?> resource, String... filepaths) {
return loadFromResourceFiles(resource, AllowlistAnnotationParser.BASE_ANNOTATION_PARSERS, filepaths);
}
/**
* Loads and creates a {@link Whitelist} from one to many text files. The file paths are passed in as an array of
* Loads and creates a {@link Allowlist} from one to many text files. The file paths are passed in as an array of
* {@link String}s with a single {@link Class} to be be used to load the resources where each {@link String}
* is the path of a single text file. The {@link Class}'s {@link ClassLoader} will be used to lookup the Java
* reflection objects for each individual {@link Class}, {@link Constructor}, {@link Method}, and {@link Field}
@ -163,10 +163,10 @@ public final class WhitelistLoader {
* }
* }
*/
public static Whitelist loadFromResourceFiles(Class<?> resource, Map<String, WhitelistAnnotationParser> parsers, String... filepaths) {
List<WhitelistClass> allowlistClasses = new ArrayList<>();
List<WhitelistMethod> allowlistStatics = new ArrayList<>();
List<WhitelistClassBinding> allowlistClassBindings = new ArrayList<>();
public static Allowlist loadFromResourceFiles(Class<?> resource, Map<String, AllowlistAnnotationParser> parsers, String... filepaths) {
List<AllowlistClass> allowlistClasses = new ArrayList<>();
List<AllowlistMethod> allowlistStatics = new ArrayList<>();
List<AllowlistClassBinding> allowlistClassBindings = new ArrayList<>();
// Execute a single pass through the allowlist text files. This will gather all the
// constructors, methods, augmented methods, and fields for each allowlisted class.
@ -183,9 +183,9 @@ public final class WhitelistLoader {
String parseType = null;
String allowlistClassOrigin = null;
String javaClassName = null;
List<WhitelistConstructor> allowlistConstructors = null;
List<WhitelistMethod> allowlistMethods = null;
List<WhitelistField> allowlistFields = null;
List<AllowlistConstructor> allowlistConstructors = null;
List<AllowlistMethod> allowlistMethods = null;
List<AllowlistField> allowlistFields = null;
List<Object> classAnnotations = null;
while ((line = reader.readLine()) != null) {
@ -254,7 +254,7 @@ public final class WhitelistLoader {
// augmented methods, and fields, and add it to the list of allowlisted classes.
if ("class".equals(parseType)) {
allowlistClasses.add(
new WhitelistClass(
new AllowlistClass(
allowlistClassOrigin,
javaClassName,
allowlistConstructors,
@ -350,7 +350,7 @@ public final class WhitelistLoader {
// Add a static import method or binding depending on the static import type.
if ("from_class".equals(staticImportType)) {
allowlistStatics.add(
new WhitelistMethod(
new AllowlistMethod(
origin,
targetJavaClassName,
methodName,
@ -361,7 +361,7 @@ public final class WhitelistLoader {
);
} else if ("bound_to".equals(staticImportType)) {
allowlistClassBindings.add(
new WhitelistClassBinding(
new AllowlistClassBinding(
origin,
targetJavaClassName,
methodName,
@ -413,7 +413,7 @@ public final class WhitelistLoader {
: parseAllowlistAnnotations(parsers, line.substring(annotationIndex));
allowlistConstructors.add(
new WhitelistConstructor(origin, Arrays.asList(canonicalTypeNameParameters), annotations)
new AllowlistConstructor(origin, Arrays.asList(canonicalTypeNameParameters), annotations)
);
// Handle the case for a method or augmented method definition.
@ -465,7 +465,7 @@ public final class WhitelistLoader {
: parseAllowlistAnnotations(parsers, line.substring(annotationIndex));
allowlistMethods.add(
new WhitelistMethod(
new AllowlistMethod(
origin,
javaAugmentedClassName,
methodName,
@ -497,7 +497,7 @@ public final class WhitelistLoader {
throw new IllegalArgumentException("invalid field definition: unexpected format [" + line + "]");
}
allowlistFields.add(new WhitelistField(origin, tokens[1], tokens[0], annotations));
allowlistFields.add(new AllowlistField(origin, tokens[1], tokens[0], annotations));
}
} else {
throw new IllegalArgumentException("invalid definition: unable to parse line [" + line + "]");
@ -515,10 +515,10 @@ public final class WhitelistLoader {
ClassLoader loader = AccessController.doPrivileged((PrivilegedAction<ClassLoader>) resource::getClassLoader);
return new Whitelist(loader, allowlistClasses, allowlistStatics, allowlistClassBindings, Collections.emptyList());
return new Allowlist(loader, allowlistClasses, allowlistStatics, allowlistClassBindings, Collections.emptyList());
}
private static List<Object> parseAllowlistAnnotations(Map<String, WhitelistAnnotationParser> parsers, String line) {
private static List<Object> parseAllowlistAnnotations(Map<String, AllowlistAnnotationParser> parsers, String line) {
List<Object> annotations;
@ -585,7 +585,7 @@ public final class WhitelistLoader {
}
}
WhitelistAnnotationParser parser = parsers.get(name);
AllowlistAnnotationParser parser = parsers.get(name);
if (parser == null) {
throw new IllegalArgumentException("invalid annotation: parser not found for [" + name + "] [" + line + "]");
@ -598,5 +598,5 @@ public final class WhitelistLoader {
return annotations;
}
private WhitelistLoader() {}
private AllowlistLoader() {}
}

View File

@ -44,7 +44,7 @@ import java.util.stream.Collectors;
* within Painless. Methods for Painless classes may be accessed exactly as methods for Java classes
* are using the '.' operator on an existing class variable/field. Painless classes may have multiple
* methods with the same name as long as they comply with arity overloading described in
* {@link WhitelistClass}.
* {@link AllowlistClass}.
*
* Classes may also have additional methods that are not part of the Java class the class represents -
* these are known as augmented methods. An augmented method can be added to a class as a part of any
@ -52,7 +52,7 @@ import java.util.stream.Collectors;
* represented by the class. Note that the augmented method's parent Java class does not need to be
* allowlisted.
*/
public class WhitelistMethod {
public class AllowlistMethod {
/** Information about where this method was allowlisted from. */
public final String origin;
@ -85,7 +85,7 @@ public class WhitelistMethod {
* augmentedCanonicalClassName; augmentedCanonicalClassName will be {@code null} unless the method
* is augmented as described in the class documentation.
*/
public WhitelistMethod(
public AllowlistMethod(
String origin,
String augmentedCanonicalClassName,
String methodName,

View File

@ -39,5 +39,5 @@ import java.util.Map;
public interface PainlessExtension {
Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists();
Map<ScriptContext<?>, List<Allowlist>> getContextAllowlists();
}

View File

@ -42,9 +42,9 @@ import java.util.stream.Stream;
* AllowlistAnnotationParser is an interface used to define how to
* parse an annotation against any allowlist object while loading.
*/
public interface WhitelistAnnotationParser {
public interface AllowlistAnnotationParser {
Map<String, WhitelistAnnotationParser> BASE_ANNOTATION_PARSERS = Collections.unmodifiableMap(
Map<String, AllowlistAnnotationParser> BASE_ANNOTATION_PARSERS = Collections.unmodifiableMap(
Stream.of(
new AbstractMap.SimpleEntry<>(NoImportAnnotation.NAME, NoImportAnnotationParser.INSTANCE),
new AbstractMap.SimpleEntry<>(DeprecatedAnnotation.NAME, DeprecatedAnnotationParser.INSTANCE),

View File

@ -34,7 +34,7 @@ package org.opensearch.painless.spi.annotation;
import java.util.Map;
public class DeprecatedAnnotationParser implements WhitelistAnnotationParser {
public class DeprecatedAnnotationParser implements AllowlistAnnotationParser {
public static final DeprecatedAnnotationParser INSTANCE = new DeprecatedAnnotationParser();

View File

@ -35,7 +35,7 @@ package org.opensearch.painless.spi.annotation;
import java.util.ArrayList;
import java.util.Map;
public class InjectConstantAnnotationParser implements WhitelistAnnotationParser {
public class InjectConstantAnnotationParser implements AllowlistAnnotationParser {
public static final InjectConstantAnnotationParser INSTANCE = new InjectConstantAnnotationParser();

View File

@ -34,7 +34,7 @@ package org.opensearch.painless.spi.annotation;
import java.util.Map;
public class NoImportAnnotationParser implements WhitelistAnnotationParser {
public class NoImportAnnotationParser implements AllowlistAnnotationParser {
public static final NoImportAnnotationParser INSTANCE = new NoImportAnnotationParser();

View File

@ -34,7 +34,7 @@ package org.opensearch.painless.spi.annotation;
import java.util.Map;
public class NonDeterministicAnnotationParser implements WhitelistAnnotationParser {
public class NonDeterministicAnnotationParser implements AllowlistAnnotationParser {
public static final NonDeterministicAnnotationParser INSTANCE = new NonDeterministicAnnotationParser();

View File

@ -43,7 +43,7 @@ import org.opensearch.painless.phase.DocFieldsPhase;
import org.opensearch.painless.phase.PainlessSemanticAnalysisPhase;
import org.opensearch.painless.phase.PainlessSemanticHeaderPhase;
import org.opensearch.painless.phase.PainlessUserTreeToIRTreePhase;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.symbol.Decorations.IRNodeDecoration;
import org.opensearch.painless.symbol.ScriptScope;
import org.objectweb.asm.util.Printer;
@ -100,7 +100,7 @@ final class Compiler {
/**
* Will check to see if the {@link Class} has already been loaded when
* the {@link PainlessLookup} was initially created. Allows for {@link Whitelist}ed
* the {@link PainlessLookup} was initially created. Allows for {@link Allowlist}ed
* classes to be loaded from other modules/plugins without a direct relationship
* to the module's/plugin's {@link ClassLoader}.
*/

View File

@ -51,8 +51,8 @@ import org.opensearch.env.NodeEnvironment;
import org.opensearch.painless.action.PainlessContextAction;
import org.opensearch.painless.action.PainlessExecuteAction;
import org.opensearch.painless.spi.PainlessExtension;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.WhitelistLoader;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.spi.AllowlistLoader;
import org.opensearch.plugins.ActionPlugin;
import org.opensearch.plugins.ExtensiblePlugin;
import org.opensearch.plugins.Plugin;
@ -83,7 +83,7 @@ import java.util.function.Supplier;
*/
public final class PainlessPlugin extends Plugin implements ScriptPlugin, ExtensiblePlugin, ActionPlugin {
private static final Map<ScriptContext<?>, List<Whitelist>> allowlists;
private static final Map<ScriptContext<?>, List<Allowlist>> allowlists;
/*
* Contexts from Core that need custom allowlists can add them to the map below.
@ -91,21 +91,21 @@ public final class PainlessPlugin extends Plugin implements ScriptPlugin, Extens
* under Painless' resources
*/
static {
Map<ScriptContext<?>, List<Whitelist>> map = new HashMap<>();
Map<ScriptContext<?>, List<Allowlist>> map = new HashMap<>();
// Moving Function Pipeline Agg
List<Whitelist> movFn = new ArrayList<>(Whitelist.BASE_WHITELISTS);
movFn.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.aggs.movfn.txt"));
List<Allowlist> movFn = new ArrayList<>(Allowlist.BASE_ALLOWLISTS);
movFn.add(AllowlistLoader.loadFromResourceFiles(Allowlist.class, "org.opensearch.aggs.movfn.txt"));
map.put(MovingFunctionScript.CONTEXT, movFn);
// Functions used for scoring docs
List<Whitelist> scoreFn = new ArrayList<>(Whitelist.BASE_WHITELISTS);
scoreFn.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.score.txt"));
List<Allowlist> scoreFn = new ArrayList<>(Allowlist.BASE_ALLOWLISTS);
scoreFn.add(AllowlistLoader.loadFromResourceFiles(Allowlist.class, "org.opensearch.score.txt"));
map.put(ScoreScript.CONTEXT, scoreFn);
// Functions available to ingest pipelines
List<Whitelist> ingest = new ArrayList<>(Whitelist.BASE_WHITELISTS);
ingest.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.ingest.txt"));
List<Allowlist> ingest = new ArrayList<>(Allowlist.BASE_ALLOWLISTS);
ingest.add(AllowlistLoader.loadFromResourceFiles(Allowlist.class, "org.opensearch.ingest.txt"));
map.put(IngestScript.CONTEXT, ingest);
allowlists = map;
@ -115,12 +115,12 @@ public final class PainlessPlugin extends Plugin implements ScriptPlugin, Extens
@Override
public ScriptEngine getScriptEngine(Settings settings, Collection<ScriptContext<?>> contexts) {
Map<ScriptContext<?>, List<Whitelist>> contextsWithAllowlists = new HashMap<>();
Map<ScriptContext<?>, List<Allowlist>> contextsWithAllowlists = new HashMap<>();
for (ScriptContext<?> context : contexts) {
// we might have a context that only uses the base allowlists, so would not have been filled in by reloadSPI
List<Whitelist> contextAllowlists = allowlists.get(context);
List<Allowlist> contextAllowlists = allowlists.get(context);
if (contextAllowlists == null) {
contextAllowlists = new ArrayList<>(Whitelist.BASE_WHITELISTS);
contextAllowlists = new ArrayList<>(Allowlist.BASE_ALLOWLISTS);
}
contextsWithAllowlists.put(context, contextAllowlists);
}
@ -156,9 +156,9 @@ public final class PainlessPlugin extends Plugin implements ScriptPlugin, Extens
public void loadExtensions(ExtensionLoader loader) {
loader.loadExtensions(PainlessExtension.class)
.stream()
.flatMap(extension -> extension.getContextWhitelists().entrySet().stream())
.flatMap(extension -> extension.getContextAllowlists().entrySet().stream())
.forEach(entry -> {
List<Whitelist> existing = allowlists.computeIfAbsent(entry.getKey(), c -> new ArrayList<>(Whitelist.BASE_WHITELISTS));
List<Allowlist> existing = allowlists.computeIfAbsent(entry.getKey(), c -> new ArrayList<>(Allowlist.BASE_ALLOWLISTS));
existing.addAll(entry.getValue());
});
}

View File

@ -37,7 +37,7 @@ import org.opensearch.common.settings.Settings;
import org.opensearch.painless.Compiler.Loader;
import org.opensearch.painless.lookup.PainlessLookup;
import org.opensearch.painless.lookup.PainlessLookupBuilder;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.symbol.ScriptScope;
import org.opensearch.script.ScriptContext;
import org.opensearch.script.ScriptEngine;
@ -101,16 +101,16 @@ public final class PainlessScriptEngine implements ScriptEngine {
* Constructor.
* @param settings The settings to initialize the engine with.
*/
public PainlessScriptEngine(Settings settings, Map<ScriptContext<?>, List<Whitelist>> contexts) {
public PainlessScriptEngine(Settings settings, Map<ScriptContext<?>, List<Allowlist>> contexts) {
defaultCompilerSettings.setRegexesEnabled(CompilerSettings.REGEX_ENABLED.get(settings));
defaultCompilerSettings.setRegexLimitFactor(CompilerSettings.REGEX_LIMIT_FACTOR.get(settings));
Map<ScriptContext<?>, Compiler> contextsToCompilers = new HashMap<>();
Map<ScriptContext<?>, PainlessLookup> contextsToLookups = new HashMap<>();
for (Map.Entry<ScriptContext<?>, List<Whitelist>> entry : contexts.entrySet()) {
for (Map.Entry<ScriptContext<?>, List<Allowlist>> entry : contexts.entrySet()) {
ScriptContext<?> context = entry.getKey();
PainlessLookup lookup = PainlessLookupBuilder.buildFromWhitelists(entry.getValue());
PainlessLookup lookup = PainlessLookupBuilder.buildFromAllowlists(entry.getValue());
contextsToCompilers.put(
context,
new Compiler(context.instanceClazz, context.factoryClazz, context.statefulFactoryClazz, lookup)

View File

@ -103,7 +103,7 @@ public class ScriptClassInfo {
+ "type ["
+ componentType.getName()
+ "]. Painless can only support getters with return types that are "
+ "whitelisted."
+ "allowlisted."
)
);
@ -156,11 +156,11 @@ public class ScriptClassInfo {
executeMethodReturnType = definitionTypeForClass(
painlessLookup,
executeMethod.getReturnType(),
componentType -> "Painless can only implement execute methods returning a whitelisted type but ["
componentType -> "Painless can only implement execute methods returning a allowlisted type but ["
+ baseClass.getName()
+ "#execute] returns ["
+ componentType.getName()
+ "] which isn't whitelisted."
+ "] which isn't allowlisted."
);
// Look up the argument
@ -261,7 +261,7 @@ public class ScriptClassInfo {
+ argName
+ "] is of unknown type ["
+ componentType.getName()
+ ". Painless interfaces can only accept arguments that are of whitelisted types."
+ ". Painless interfaces can only accept arguments that are of allowlisted types."
);
return new MethodArgument(defClass, argName);
}

View File

@ -36,13 +36,13 @@ import org.opensearch.bootstrap.BootstrapInfo;
import org.opensearch.painless.Def;
import org.opensearch.painless.MethodWriter;
import org.opensearch.painless.WriterConstants;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.WhitelistClass;
import org.opensearch.painless.spi.WhitelistClassBinding;
import org.opensearch.painless.spi.WhitelistConstructor;
import org.opensearch.painless.spi.WhitelistField;
import org.opensearch.painless.spi.WhitelistInstanceBinding;
import org.opensearch.painless.spi.WhitelistMethod;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.spi.AllowlistClass;
import org.opensearch.painless.spi.AllowlistClassBinding;
import org.opensearch.painless.spi.AllowlistConstructor;
import org.opensearch.painless.spi.AllowlistField;
import org.opensearch.painless.spi.AllowlistInstanceBinding;
import org.opensearch.painless.spi.AllowlistMethod;
import org.opensearch.painless.spi.annotation.InjectConstantAnnotation;
import org.opensearch.painless.spi.annotation.NoImportAnnotation;
import org.objectweb.asm.ClassWriter;
@ -126,13 +126,13 @@ public final class PainlessLookupBuilder {
}
}
public static PainlessLookup buildFromWhitelists(List<Whitelist> allowlists) {
public static PainlessLookup buildFromAllowlists(List<Allowlist> allowlists) {
PainlessLookupBuilder painlessLookupBuilder = new PainlessLookupBuilder();
String origin = "internal error";
try {
for (Whitelist allowlist : allowlists) {
for (WhitelistClass allowlistClass : allowlist.whitelistClasses) {
for (Allowlist allowlist : allowlists) {
for (AllowlistClass allowlistClass : allowlist.allowlistClasses) {
origin = allowlistClass.origin;
painlessLookupBuilder.addPainlessClass(
allowlist.classLoader,
@ -142,11 +142,11 @@ public final class PainlessLookupBuilder {
}
}
for (Whitelist allowlist : allowlists) {
for (WhitelistClass allowlistClass : allowlist.whitelistClasses) {
for (Allowlist allowlist : allowlists) {
for (AllowlistClass allowlistClass : allowlist.allowlistClasses) {
String targetCanonicalClassName = allowlistClass.javaClassName.replace('$', '.');
for (WhitelistConstructor allowlistConstructor : allowlistClass.whitelistConstructors) {
for (AllowlistConstructor allowlistConstructor : allowlistClass.allowlistConstructors) {
origin = allowlistConstructor.origin;
painlessLookupBuilder.addPainlessConstructor(
targetCanonicalClassName,
@ -155,7 +155,7 @@ public final class PainlessLookupBuilder {
);
}
for (WhitelistMethod allowlistMethod : allowlistClass.whitelistMethods) {
for (AllowlistMethod allowlistMethod : allowlistClass.allowlistMethods) {
origin = allowlistMethod.origin;
painlessLookupBuilder.addPainlessMethod(
allowlist.classLoader,
@ -168,7 +168,7 @@ public final class PainlessLookupBuilder {
);
}
for (WhitelistField allowlistField : allowlistClass.whitelistFields) {
for (AllowlistField allowlistField : allowlistClass.allowlistFields) {
origin = allowlistField.origin;
painlessLookupBuilder.addPainlessField(
targetCanonicalClassName,
@ -178,7 +178,7 @@ public final class PainlessLookupBuilder {
}
}
for (WhitelistMethod allowlistStatic : allowlist.whitelistImportedMethods) {
for (AllowlistMethod allowlistStatic : allowlist.allowlistImportedMethods) {
origin = allowlistStatic.origin;
painlessLookupBuilder.addImportedPainlessMethod(
allowlist.classLoader,
@ -190,7 +190,7 @@ public final class PainlessLookupBuilder {
);
}
for (WhitelistClassBinding allowlistClassBinding : allowlist.whitelistClassBindings) {
for (AllowlistClassBinding allowlistClassBinding : allowlist.allowlistClassBindings) {
origin = allowlistClassBinding.origin;
painlessLookupBuilder.addPainlessClassBinding(
allowlist.classLoader,
@ -202,7 +202,7 @@ public final class PainlessLookupBuilder {
);
}
for (WhitelistInstanceBinding allowlistInstanceBinding : allowlist.whitelistInstanceBindings) {
for (AllowlistInstanceBinding allowlistInstanceBinding : allowlist.allowlistInstanceBindings) {
origin = allowlistInstanceBinding.origin;
painlessLookupBuilder.addPainlessInstanceBinding(
allowlistInstanceBinding.targetInstance,

View File

@ -32,24 +32,24 @@
package org.opensearch.painless;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.WhitelistClass;
import org.opensearch.painless.spi.WhitelistLoader;
import org.opensearch.painless.spi.WhitelistMethod;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.spi.AllowlistClass;
import org.opensearch.painless.spi.AllowlistLoader;
import org.opensearch.painless.spi.AllowlistMethod;
import org.opensearch.painless.spi.annotation.DeprecatedAnnotation;
import org.opensearch.painless.spi.annotation.NoImportAnnotation;
import org.opensearch.painless.spi.annotation.WhitelistAnnotationParser;
import org.opensearch.painless.spi.annotation.AllowlistAnnotationParser;
import java.util.HashMap;
import java.util.Map;
public class WhitelistLoaderTests extends ScriptTestCase {
public class AllowlistLoaderTests extends ScriptTestCase {
public void testUnknownAnnotations() {
Map<String, WhitelistAnnotationParser> parsers = new HashMap<>(WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS);
Map<String, AllowlistAnnotationParser> parsers = new HashMap<>(AllowlistAnnotationParser.BASE_ANNOTATION_PARSERS);
RuntimeException expected = expectThrows(
RuntimeException.class,
() -> { WhitelistLoader.loadFromResourceFiles(Whitelist.class, parsers, "org.opensearch.painless.annotation.unknown"); }
() -> { AllowlistLoader.loadFromResourceFiles(Allowlist.class, parsers, "org.opensearch.painless.annotation.unknown"); }
);
assertEquals("invalid annotation: parser not found for [unknownAnnotation] [@unknownAnnotation]", expected.getCause().getMessage());
assertEquals(IllegalArgumentException.class, expected.getCause().getClass());
@ -57,7 +57,7 @@ public class WhitelistLoaderTests extends ScriptTestCase {
expected = expectThrows(
RuntimeException.class,
() -> {
WhitelistLoader.loadFromResourceFiles(Whitelist.class, parsers, "org.opensearch.painless.annotation.unknown_with_options");
AllowlistLoader.loadFromResourceFiles(Allowlist.class, parsers, "org.opensearch.painless.annotation.unknown_with_options");
}
);
assertEquals(
@ -68,21 +68,21 @@ public class WhitelistLoaderTests extends ScriptTestCase {
}
public void testAnnotations() {
Map<String, WhitelistAnnotationParser> parsers = new HashMap<>(WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS);
Map<String, AllowlistAnnotationParser> parsers = new HashMap<>(AllowlistAnnotationParser.BASE_ANNOTATION_PARSERS);
parsers.put(AnnotationTestObject.TestAnnotation.NAME, AnnotationTestObject.TestAnnotationParser.INSTANCE);
Whitelist allowlist = WhitelistLoader.loadFromResourceFiles(Whitelist.class, parsers, "org.opensearch.painless.annotation");
Allowlist allowlist = AllowlistLoader.loadFromResourceFiles(Allowlist.class, parsers, "org.opensearch.painless.annotation");
assertEquals(1, allowlist.whitelistClasses.size());
assertEquals(1, allowlist.allowlistClasses.size());
WhitelistClass allowlistClass = allowlist.whitelistClasses.get(0);
AllowlistClass allowlistClass = allowlist.allowlistClasses.get(0);
assertNotNull(allowlistClass.painlessAnnotations.get(NoImportAnnotation.class));
assertEquals(1, allowlistClass.painlessAnnotations.size());
assertEquals(3, allowlistClass.whitelistMethods.size());
assertEquals(3, allowlistClass.allowlistMethods.size());
int count = 0;
for (WhitelistMethod allowlistMethod : allowlistClass.whitelistMethods) {
for (AllowlistMethod allowlistMethod : allowlistClass.allowlistMethods) {
if ("deprecatedMethod".equals(allowlistMethod.methodName)) {
assertEquals(
"use another method",

View File

@ -32,7 +32,7 @@
package org.opensearch.painless;
import org.opensearch.painless.spi.annotation.WhitelistAnnotationParser;
import org.opensearch.painless.spi.annotation.AllowlistAnnotationParser;
import java.util.Map;
@ -65,7 +65,7 @@ public class AnnotationTestObject {
}
}
public static class TestAnnotationParser implements WhitelistAnnotationParser {
public static class TestAnnotationParser implements AllowlistAnnotationParser {
public static final TestAnnotationParser INSTANCE = new TestAnnotationParser();

View File

@ -35,8 +35,8 @@ package org.opensearch.painless;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.opensearch.common.settings.Settings;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.WhitelistLoader;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.spi.AllowlistLoader;
import org.opensearch.script.ScriptContext;
import java.util.ArrayList;
@ -52,9 +52,9 @@ public class AugmentationTests extends ScriptTestCase {
@BeforeClass
public static void beforeClass() {
Map<ScriptContext<?>, List<Whitelist>> contexts = newDefaultContexts();
List<Whitelist> digestAllowlist = new ArrayList<>(Whitelist.BASE_WHITELISTS);
digestAllowlist.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.ingest.txt"));
Map<ScriptContext<?>, List<Allowlist>> contexts = newDefaultContexts();
List<Allowlist> digestAllowlist = new ArrayList<>(Allowlist.BASE_ALLOWLISTS);
digestAllowlist.add(AllowlistLoader.loadFromResourceFiles(Allowlist.class, "org.opensearch.ingest.txt"));
contexts.put(DigestTestScript.CONTEXT, digestAllowlist);
SCRIPT_ENGINE = new PainlessScriptEngine(Settings.EMPTY, contexts);
}

View File

@ -35,7 +35,7 @@ package org.opensearch.painless;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.opensearch.common.settings.Settings;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.script.ScriptContext;
import java.util.Collections;
@ -56,28 +56,28 @@ public class BaseClassTests extends ScriptTestCase {
@BeforeClass
public static void beforeClass() {
Map<ScriptContext<?>, List<Whitelist>> contexts = new HashMap<>();
contexts.put(Gets.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(NoArgs.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(OneArg.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(ArrayArg.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(PrimitiveArrayArg.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(DefArrayArg.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(ManyArgs.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(VarArgs.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(DefaultMethods.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(ReturnsVoid.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(ReturnsPrimitiveBoolean.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(ReturnsPrimitiveInt.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(ReturnsPrimitiveFloat.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(ReturnsPrimitiveDouble.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(NoArgsConstant.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(WrongArgsConstant.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(WrongLengthOfArgConstant.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(UnknownArgType.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(UnknownReturnType.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(UnknownArgTypeInArray.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(TwoExecuteMethods.CONTEXT, Whitelist.BASE_WHITELISTS);
Map<ScriptContext<?>, List<Allowlist>> contexts = new HashMap<>();
contexts.put(Gets.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(NoArgs.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(OneArg.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(ArrayArg.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(PrimitiveArrayArg.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(DefArrayArg.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(ManyArgs.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(VarArgs.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(DefaultMethods.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(ReturnsVoid.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(ReturnsPrimitiveBoolean.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(ReturnsPrimitiveInt.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(ReturnsPrimitiveFloat.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(ReturnsPrimitiveDouble.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(NoArgsConstant.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(WrongArgsConstant.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(WrongLengthOfArgConstant.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(UnknownArgType.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(UnknownReturnType.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(UnknownArgTypeInArray.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(TwoExecuteMethods.CONTEXT, Allowlist.BASE_ALLOWLISTS);
SCRIPT_ENGINE = new PainlessScriptEngine(Settings.EMPTY, contexts);
}
@ -931,7 +931,7 @@ public class BaseClassTests extends ScriptTestCase {
"[foo] is of unknown type ["
+ UnknownArgType.class.getName()
+ ". Painless interfaces can only accept arguments "
+ "that are of whitelisted types.",
+ "that are of allowlisted types.",
e.getMessage()
);
}
@ -955,11 +955,11 @@ public class BaseClassTests extends ScriptTestCase {
() -> getEngine().compile("testUnknownReturnType0", "1", UnknownReturnType.CONTEXT, emptyMap())
);
assertEquals(
"Painless can only implement execute methods returning a whitelisted type but ["
"Painless can only implement execute methods returning a allowlisted type but ["
+ UnknownReturnType.class.getName()
+ "#execute] returns ["
+ UnknownReturnType.class.getName()
+ "] which isn't whitelisted.",
+ "] which isn't allowlisted.",
e.getMessage()
);
}
@ -986,7 +986,7 @@ public class BaseClassTests extends ScriptTestCase {
"[foo] is of unknown type ["
+ UnknownArgTypeInArray.class.getName()
+ ". Painless interfaces can only accept "
+ "arguments that are of whitelisted types.",
+ "arguments that are of allowlisted types.",
e.getMessage()
);
}

View File

@ -35,7 +35,7 @@ package org.opensearch.painless;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.opensearch.common.settings.Settings;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.script.ScriptContext;
import java.util.ArrayList;
@ -51,8 +51,8 @@ public class BasicStatementTests extends ScriptTestCase {
@BeforeClass
public static void beforeClass() {
Map<ScriptContext<?>, List<Whitelist>> contexts = newDefaultContexts();
contexts.put(OneArg.CONTEXT, Whitelist.BASE_WHITELISTS);
Map<ScriptContext<?>, List<Allowlist>> contexts = newDefaultContexts();
contexts.put(OneArg.CONTEXT, Allowlist.BASE_ALLOWLISTS);
SCRIPT_ENGINE = new PainlessScriptEngine(Settings.EMPTY, contexts);
}

View File

@ -35,9 +35,9 @@ package org.opensearch.painless;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.opensearch.common.settings.Settings;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.WhitelistInstanceBinding;
import org.opensearch.painless.spi.WhitelistLoader;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.spi.AllowlistInstanceBinding;
import org.opensearch.painless.spi.AllowlistLoader;
import org.opensearch.script.ScriptContext;
import java.util.ArrayList;
@ -50,12 +50,12 @@ public class BindingsTests extends ScriptTestCase {
@BeforeClass
public static void beforeClass() {
Map<ScriptContext<?>, List<Whitelist>> contexts = newDefaultContexts();
List<Whitelist> allowlists = new ArrayList<>(Whitelist.BASE_WHITELISTS);
allowlists.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.painless.test"));
Map<ScriptContext<?>, List<Allowlist>> contexts = newDefaultContexts();
List<Allowlist> allowlists = new ArrayList<>(Allowlist.BASE_ALLOWLISTS);
allowlists.add(AllowlistLoader.loadFromResourceFiles(Allowlist.class, "org.opensearch.painless.test"));
InstanceBindingTestClass instanceBindingTestClass = new InstanceBindingTestClass(1);
WhitelistInstanceBinding getter = new WhitelistInstanceBinding(
AllowlistInstanceBinding getter = new AllowlistInstanceBinding(
"test",
instanceBindingTestClass,
"setInstanceBindingValue",
@ -63,7 +63,7 @@ public class BindingsTests extends ScriptTestCase {
Collections.singletonList("int"),
Collections.emptyList()
);
WhitelistInstanceBinding setter = new WhitelistInstanceBinding(
AllowlistInstanceBinding setter = new AllowlistInstanceBinding(
"test",
instanceBindingTestClass,
"getInstanceBindingValue",
@ -71,10 +71,10 @@ public class BindingsTests extends ScriptTestCase {
Collections.emptyList(),
Collections.emptyList()
);
List<WhitelistInstanceBinding> instanceBindingsList = new ArrayList<>();
List<AllowlistInstanceBinding> instanceBindingsList = new ArrayList<>();
instanceBindingsList.add(getter);
instanceBindingsList.add(setter);
Whitelist instanceBindingsAllowlist = new Whitelist(
Allowlist instanceBindingsAllowlist = new Allowlist(
instanceBindingTestClass.getClass().getClassLoader(),
Collections.emptyList(),
Collections.emptyList(),

View File

@ -37,7 +37,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.painless.lookup.PainlessLookup;
import org.opensearch.painless.lookup.PainlessLookupBuilder;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.script.ScriptException;
import java.io.IOException;
@ -50,7 +50,7 @@ import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.not;
public class DebugTests extends ScriptTestCase {
private final PainlessLookup painlessLookup = PainlessLookupBuilder.buildFromWhitelists(Whitelist.BASE_WHITELISTS);
private final PainlessLookup painlessLookup = PainlessLookupBuilder.buildFromAllowlists(Allowlist.BASE_ALLOWLISTS);
public void testExplain() {
// Debug.explain can explain an object

View File

@ -35,7 +35,7 @@ package org.opensearch.painless;
import org.opensearch.painless.action.PainlessExecuteAction.PainlessTestScript;
import org.opensearch.painless.lookup.PainlessLookup;
import org.opensearch.painless.lookup.PainlessLookupBuilder;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.objectweb.asm.util.Textifier;
import java.io.PrintWriter;
@ -49,7 +49,7 @@ final class Debugger {
return toString(PainlessTestScript.class, source, new CompilerSettings());
}
private static final PainlessLookup LOOKUP = PainlessLookupBuilder.buildFromWhitelists(Whitelist.BASE_WHITELISTS);
private static final PainlessLookup LOOKUP = PainlessLookupBuilder.buildFromAllowlists(Allowlist.BASE_ALLOWLISTS);
/** compiles to bytecode, and returns debugging output */
static String toString(Class<?> iface, String source, CompilerSettings settings) {

View File

@ -34,7 +34,7 @@ package org.opensearch.painless;
import org.opensearch.painless.lookup.PainlessLookup;
import org.opensearch.painless.lookup.PainlessLookupBuilder;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.symbol.FunctionTable;
import org.opensearch.test.OpenSearchTestCase;
@ -47,7 +47,7 @@ import java.util.Collections;
import java.util.HashMap;
public class DefBootstrapTests extends OpenSearchTestCase {
private final PainlessLookup painlessLookup = PainlessLookupBuilder.buildFromWhitelists(Whitelist.BASE_WHITELISTS);
private final PainlessLookup painlessLookup = PainlessLookupBuilder.buildFromAllowlists(Allowlist.BASE_ALLOWLISTS);
/** calls toString() on integers, twice */
public void testOneType() throws Throwable {

View File

@ -35,7 +35,7 @@ package org.opensearch.painless;
import org.opensearch.painless.Compiler.Loader;
import org.opensearch.painless.lookup.PainlessLookup;
import org.opensearch.painless.lookup.PainlessLookupBuilder;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.symbol.ScriptScope;
import org.opensearch.script.ScriptContext;
@ -46,7 +46,7 @@ import java.util.List;
import java.util.Map;
public class DocFieldsPhaseTests extends ScriptTestCase {
PainlessLookup lookup = PainlessLookupBuilder.buildFromWhitelists(Whitelist.BASE_WHITELISTS);
PainlessLookup lookup = PainlessLookupBuilder.buildFromAllowlists(Allowlist.BASE_ALLOWLISTS);
ScriptScope compile(String script) {
Compiler compiler = new Compiler(

View File

@ -35,7 +35,7 @@ package org.opensearch.painless;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.opensearch.common.settings.Settings;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.script.ScriptContext;
import org.opensearch.script.ScriptException;
import org.opensearch.script.ScriptFactory;
@ -54,16 +54,16 @@ public class FactoryTests extends ScriptTestCase {
@BeforeClass
public static void beforeClass() {
Map<ScriptContext<?>, List<Whitelist>> contexts = newDefaultContexts();
contexts.put(StatefulFactoryTestScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(FactoryTestScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(DeterministicFactoryTestScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(EmptyTestScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(TemplateScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(VoidReturnTestScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(FactoryTestConverterScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(FactoryTestConverterScriptBadDef.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(DocFieldsTestScript.CONTEXT, Whitelist.BASE_WHITELISTS);
Map<ScriptContext<?>, List<Allowlist>> contexts = newDefaultContexts();
contexts.put(StatefulFactoryTestScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(FactoryTestScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(DeterministicFactoryTestScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(EmptyTestScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(TemplateScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(VoidReturnTestScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(FactoryTestConverterScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(FactoryTestConverterScriptBadDef.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(DocFieldsTestScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
SCRIPT_ENGINE = new PainlessScriptEngine(Settings.EMPTY, contexts);
}

View File

@ -35,7 +35,7 @@ package org.opensearch.painless;
import org.opensearch.common.settings.Settings;
import org.opensearch.index.IndexService;
import org.opensearch.index.query.QueryShardContext;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.script.NumberSortScript;
import org.opensearch.script.ScriptContext;
import org.opensearch.test.OpenSearchSingleNodeTestCase;
@ -54,8 +54,8 @@ public class NeedsScoreTests extends OpenSearchSingleNodeTestCase {
public void testNeedsScores() {
IndexService index = createIndex("test", Settings.EMPTY, "type", "d", "type=double");
Map<ScriptContext<?>, List<Whitelist>> contexts = new HashMap<>();
contexts.put(NumberSortScript.CONTEXT, Whitelist.BASE_WHITELISTS);
Map<ScriptContext<?>, List<Allowlist>> contexts = new HashMap<>();
contexts.put(NumberSortScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
PainlessScriptEngine service = new PainlessScriptEngine(Settings.EMPTY, contexts);
QueryShardContext shardContext = index.newQueryShardContext(0, null, () -> 0, null);

View File

@ -36,8 +36,8 @@ import junit.framework.AssertionFailedError;
import org.opensearch.common.settings.Settings;
import org.opensearch.painless.antlr.Walker;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.WhitelistLoader;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.spi.AllowlistLoader;
import org.opensearch.script.ScriptContext;
import org.opensearch.script.ScriptException;
import org.opensearch.test.OpenSearchTestCase;
@ -60,10 +60,10 @@ public abstract class ScriptTestCase extends OpenSearchTestCase {
private static final PainlessScriptEngine SCRIPT_ENGINE = new PainlessScriptEngine(Settings.EMPTY, newDefaultContexts());
/** Creates a new contexts map with PainlessTextScript = org.opensearch.painless.test */
protected static Map<ScriptContext<?>, List<Whitelist>> newDefaultContexts() {
Map<ScriptContext<?>, List<Whitelist>> contexts = new HashMap<>();
List<Whitelist> allowlists = new ArrayList<>(Whitelist.BASE_WHITELISTS);
allowlists.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.painless.test"));
protected static Map<ScriptContext<?>, List<Allowlist>> newDefaultContexts() {
Map<ScriptContext<?>, List<Allowlist>> contexts = new HashMap<>();
List<Allowlist> allowlists = new ArrayList<>(Allowlist.BASE_ALLOWLISTS);
allowlists.add(AllowlistLoader.loadFromResourceFiles(Allowlist.class, "org.opensearch.painless.test"));
contexts.put(PainlessTestScript.CONTEXT, allowlists);
return contexts;
}

View File

@ -38,7 +38,7 @@ import org.apache.lucene.search.Scorable;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.opensearch.common.settings.Settings;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.script.ScriptContext;
import org.opensearch.script.ScriptedMetricAggContexts;
import org.opensearch.search.lookup.LeafSearchLookup;
@ -60,11 +60,11 @@ public class ScriptedMetricAggContextsTests extends ScriptTestCase {
@BeforeClass
public static void beforeClass() {
Map<ScriptContext<?>, List<Whitelist>> contexts = new HashMap<>();
contexts.put(ScriptedMetricAggContexts.InitScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(ScriptedMetricAggContexts.MapScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(ScriptedMetricAggContexts.CombineScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(ScriptedMetricAggContexts.ReduceScript.CONTEXT, Whitelist.BASE_WHITELISTS);
Map<ScriptContext<?>, List<Allowlist>> contexts = new HashMap<>();
contexts.put(ScriptedMetricAggContexts.InitScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(ScriptedMetricAggContexts.MapScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(ScriptedMetricAggContexts.CombineScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(ScriptedMetricAggContexts.ReduceScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
SCRIPT_ENGINE = new PainlessScriptEngine(Settings.EMPTY, contexts);
}

View File

@ -53,7 +53,7 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.opensearch.common.settings.Settings;
import org.opensearch.index.similarity.ScriptedSimilarity;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.script.ScriptContext;
import org.opensearch.script.SimilarityScript;
import org.opensearch.script.SimilarityWeightScript;
@ -69,9 +69,9 @@ public class SimilarityScriptTests extends ScriptTestCase {
@BeforeClass
public static void beforeClass() {
Map<ScriptContext<?>, List<Whitelist>> contexts = new HashMap<>();
contexts.put(SimilarityScript.CONTEXT, Whitelist.BASE_WHITELISTS);
contexts.put(SimilarityWeightScript.CONTEXT, Whitelist.BASE_WHITELISTS);
Map<ScriptContext<?>, List<Allowlist>> contexts = new HashMap<>();
contexts.put(SimilarityScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
contexts.put(SimilarityWeightScript.CONTEXT, Allowlist.BASE_ALLOWLISTS);
SCRIPT_ENGINE = new PainlessScriptEngine(Settings.EMPTY, contexts);
}

View File

@ -50,15 +50,15 @@ import static org.opensearch.index.reindex.ReindexValidator.checkRemoteAllowlist
/**
* Tests the reindex-from-remote allowlist of remotes.
*/
public class ReindexFromRemoteWhitelistTests extends OpenSearchTestCase {
public class ReindexFromRemoteAllowlistTests extends OpenSearchTestCase {
private final BytesReference query = new BytesArray("{ \"foo\" : \"bar\" }");
public void testLocalRequestWithoutWhitelist() {
public void testLocalRequestWithoutAllowlist() {
checkRemoteAllowlist(buildRemoteAllowlist(emptyList()), null);
}
public void testLocalRequestWithWhitelist() {
public void testLocalRequestWithAllowlist() {
checkRemoteAllowlist(buildRemoteAllowlist(randomAllowlist()), null);
}
@ -80,7 +80,7 @@ public class ReindexFromRemoteWhitelistTests extends OpenSearchTestCase {
);
}
public void testWhitelistedRemote() {
public void testAllowlistedRemote() {
List<String> allowlist = randomAllowlist();
String[] inList = allowlist.iterator().next().split(":");
String host = inList[0];
@ -88,7 +88,7 @@ public class ReindexFromRemoteWhitelistTests extends OpenSearchTestCase {
checkRemoteAllowlist(buildRemoteAllowlist(allowlist), newRemoteInfo(host, port));
}
public void testWhitelistedByPrefix() {
public void testAllowlistedByPrefix() {
checkRemoteAllowlist(
buildRemoteAllowlist(singletonList("*.example.com:9200")),
new RemoteInfo(
@ -110,21 +110,21 @@ public class ReindexFromRemoteWhitelistTests extends OpenSearchTestCase {
);
}
public void testWhitelistedBySuffix() {
public void testAllowlistedBySuffix() {
checkRemoteAllowlist(buildRemoteAllowlist(singletonList("es.example.com:*")), newRemoteInfo("es.example.com", 9200));
}
public void testWhitelistedByInfix() {
public void testAllowlistedByInfix() {
checkRemoteAllowlist(buildRemoteAllowlist(singletonList("es*.example.com:9200")), newRemoteInfo("es1.example.com", 9200));
}
public void testLoopbackInWhitelistRemote() throws UnknownHostException {
public void testLoopbackInAllowlistRemote() throws UnknownHostException {
List<String> allowlist = randomAllowlist();
allowlist.add("127.0.0.1:*");
checkRemoteAllowlist(buildRemoteAllowlist(allowlist), newRemoteInfo("127.0.0.1", 9200));
}
public void testUnwhitelistedRemote() {
public void testUnallowlistedRemote() {
int port = between(1, Integer.MAX_VALUE);
List<String> allowlist = randomBoolean() ? randomAllowlist() : emptyList();
Exception e = expectThrows(

View File

@ -68,7 +68,7 @@ public class URLRepositoryTests extends OpenSearchTestCase {
};
}
public void testWhiteListingRepoURL() throws IOException {
public void testAllowListingRepoURL() throws IOException {
String repoPath = createTempDir().resolve("repository").toUri().toURL().toString();
Settings baseSettings = Settings.builder()
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
@ -84,7 +84,7 @@ public class URLRepositoryTests extends OpenSearchTestCase {
assertThat("blobContainer has to initialize blob store", repository.getBlobStore(), not(nullValue()));
}
public void testIfNotWhiteListedMustSetRepoURL() throws IOException {
public void testIfNotAllowListedMustSetRepoURL() throws IOException {
String repoPath = createTempDir().resolve("repository").toUri().toURL().toString();
Settings baseSettings = Settings.builder()
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())

View File

@ -28,7 +28,7 @@ gradle.projectsEvaluated {
}
}
configure(project('painless-whitelist')) {
configure(project('painless-allowlist')) {
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module('org.opensearch.plugin:opensearch-scripting-painless-spi') with project(':modules:lang-painless:spi')

View File

@ -31,9 +31,9 @@ apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.yaml-rest-test'
opensearchplugin {
name 'painless-whitelist'
name 'painless-allowlist'
description 'An example allowlisting additional classes and methods in painless'
classname 'org.opensearch.example.painlesswhitelist.MyWhitelistPlugin'
classname 'org.opensearch.example.painlessallowlist.MyAllowlistPlugin'
extendedPlugins = ['lang-painless']
licenseFile rootProject.file('licenses/APACHE-LICENSE-2.0.txt')
noticeFile rootProject.file('NOTICE.txt')

View File

@ -30,17 +30,17 @@
* GitHub history for details.
*/
package org.opensearch.example.painlesswhitelist;
package org.opensearch.example.painlessallowlist;
import org.opensearch.painless.spi.annotation.WhitelistAnnotationParser;
import org.opensearch.painless.spi.annotation.AllowlistAnnotationParser;
import java.util.Map;
public class ExampleWhitelistAnnotationParser implements WhitelistAnnotationParser {
public class ExampleAllowlistAnnotationParser implements AllowlistAnnotationParser {
public static final ExampleWhitelistAnnotationParser INSTANCE = new ExampleWhitelistAnnotationParser();
public static final ExampleAllowlistAnnotationParser INSTANCE = new ExampleAllowlistAnnotationParser();
private ExampleWhitelistAnnotationParser() {
private ExampleAllowlistAnnotationParser() {
}

View File

@ -30,13 +30,13 @@
* GitHub history for details.
*/
package org.opensearch.example.painlesswhitelist;
package org.opensearch.example.painlessallowlist;
import org.opensearch.painless.spi.PainlessExtension;
import org.opensearch.painless.spi.Whitelist;
import org.opensearch.painless.spi.WhitelistInstanceBinding;
import org.opensearch.painless.spi.WhitelistLoader;
import org.opensearch.painless.spi.annotation.WhitelistAnnotationParser;
import org.opensearch.painless.spi.Allowlist;
import org.opensearch.painless.spi.AllowlistInstanceBinding;
import org.opensearch.painless.spi.AllowlistLoader;
import org.opensearch.painless.spi.annotation.AllowlistAnnotationParser;
import org.opensearch.script.FieldScript;
import org.opensearch.script.ScriptContext;
@ -47,16 +47,16 @@ import java.util.List;
import java.util.Map;
/** An extension of painless which adds an allowlist. */
public class ExampleWhitelistExtension implements PainlessExtension {
public class ExampleAllowlistExtension implements PainlessExtension {
@Override
public Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists() {
Map<String, WhitelistAnnotationParser> parsers = new HashMap<>(WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS);
parsers.put(ExamplePainlessAnnotation.NAME, ExampleWhitelistAnnotationParser.INSTANCE);
Whitelist classAllowlist = WhitelistLoader.loadFromResourceFiles(ExampleWhitelistExtension.class, parsers, "example_whitelist.txt");
public Map<ScriptContext<?>, List<Allowlist>> getContextAllowlists() {
Map<String, AllowlistAnnotationParser> parsers = new HashMap<>(AllowlistAnnotationParser.BASE_ANNOTATION_PARSERS);
parsers.put(ExamplePainlessAnnotation.NAME, ExampleAllowlistAnnotationParser.INSTANCE);
Allowlist classAllowlist = AllowlistLoader.loadFromResourceFiles(ExampleAllowlistExtension.class, parsers, "example_allowlist.txt");
ExampleWhitelistedInstance eai = new ExampleWhitelistedInstance(1);
WhitelistInstanceBinding addValue = new WhitelistInstanceBinding(
ExampleAllowlistedInstance eai = new ExampleAllowlistedInstance(1);
AllowlistInstanceBinding addValue = new AllowlistInstanceBinding(
"example addValue",
eai,
"addValue",
@ -64,7 +64,7 @@ public class ExampleWhitelistExtension implements PainlessExtension {
Collections.singletonList("int"),
Collections.emptyList()
);
WhitelistInstanceBinding getValue = new WhitelistInstanceBinding(
AllowlistInstanceBinding getValue = new AllowlistInstanceBinding(
"example getValue",
eai,
"getValue",
@ -72,7 +72,7 @@ public class ExampleWhitelistExtension implements PainlessExtension {
Collections.emptyList(),
Collections.emptyList()
);
Whitelist instanceAllowlist = new Whitelist(
Allowlist instanceAllowlist = new Allowlist(
eai.getClass().getClassLoader(),
Collections.emptyList(),
Collections.emptyList(),

View File

@ -30,15 +30,15 @@
* GitHub history for details.
*/
package org.opensearch.example.painlesswhitelist;
package org.opensearch.example.painlessallowlist;
/**
* An example of a class to be allowlisted for use by painless scripts
*
* Each of the members and methods below are allowlisted for use in search scripts.
* See <a href="file:example_whitelist.txt">example_whitelist.txt</a>.
* See <a href="file:example_allowlist.txt">example_allowlist.txt</a>.
*/
public class ExampleWhitelistedClass {
public class ExampleAllowlistedClass {
public static final int CONSTANT = 42;
@ -46,7 +46,7 @@ public class ExampleWhitelistedClass {
private int privateMember;
public ExampleWhitelistedClass(int publicMember, int privateMember) {
public ExampleAllowlistedClass(int publicMember, int privateMember) {
this.publicMember = publicMember;
this.privateMember = privateMember;
}

View File

@ -30,12 +30,12 @@
* GitHub history for details.
*/
package org.opensearch.example.painlesswhitelist;
package org.opensearch.example.painlessallowlist;
public class ExampleWhitelistedInstance {
public class ExampleAllowlistedInstance {
private final int value;
public ExampleWhitelistedInstance(int value) {
public ExampleAllowlistedInstance(int value) {
this.value = value;
}

View File

@ -30,7 +30,7 @@
* GitHub history for details.
*/
package org.opensearch.example.painlesswhitelist;
package org.opensearch.example.painlessallowlist;
public class ExamplePainlessAnnotation {

View File

@ -30,7 +30,7 @@
* GitHub history for details.
*/
package org.opensearch.example.painlesswhitelist;
package org.opensearch.example.painlessallowlist;
public class ExampleStaticMethodClass {
public static int exampleAddInts(int x, int y) {

View File

@ -30,10 +30,10 @@
* GitHub history for details.
*/
package org.opensearch.example.painlesswhitelist;
package org.opensearch.example.painlessallowlist;
import org.opensearch.plugins.Plugin;
public class MyWhitelistPlugin extends Plugin {
public class MyAllowlistPlugin extends Plugin {
// we don't actually need anything here, since allowlists are extended through SPI
}

View File

@ -0,0 +1 @@
org.opensearch.example.painlessallowlist.ExampleAllowlistExtension

View File

@ -19,7 +19,7 @@
# This file contains an allowlist for an example class which may be access from painless
class org.opensearch.example.painlesswhitelist.ExampleWhitelistedClass {
class org.opensearch.example.painlessallowlist.ExampleAllowlistedClass {
# constructor
(int, int)
@ -41,9 +41,9 @@ class org.opensearch.example.painlesswhitelist.ExampleWhitelistedClass {
class java.lang.String {
# existing classes can be "augmented" to have additional methods, which take the object
# to operate on as the first argument to a static method
int org.opensearch.example.painlesswhitelist.ExampleWhitelistedClass toInt()
int org.opensearch.example.painlessallowlist.ExampleAllowlistedClass toInt()
}
static_import {
int exampleAddInts(int, int) from_class org.opensearch.example.painlesswhitelist.ExampleStaticMethodClass
int exampleAddInts(int, int) from_class org.opensearch.example.painlessallowlist.ExampleStaticMethodClass
}

View File

@ -30,16 +30,16 @@
* GitHub history for details.
*/
package org.opensearch.example.painlesswhitelist;
package org.opensearch.example.painlessallowlist;
import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.opensearch.test.rest.yaml.ClientYamlTestCandidate;
import org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase;
public class PainlessWhitelistClientYamlTestSuiteIT extends OpenSearchClientYamlSuiteTestCase {
public class PainlessAllowlistClientYamlTestSuiteIT extends OpenSearchClientYamlSuiteTestCase {
public PainlessWhitelistClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
public PainlessAllowlistClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}

View File

@ -13,4 +13,4 @@
- do:
nodes.info: {}
- contains: { nodes.$cluster_manager.plugins: { name: painless-whitelist } }
- contains: { nodes.$cluster_manager.plugins: { name: painless-allowlist } }

View File

@ -1,6 +1,6 @@
# Example test using allowlisted members and methods
"Whitelisted custom class":
"Allowlisted custom class":
- do:
index:
index: test
@ -19,7 +19,7 @@
script_fields:
sNum1:
script:
source: "def e = new ExampleWhitelistedClass(6, 42); ExampleWhitelistedClass.staticMethod(); return e.publicMember + e.privateMemberAccessor + ExampleWhitelistedClass.CONSTANT + '2'.toInt()"
source: "def e = new ExampleAllowlistedClass(6, 42); ExampleAllowlistedClass.staticMethod(); return e.publicMember + e.privateMemberAccessor + ExampleAllowlistedClass.CONSTANT + '2'.toInt()"
lang: painless
- match: { hits.total: 1 }

View File

@ -1 +0,0 @@
org.opensearch.example.painlesswhitelist.ExampleWhitelistExtension

View File

@ -157,9 +157,9 @@ The runner is able to send and receive `application/yaml` and perform all assert
Asserts an array of object contains an object with a property set to a certain value. e.g:
… contains: { nodes.$master.plugins: { name: painless-whitelist } } …
… contains: { nodes.$cluster_manager.plugins: { name: painless-allowlist } } …
Asserts the plugins array contains an object with a `name` property with the value `painless-whitelist`
Asserts the plugins array contains an object with a `name` property with the value `painless-allowlist`
## `transform_and_set`

View File

@ -39,7 +39,7 @@ import java.util.Arrays;
import static org.hamcrest.Matchers.equalTo;
public class MovFnWhitelistedFunctionTests extends OpenSearchTestCase {
public class MovFnAllowlistedFunctionTests extends OpenSearchTestCase {
public void testWindowMax() {
int numValues = randomIntBetween(1, 100);