From 8f8909fd548dd6617a4d4cd57a9b06407f72a68f Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Tue, 17 May 2022 13:34:05 -0700 Subject: [PATCH] Replace 'whitelist' terminology in Java API (#3350) Signed-off-by: Tianli Feng --- .github/dependabot.yml | 2 +- gradle/missing-javadoc.gradle | 2 +- .../common/AnalysisPainlessExtension.java | 10 ++-- ...s_whitelist.txt => painless_allowlist.txt} | 0 ...java => ProcessorsAllowlistExtension.java} | 14 ++--- ....opensearch.painless.spi.PainlessExtension | 2 +- ...whitelist.txt => processors_allowlist.txt} | 0 .../spi/{Whitelist.java => Allowlist.java} | 40 +++++++------- ...hitelistClass.java => AllowlistClass.java} | 30 +++++------ ...inding.java => AllowlistClassBinding.java} | 4 +- ...tructor.java => AllowlistConstructor.java} | 6 +-- ...hitelistField.java => AllowlistField.java} | 4 +- ...ing.java => AllowlistInstanceBinding.java} | 4 +- ...telistLoader.java => AllowlistLoader.java} | 48 ++++++++--------- ...telistMethod.java => AllowlistMethod.java} | 6 +-- .../painless/spi/PainlessExtension.java | 2 +- ...er.java => AllowlistAnnotationParser.java} | 4 +- .../DeprecatedAnnotationParser.java | 2 +- .../InjectConstantAnnotationParser.java | 2 +- .../annotation/NoImportAnnotationParser.java | 2 +- .../NonDeterministicAnnotationParser.java | 2 +- .../org/opensearch/painless/Compiler.java | 4 +- .../opensearch/painless/PainlessPlugin.java | 30 +++++------ .../painless/PainlessScriptEngine.java | 8 +-- .../opensearch/painless/ScriptClassInfo.java | 8 +-- .../lookup/PainlessLookupBuilder.java | 36 ++++++------- ...erTests.java => AllowlistLoaderTests.java} | 30 +++++------ .../painless/AnnotationTestObject.java | 4 +- .../painless/AugmentationTests.java | 10 ++-- .../opensearch/painless/BaseClassTests.java | 54 +++++++++---------- .../painless/BasicStatementTests.java | 6 +-- .../opensearch/painless/BindingsTests.java | 20 +++---- .../org/opensearch/painless/DebugTests.java | 4 +- .../org/opensearch/painless/Debugger.java | 4 +- .../painless/DefBootstrapTests.java | 4 +- .../painless/DocFieldsPhaseTests.java | 4 +- .../org/opensearch/painless/FactoryTests.java | 22 ++++---- .../opensearch/painless/NeedsScoreTests.java | 6 +-- .../opensearch/painless/ScriptTestCase.java | 12 ++--- .../ScriptedMetricAggContextsTests.java | 12 ++--- .../painless/SimilarityScriptTests.java | 8 +-- ...a => ReindexFromRemoteAllowlistTests.java} | 18 +++---- .../repositories/url/URLRepositoryTests.java | 4 +- plugins/examples/build.gradle | 2 +- .../build.gradle | 4 +- .../ExampleAllowlistAnnotationParser.java} | 10 ++-- .../ExampleAllowlistExtension.java} | 28 +++++----- .../ExampleAllowlistedClass.java} | 8 +-- .../ExampleAllowlistedInstance.java} | 6 +-- .../ExamplePainlessAnnotation.java | 2 +- .../ExampleStaticMethodClass.java | 2 +- .../painlessallowlist/MyAllowlistPlugin.java} | 4 +- ....opensearch.painless.spi.PainlessExtension | 1 + .../painlessallowlist/example_allowlist.txt} | 6 +-- ...inlessAllowlistClientYamlTestSuiteIT.java} | 6 +-- .../test/painless_allowlist}/10_basic.yml | 2 +- .../test/painless_allowlist/20_allowlist.yml} | 4 +- .../test/painless_allowlist}/30_static.yml | 0 .../test/painless_allowlist}/40_instance.yml | 0 ....opensearch.painless.spi.PainlessExtension | 1 - .../resources/rest-api-spec/test/README.md | 4 +- ...ava => MovFnAllowlistedFunctionTests.java} | 2 +- 62 files changed, 293 insertions(+), 293 deletions(-) rename modules/analysis-common/src/main/resources/org/opensearch/analysis/common/{painless_whitelist.txt => painless_allowlist.txt} (100%) rename modules/ingest-common/src/main/java/org/opensearch/ingest/common/{ProcessorsWhitelistExtension.java => ProcessorsAllowlistExtension.java} (79%) rename modules/ingest-common/src/main/resources/org/opensearch/ingest/common/{processors_whitelist.txt => processors_allowlist.txt} (100%) rename modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/{Whitelist.java => Allowlist.java} (69%) rename modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/{WhitelistClass.java => AllowlistClass.java} (81%) rename modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/{WhitelistClassBinding.java => AllowlistClassBinding.java} (98%) rename modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/{WhitelistConstructor.java => AllowlistConstructor.java} (95%) rename modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/{WhitelistField.java => AllowlistField.java} (96%) rename modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/{WhitelistInstanceBinding.java => AllowlistInstanceBinding.java} (97%) rename modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/{WhitelistLoader.java => AllowlistLoader.java} (95%) rename modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/{WhitelistMethod.java => AllowlistMethod.java} (98%) rename modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/{WhitelistAnnotationParser.java => AllowlistAnnotationParser.java} (94%) rename modules/lang-painless/src/test/java/org/opensearch/painless/{WhitelistLoaderTests.java => AllowlistLoaderTests.java} (80%) rename modules/reindex/src/test/java/org/opensearch/index/reindex/{ReindexFromRemoteWhitelistTests.java => ReindexFromRemoteAllowlistTests.java} (92%) rename plugins/examples/{painless-whitelist => painless-allowlist}/build.gradle (94%) rename plugins/examples/{painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistAnnotationParser.java => painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistAnnotationParser.java} (86%) rename plugins/examples/{painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistExtension.java => painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistExtension.java} (69%) rename plugins/examples/{painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistedClass.java => painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistedClass.java} (90%) rename plugins/examples/{painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistedInstance.java => painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistedInstance.java} (90%) rename plugins/examples/{painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist => painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist}/ExamplePainlessAnnotation.java (96%) rename plugins/examples/{painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist => painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist}/ExampleStaticMethodClass.java (96%) rename plugins/examples/{painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/MyWhitelistPlugin.java => painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/MyAllowlistPlugin.java} (92%) create mode 100644 plugins/examples/painless-allowlist/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension rename plugins/examples/{painless-whitelist/src/main/resources/org/opensearch/example/painlesswhitelist/example_whitelist.txt => painless-allowlist/src/main/resources/org/opensearch/example/painlessallowlist/example_allowlist.txt} (90%) rename plugins/examples/{painless-whitelist/src/yamlRestTest/java/org/opensearch/example/painlesswhitelist/PainlessWhitelistClientYamlTestSuiteIT.java => painless-allowlist/src/yamlRestTest/java/org/opensearch/example/painlessallowlist/PainlessAllowlistClientYamlTestSuiteIT.java} (90%) rename plugins/examples/{painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist => painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist}/10_basic.yml (95%) rename plugins/examples/{painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/20_whitelist.yml => painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/20_allowlist.yml} (73%) rename plugins/examples/{painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist => painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist}/30_static.yml (100%) rename plugins/examples/{painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist => painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist}/40_instance.yml (100%) delete mode 100644 plugins/examples/painless-whitelist/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension rename server/src/test/java/org/opensearch/search/aggregations/pipeline/{MovFnWhitelistedFunctionTests.java => MovFnAllowlistedFunctionTests.java} (99%) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ca972d1b242..9682461d9e1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -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: diff --git a/gradle/missing-javadoc.gradle b/gradle/missing-javadoc.gradle index 2313807e0bd..d927bc8a2d0 100644 --- a/gradle/missing-javadoc.gradle +++ b/gradle/missing-javadoc.gradle @@ -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"), diff --git a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/AnalysisPainlessExtension.java b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/AnalysisPainlessExtension.java index 1c13e51788f..8924e2d314c 100644 --- a/modules/analysis-common/src/main/java/org/opensearch/analysis/common/AnalysisPainlessExtension.java +++ b/modules/analysis-common/src/main/java/org/opensearch/analysis/common/AnalysisPainlessExtension.java @@ -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, List> getContextWhitelists() { + public Map, List> getContextAllowlists() { return Collections.singletonMap(AnalysisPredicateScript.CONTEXT, Collections.singletonList(ALLOWLIST)); } } diff --git a/modules/analysis-common/src/main/resources/org/opensearch/analysis/common/painless_whitelist.txt b/modules/analysis-common/src/main/resources/org/opensearch/analysis/common/painless_allowlist.txt similarity index 100% rename from modules/analysis-common/src/main/resources/org/opensearch/analysis/common/painless_whitelist.txt rename to modules/analysis-common/src/main/resources/org/opensearch/analysis/common/painless_allowlist.txt diff --git a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ProcessorsWhitelistExtension.java b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ProcessorsAllowlistExtension.java similarity index 79% rename from modules/ingest-common/src/main/java/org/opensearch/ingest/common/ProcessorsWhitelistExtension.java rename to modules/ingest-common/src/main/java/org/opensearch/ingest/common/ProcessorsAllowlistExtension.java index c45104873c7..1ba16ae2ccd 100644 --- a/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ProcessorsWhitelistExtension.java +++ b/modules/ingest-common/src/main/java/org/opensearch/ingest/common/ProcessorsAllowlistExtension.java @@ -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, List> getContextWhitelists() { + public Map, List> getContextAllowlists() { return Collections.singletonMap(IngestScript.CONTEXT, Collections.singletonList(ALLOWLIST)); } } diff --git a/modules/ingest-common/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension b/modules/ingest-common/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension index faa5444fc8d..b6a078720f6 100644 --- a/modules/ingest-common/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension +++ b/modules/ingest-common/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension @@ -1 +1 @@ -org.opensearch.ingest.common.ProcessorsWhitelistExtension +org.opensearch.ingest.common.ProcessorsAllowlistExtension diff --git a/modules/ingest-common/src/main/resources/org/opensearch/ingest/common/processors_whitelist.txt b/modules/ingest-common/src/main/resources/org/opensearch/ingest/common/processors_allowlist.txt similarity index 100% rename from modules/ingest-common/src/main/resources/org/opensearch/ingest/common/processors_whitelist.txt rename to modules/ingest-common/src/main/resources/org/opensearch/ingest/common/processors_allowlist.txt diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/Whitelist.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/Allowlist.java similarity index 69% rename from modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/Whitelist.java rename to modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/Allowlist.java index b400c7a027f..56ade63efa5 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/Whitelist.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/Allowlist.java @@ -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 BASE_WHITELISTS = Collections.singletonList( - WhitelistLoader.loadFromResourceFiles(Whitelist.class, WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS, BASE_ALLOWLIST_FILES) + public static final List 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 whitelistClasses; + public final List allowlistClasses; /** The {@link List} of all the allowlisted static Painless methods. */ - public final List whitelistImportedMethods; + public final List allowlistImportedMethods; /** The {@link List} of all the allowlisted Painless class bindings. */ - public final List whitelistClassBindings; + public final List allowlistClassBindings; /** The {@link List} of all the allowlisted Painless instance bindings. */ - public final List whitelistInstanceBindings; + public final List allowlistInstanceBindings; /** Standard constructor. All values must be not {@code null}. */ - public Whitelist( + public Allowlist( ClassLoader classLoader, - List allowlistClasses, - List allowlistImportedMethods, - List allowlistClassBindings, - List allowlistInstanceBindings + List allowlistClasses, + List allowlistImportedMethods, + List allowlistClassBindings, + List 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)); } } diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistClass.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistClass.java similarity index 81% rename from modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistClass.java rename to modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistClass.java index bf5083998f9..17e6814addf 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistClass.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistClass.java @@ -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 whitelistConstructors; + /** The {@link List} of allowlisted ({@link AllowlistConstructor}s) available to this class. */ + public final List allowlistConstructors; - /** The {@link List} of allowlisted ({@link WhitelistMethod}s) available to this class. */ - public final List whitelistMethods; + /** The {@link List} of allowlisted ({@link AllowlistMethod}s) available to this class. */ + public final List allowlistMethods; - /** The {@link List} of allowlisted ({@link WhitelistField}s) available to this class. */ - public final List whitelistFields; + /** The {@link List} of allowlisted ({@link AllowlistField}s) available to this class. */ + public final List allowlistFields; /** The {@link Map} of annotations for this class. */ public final Map, Object> painlessAnnotations; /** Standard constructor. All values must be not {@code null}. */ - public WhitelistClass( + public AllowlistClass( String origin, String javaClassName, - List allowlistConstructors, - List allowlistMethods, - List allowlistFields, + List allowlistConstructors, + List allowlistMethods, + List allowlistFields, List 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(); diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistClassBinding.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistClassBinding.java similarity index 98% rename from modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistClassBinding.java rename to modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistClassBinding.java index 15ce4b84c4b..147712babef 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistClassBinding.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistClassBinding.java @@ -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, Object> painlessAnnotations; /** Standard constructor. All values must be not {@code null}. */ - public WhitelistClassBinding( + public AllowlistClassBinding( String origin, String targetJavaClassName, String methodName, diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistConstructor.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistConstructor.java similarity index 95% rename from modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistConstructor.java rename to modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistConstructor.java index 30182996825..603df930033 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistConstructor.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistConstructor.java @@ -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, Object> painlessAnnotations; /** Standard constructor. All values must be not {@code null}. */ - public WhitelistConstructor(String origin, List canonicalTypeNameParameters, List painlessAnnotations) { + public AllowlistConstructor(String origin, List canonicalTypeNameParameters, List painlessAnnotations) { this.origin = Objects.requireNonNull(origin); this.canonicalTypeNameParameters = Collections.unmodifiableList(Objects.requireNonNull(canonicalTypeNameParameters)); diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistField.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistField.java similarity index 96% rename from modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistField.java rename to modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistField.java index cc3f6290a6c..b3dfcff6b70 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistField.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistField.java @@ -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, Object> painlessAnnotations; /** Standard constructor. All values must be not {@code null}. */ - public WhitelistField(String origin, String fieldName, String canonicalTypeNameParameter, List painlessAnnotations) { + public AllowlistField(String origin, String fieldName, String canonicalTypeNameParameter, List painlessAnnotations) { this.origin = Objects.requireNonNull(origin); this.fieldName = Objects.requireNonNull(fieldName); this.canonicalTypeNameParameter = Objects.requireNonNull(canonicalTypeNameParameter); diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistInstanceBinding.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistInstanceBinding.java similarity index 97% rename from modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistInstanceBinding.java rename to modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistInstanceBinding.java index 7e9bf0af94b..89a03220c84 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistInstanceBinding.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistInstanceBinding.java @@ -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, Object> painlessAnnotations; /** Standard constructor. All values must be not {@code null}. */ - public WhitelistInstanceBinding( + public AllowlistInstanceBinding( String origin, Object targetInstance, String methodName, diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistLoader.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistLoader.java similarity index 95% rename from modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistLoader.java rename to modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistLoader.java index 2da6d8fce1d..71265f82aca 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistLoader.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistLoader.java @@ -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 parsers, String... filepaths) { - List allowlistClasses = new ArrayList<>(); - List allowlistStatics = new ArrayList<>(); - List allowlistClassBindings = new ArrayList<>(); + public static Allowlist loadFromResourceFiles(Class resource, Map parsers, String... filepaths) { + List allowlistClasses = new ArrayList<>(); + List allowlistStatics = new ArrayList<>(); + List 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 allowlistConstructors = null; - List allowlistMethods = null; - List allowlistFields = null; + List allowlistConstructors = null; + List allowlistMethods = null; + List allowlistFields = null; List 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) resource::getClassLoader); - return new Whitelist(loader, allowlistClasses, allowlistStatics, allowlistClassBindings, Collections.emptyList()); + return new Allowlist(loader, allowlistClasses, allowlistStatics, allowlistClassBindings, Collections.emptyList()); } - private static List parseAllowlistAnnotations(Map parsers, String line) { + private static List parseAllowlistAnnotations(Map parsers, String line) { List 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() {} } diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistMethod.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistMethod.java similarity index 98% rename from modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistMethod.java rename to modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistMethod.java index 9a57a5a098c..8bb0231ff3f 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/WhitelistMethod.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/AllowlistMethod.java @@ -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, diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/PainlessExtension.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/PainlessExtension.java index 5f4be939f80..fae4ba663f5 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/PainlessExtension.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/PainlessExtension.java @@ -39,5 +39,5 @@ import java.util.Map; public interface PainlessExtension { - Map, List> getContextWhitelists(); + Map, List> getContextAllowlists(); } diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/WhitelistAnnotationParser.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/AllowlistAnnotationParser.java similarity index 94% rename from modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/WhitelistAnnotationParser.java rename to modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/AllowlistAnnotationParser.java index 9874c61b2a0..e43240eb1fe 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/WhitelistAnnotationParser.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/AllowlistAnnotationParser.java @@ -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 BASE_ANNOTATION_PARSERS = Collections.unmodifiableMap( + Map BASE_ANNOTATION_PARSERS = Collections.unmodifiableMap( Stream.of( new AbstractMap.SimpleEntry<>(NoImportAnnotation.NAME, NoImportAnnotationParser.INSTANCE), new AbstractMap.SimpleEntry<>(DeprecatedAnnotation.NAME, DeprecatedAnnotationParser.INSTANCE), diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/DeprecatedAnnotationParser.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/DeprecatedAnnotationParser.java index 52d7c1819d4..5c0c5812df4 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/DeprecatedAnnotationParser.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/DeprecatedAnnotationParser.java @@ -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(); diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/InjectConstantAnnotationParser.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/InjectConstantAnnotationParser.java index 6cb856cd33d..f0263c6aec1 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/InjectConstantAnnotationParser.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/InjectConstantAnnotationParser.java @@ -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(); diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/NoImportAnnotationParser.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/NoImportAnnotationParser.java index 5a4110225aa..671fb9d2cda 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/NoImportAnnotationParser.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/NoImportAnnotationParser.java @@ -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(); diff --git a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/NonDeterministicAnnotationParser.java b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/NonDeterministicAnnotationParser.java index 47d5eddc60e..54f3729732b 100644 --- a/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/NonDeterministicAnnotationParser.java +++ b/modules/lang-painless/spi/src/main/java/org/opensearch/painless/spi/annotation/NonDeterministicAnnotationParser.java @@ -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(); diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/Compiler.java b/modules/lang-painless/src/main/java/org/opensearch/painless/Compiler.java index eca931d87b6..7b9efa4deb2 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/Compiler.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/Compiler.java @@ -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}. */ diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessPlugin.java b/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessPlugin.java index 09a23c15f34..9a235df0fb1 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessPlugin.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessPlugin.java @@ -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, List> allowlists; + private static final Map, List> 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, List> map = new HashMap<>(); + Map, List> map = new HashMap<>(); // Moving Function Pipeline Agg - List movFn = new ArrayList<>(Whitelist.BASE_WHITELISTS); - movFn.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.aggs.movfn.txt")); + List 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 scoreFn = new ArrayList<>(Whitelist.BASE_WHITELISTS); - scoreFn.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.score.txt")); + List 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 ingest = new ArrayList<>(Whitelist.BASE_WHITELISTS); - ingest.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.ingest.txt")); + List 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> contexts) { - Map, List> contextsWithAllowlists = new HashMap<>(); + Map, List> 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 contextAllowlists = allowlists.get(context); + List 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 existing = allowlists.computeIfAbsent(entry.getKey(), c -> new ArrayList<>(Whitelist.BASE_WHITELISTS)); + List existing = allowlists.computeIfAbsent(entry.getKey(), c -> new ArrayList<>(Allowlist.BASE_ALLOWLISTS)); existing.addAll(entry.getValue()); }); } diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessScriptEngine.java b/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessScriptEngine.java index 1663185ae7c..ca6e6870670 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessScriptEngine.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/PainlessScriptEngine.java @@ -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, List> contexts) { + public PainlessScriptEngine(Settings settings, Map, List> contexts) { defaultCompilerSettings.setRegexesEnabled(CompilerSettings.REGEX_ENABLED.get(settings)); defaultCompilerSettings.setRegexLimitFactor(CompilerSettings.REGEX_LIMIT_FACTOR.get(settings)); Map, Compiler> contextsToCompilers = new HashMap<>(); Map, PainlessLookup> contextsToLookups = new HashMap<>(); - for (Map.Entry, List> entry : contexts.entrySet()) { + for (Map.Entry, List> 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) diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/ScriptClassInfo.java b/modules/lang-painless/src/main/java/org/opensearch/painless/ScriptClassInfo.java index a9d5a7abbb1..e80f9244268 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/ScriptClassInfo.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/ScriptClassInfo.java @@ -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); } diff --git a/modules/lang-painless/src/main/java/org/opensearch/painless/lookup/PainlessLookupBuilder.java b/modules/lang-painless/src/main/java/org/opensearch/painless/lookup/PainlessLookupBuilder.java index ff3fbc640e9..e43d1beb9b2 100644 --- a/modules/lang-painless/src/main/java/org/opensearch/painless/lookup/PainlessLookupBuilder.java +++ b/modules/lang-painless/src/main/java/org/opensearch/painless/lookup/PainlessLookupBuilder.java @@ -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 allowlists) { + public static PainlessLookup buildFromAllowlists(List 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, diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/WhitelistLoaderTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/AllowlistLoaderTests.java similarity index 80% rename from modules/lang-painless/src/test/java/org/opensearch/painless/WhitelistLoaderTests.java rename to modules/lang-painless/src/test/java/org/opensearch/painless/AllowlistLoaderTests.java index e4e754a5414..828ff267912 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/WhitelistLoaderTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/AllowlistLoaderTests.java @@ -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 parsers = new HashMap<>(WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS); + Map 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 parsers = new HashMap<>(WhitelistAnnotationParser.BASE_ANNOTATION_PARSERS); + Map 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", diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/AnnotationTestObject.java b/modules/lang-painless/src/test/java/org/opensearch/painless/AnnotationTestObject.java index b8aed47696b..c71a468989b 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/AnnotationTestObject.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/AnnotationTestObject.java @@ -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(); diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/AugmentationTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/AugmentationTests.java index 98b0cad9960..8740e1fc8f9 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/AugmentationTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/AugmentationTests.java @@ -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, List> contexts = newDefaultContexts(); - List digestAllowlist = new ArrayList<>(Whitelist.BASE_WHITELISTS); - digestAllowlist.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.ingest.txt")); + Map, List> contexts = newDefaultContexts(); + List 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); } diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/BaseClassTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/BaseClassTests.java index 6892974b6ca..29bf5df28db 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/BaseClassTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/BaseClassTests.java @@ -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, List> 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, List> 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() ); } diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/BasicStatementTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/BasicStatementTests.java index 403bd12147c..a2ddec10e3c 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/BasicStatementTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/BasicStatementTests.java @@ -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, List> contexts = newDefaultContexts(); - contexts.put(OneArg.CONTEXT, Whitelist.BASE_WHITELISTS); + Map, List> contexts = newDefaultContexts(); + contexts.put(OneArg.CONTEXT, Allowlist.BASE_ALLOWLISTS); SCRIPT_ENGINE = new PainlessScriptEngine(Settings.EMPTY, contexts); } diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/BindingsTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/BindingsTests.java index e5113d93677..f4435bc8659 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/BindingsTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/BindingsTests.java @@ -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, List> contexts = newDefaultContexts(); - List allowlists = new ArrayList<>(Whitelist.BASE_WHITELISTS); - allowlists.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.painless.test")); + Map, List> contexts = newDefaultContexts(); + List 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 instanceBindingsList = new ArrayList<>(); + List instanceBindingsList = new ArrayList<>(); instanceBindingsList.add(getter); instanceBindingsList.add(setter); - Whitelist instanceBindingsAllowlist = new Whitelist( + Allowlist instanceBindingsAllowlist = new Allowlist( instanceBindingTestClass.getClass().getClassLoader(), Collections.emptyList(), Collections.emptyList(), diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/DebugTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/DebugTests.java index 285de018f1d..90bb6bac30f 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/DebugTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/DebugTests.java @@ -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 diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/Debugger.java b/modules/lang-painless/src/test/java/org/opensearch/painless/Debugger.java index 31233bd7518..9b3b0c247f8 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/Debugger.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/Debugger.java @@ -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) { diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/DefBootstrapTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/DefBootstrapTests.java index 9134d7a3c06..856f17d4aae 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/DefBootstrapTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/DefBootstrapTests.java @@ -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 { diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/DocFieldsPhaseTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/DocFieldsPhaseTests.java index 6a6634a823e..3418bcf01e1 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/DocFieldsPhaseTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/DocFieldsPhaseTests.java @@ -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( diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/FactoryTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/FactoryTests.java index 7ee0bd6fc09..95b18cf1c52 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/FactoryTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/FactoryTests.java @@ -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, List> 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, List> 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); } diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/NeedsScoreTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/NeedsScoreTests.java index c619e849267..9f87fbedb2a 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/NeedsScoreTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/NeedsScoreTests.java @@ -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, List> contexts = new HashMap<>(); - contexts.put(NumberSortScript.CONTEXT, Whitelist.BASE_WHITELISTS); + Map, List> 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); diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/ScriptTestCase.java b/modules/lang-painless/src/test/java/org/opensearch/painless/ScriptTestCase.java index a30aa97d334..1f8824113df 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/ScriptTestCase.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/ScriptTestCase.java @@ -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, List> newDefaultContexts() { - Map, List> contexts = new HashMap<>(); - List allowlists = new ArrayList<>(Whitelist.BASE_WHITELISTS); - allowlists.add(WhitelistLoader.loadFromResourceFiles(Whitelist.class, "org.opensearch.painless.test")); + protected static Map, List> newDefaultContexts() { + Map, List> contexts = new HashMap<>(); + List allowlists = new ArrayList<>(Allowlist.BASE_ALLOWLISTS); + allowlists.add(AllowlistLoader.loadFromResourceFiles(Allowlist.class, "org.opensearch.painless.test")); contexts.put(PainlessTestScript.CONTEXT, allowlists); return contexts; } diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/ScriptedMetricAggContextsTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/ScriptedMetricAggContextsTests.java index af28a3f850d..e9d800b39f0 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/ScriptedMetricAggContextsTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/ScriptedMetricAggContextsTests.java @@ -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, List> 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, List> 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); } diff --git a/modules/lang-painless/src/test/java/org/opensearch/painless/SimilarityScriptTests.java b/modules/lang-painless/src/test/java/org/opensearch/painless/SimilarityScriptTests.java index 9b404853cf7..ac8f45bb598 100644 --- a/modules/lang-painless/src/test/java/org/opensearch/painless/SimilarityScriptTests.java +++ b/modules/lang-painless/src/test/java/org/opensearch/painless/SimilarityScriptTests.java @@ -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, List> contexts = new HashMap<>(); - contexts.put(SimilarityScript.CONTEXT, Whitelist.BASE_WHITELISTS); - contexts.put(SimilarityWeightScript.CONTEXT, Whitelist.BASE_WHITELISTS); + Map, List> contexts = new HashMap<>(); + contexts.put(SimilarityScript.CONTEXT, Allowlist.BASE_ALLOWLISTS); + contexts.put(SimilarityWeightScript.CONTEXT, Allowlist.BASE_ALLOWLISTS); SCRIPT_ENGINE = new PainlessScriptEngine(Settings.EMPTY, contexts); } diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexFromRemoteWhitelistTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexFromRemoteAllowlistTests.java similarity index 92% rename from modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexFromRemoteWhitelistTests.java rename to modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexFromRemoteAllowlistTests.java index 8012b67253c..7ade56e378a 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexFromRemoteWhitelistTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexFromRemoteAllowlistTests.java @@ -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 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 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 allowlist = randomBoolean() ? randomAllowlist() : emptyList(); Exception e = expectThrows( diff --git a/modules/repository-url/src/test/java/org/opensearch/repositories/url/URLRepositoryTests.java b/modules/repository-url/src/test/java/org/opensearch/repositories/url/URLRepositoryTests.java index 30d1c81fc9e..95ae348d0fb 100644 --- a/modules/repository-url/src/test/java/org/opensearch/repositories/url/URLRepositoryTests.java +++ b/modules/repository-url/src/test/java/org/opensearch/repositories/url/URLRepositoryTests.java @@ -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()) diff --git a/plugins/examples/build.gradle b/plugins/examples/build.gradle index 460c6e81eac..7b91333c62d 100644 --- a/plugins/examples/build.gradle +++ b/plugins/examples/build.gradle @@ -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') diff --git a/plugins/examples/painless-whitelist/build.gradle b/plugins/examples/painless-allowlist/build.gradle similarity index 94% rename from plugins/examples/painless-whitelist/build.gradle rename to plugins/examples/painless-allowlist/build.gradle index 70052c209ab..99722126dd1 100644 --- a/plugins/examples/painless-whitelist/build.gradle +++ b/plugins/examples/painless-allowlist/build.gradle @@ -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') diff --git a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistAnnotationParser.java b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistAnnotationParser.java similarity index 86% rename from plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistAnnotationParser.java rename to plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistAnnotationParser.java index 2ffd866ac47..3f876cebf6b 100644 --- a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistAnnotationParser.java +++ b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistAnnotationParser.java @@ -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() { } diff --git a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistExtension.java b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistExtension.java similarity index 69% rename from plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistExtension.java rename to plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistExtension.java index 74adcf5e4f5..b8916bb7954 100644 --- a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistExtension.java +++ b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistExtension.java @@ -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, List> getContextWhitelists() { - Map 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, List> getContextAllowlists() { + Map 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(), diff --git a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistedClass.java b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistedClass.java similarity index 90% rename from plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistedClass.java rename to plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistedClass.java index 5832a2ee59a..79de22b9aba 100644 --- a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistedClass.java +++ b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistedClass.java @@ -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 example_whitelist.txt. + * See example_allowlist.txt. */ -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; } diff --git a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistedInstance.java b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistedInstance.java similarity index 90% rename from plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistedInstance.java rename to plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistedInstance.java index 1777a21476f..b4af91d9f15 100644 --- a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleWhitelistedInstance.java +++ b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleAllowlistedInstance.java @@ -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; } diff --git a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExamplePainlessAnnotation.java b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExamplePainlessAnnotation.java similarity index 96% rename from plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExamplePainlessAnnotation.java rename to plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExamplePainlessAnnotation.java index c053ecee333..1b33f7fd49a 100644 --- a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExamplePainlessAnnotation.java +++ b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExamplePainlessAnnotation.java @@ -30,7 +30,7 @@ * GitHub history for details. */ -package org.opensearch.example.painlesswhitelist; +package org.opensearch.example.painlessallowlist; public class ExamplePainlessAnnotation { diff --git a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleStaticMethodClass.java b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleStaticMethodClass.java similarity index 96% rename from plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleStaticMethodClass.java rename to plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleStaticMethodClass.java index 5589f4894c1..a226ed6b086 100644 --- a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/ExampleStaticMethodClass.java +++ b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/ExampleStaticMethodClass.java @@ -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) { diff --git a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/MyWhitelistPlugin.java b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/MyAllowlistPlugin.java similarity index 92% rename from plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/MyWhitelistPlugin.java rename to plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/MyAllowlistPlugin.java index ab6ba53e403..fdae22783cf 100644 --- a/plugins/examples/painless-whitelist/src/main/java/org/opensearch/example/painlesswhitelist/MyWhitelistPlugin.java +++ b/plugins/examples/painless-allowlist/src/main/java/org/opensearch/example/painlessallowlist/MyAllowlistPlugin.java @@ -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 } diff --git a/plugins/examples/painless-allowlist/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension b/plugins/examples/painless-allowlist/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension new file mode 100644 index 00000000000..448f78e2afc --- /dev/null +++ b/plugins/examples/painless-allowlist/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension @@ -0,0 +1 @@ +org.opensearch.example.painlessallowlist.ExampleAllowlistExtension diff --git a/plugins/examples/painless-whitelist/src/main/resources/org/opensearch/example/painlesswhitelist/example_whitelist.txt b/plugins/examples/painless-allowlist/src/main/resources/org/opensearch/example/painlessallowlist/example_allowlist.txt similarity index 90% rename from plugins/examples/painless-whitelist/src/main/resources/org/opensearch/example/painlesswhitelist/example_whitelist.txt rename to plugins/examples/painless-allowlist/src/main/resources/org/opensearch/example/painlessallowlist/example_allowlist.txt index 8f2ccaf05f2..31bbd087b5c 100644 --- a/plugins/examples/painless-whitelist/src/main/resources/org/opensearch/example/painlesswhitelist/example_whitelist.txt +++ b/plugins/examples/painless-allowlist/src/main/resources/org/opensearch/example/painlessallowlist/example_allowlist.txt @@ -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 } diff --git a/plugins/examples/painless-whitelist/src/yamlRestTest/java/org/opensearch/example/painlesswhitelist/PainlessWhitelistClientYamlTestSuiteIT.java b/plugins/examples/painless-allowlist/src/yamlRestTest/java/org/opensearch/example/painlessallowlist/PainlessAllowlistClientYamlTestSuiteIT.java similarity index 90% rename from plugins/examples/painless-whitelist/src/yamlRestTest/java/org/opensearch/example/painlesswhitelist/PainlessWhitelistClientYamlTestSuiteIT.java rename to plugins/examples/painless-allowlist/src/yamlRestTest/java/org/opensearch/example/painlessallowlist/PainlessAllowlistClientYamlTestSuiteIT.java index 63214ad3de6..346d91bb27f 100644 --- a/plugins/examples/painless-whitelist/src/yamlRestTest/java/org/opensearch/example/painlesswhitelist/PainlessWhitelistClientYamlTestSuiteIT.java +++ b/plugins/examples/painless-allowlist/src/yamlRestTest/java/org/opensearch/example/painlessallowlist/PainlessAllowlistClientYamlTestSuiteIT.java @@ -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); } diff --git a/plugins/examples/painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/10_basic.yml b/plugins/examples/painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/10_basic.yml similarity index 95% rename from plugins/examples/painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/10_basic.yml rename to plugins/examples/painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/10_basic.yml index fab9789eeec..d8043136de5 100644 --- a/plugins/examples/painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/10_basic.yml +++ b/plugins/examples/painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/10_basic.yml @@ -13,4 +13,4 @@ - do: nodes.info: {} - - contains: { nodes.$cluster_manager.plugins: { name: painless-whitelist } } + - contains: { nodes.$cluster_manager.plugins: { name: painless-allowlist } } diff --git a/plugins/examples/painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/20_whitelist.yml b/plugins/examples/painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/20_allowlist.yml similarity index 73% rename from plugins/examples/painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/20_whitelist.yml rename to plugins/examples/painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/20_allowlist.yml index 92289af1792..bda19289359 100644 --- a/plugins/examples/painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/20_whitelist.yml +++ b/plugins/examples/painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/20_allowlist.yml @@ -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 } diff --git a/plugins/examples/painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/30_static.yml b/plugins/examples/painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/30_static.yml similarity index 100% rename from plugins/examples/painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/30_static.yml rename to plugins/examples/painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/30_static.yml diff --git a/plugins/examples/painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/40_instance.yml b/plugins/examples/painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/40_instance.yml similarity index 100% rename from plugins/examples/painless-whitelist/src/yamlRestTest/resources/rest-api-spec/test/painless_whitelist/40_instance.yml rename to plugins/examples/painless-allowlist/src/yamlRestTest/resources/rest-api-spec/test/painless_allowlist/40_instance.yml diff --git a/plugins/examples/painless-whitelist/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension b/plugins/examples/painless-whitelist/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension deleted file mode 100644 index e70236e92e6..00000000000 --- a/plugins/examples/painless-whitelist/src/main/resources/META-INF/services/org.opensearch.painless.spi.PainlessExtension +++ /dev/null @@ -1 +0,0 @@ -org.opensearch.example.painlesswhitelist.ExampleWhitelistExtension diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/README.md b/rest-api-spec/src/main/resources/rest-api-spec/test/README.md index cfaba9a2347..da97910df17 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/README.md +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/README.md @@ -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` diff --git a/server/src/test/java/org/opensearch/search/aggregations/pipeline/MovFnWhitelistedFunctionTests.java b/server/src/test/java/org/opensearch/search/aggregations/pipeline/MovFnAllowlistedFunctionTests.java similarity index 99% rename from server/src/test/java/org/opensearch/search/aggregations/pipeline/MovFnWhitelistedFunctionTests.java rename to server/src/test/java/org/opensearch/search/aggregations/pipeline/MovFnAllowlistedFunctionTests.java index ca49d8e860b..59bf1607e1b 100644 --- a/server/src/test/java/org/opensearch/search/aggregations/pipeline/MovFnWhitelistedFunctionTests.java +++ b/server/src/test/java/org/opensearch/search/aggregations/pipeline/MovFnAllowlistedFunctionTests.java @@ -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);