Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into createpit
  • Loading branch information
bharath-techie committed May 18, 2022
2 parents c28762e + f021860 commit f272405
Show file tree
Hide file tree
Showing 77 changed files with 822 additions and 731 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion gradle/missing-javadoc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,13 +43,13 @@

public class AnalysisPainlessExtension implements PainlessExtension {

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

@Override
public Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists() {
public Map<ScriptContext<?>, List<Allowlist>> getContextAllowlists() {
return Collections.singletonMap(AnalysisPredicateScript.CONTEXT, Collections.singletonList(ALLOWLIST));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@
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;

import java.util.Collections;
import java.util.List;
import java.util.Map;

public class ProcessorsWhitelistExtension implements PainlessExtension {
public class ProcessorsAllowlistExtension implements PainlessExtension {

private static final Whitelist ALLOWLIST = WhitelistLoader.loadFromResourceFiles(
ProcessorsWhitelistExtension.class,
"processors_whitelist.txt"
private static final Allowlist ALLOWLIST = AllowlistLoader.loadFromResourceFiles(
ProcessorsAllowlistExtension.class,
"processors_allowlist.txt"
);

@Override
public Map<ScriptContext<?>, List<Whitelist>> getContextWhitelists() {
public Map<ScriptContext<?>, List<Allowlist>> getContextAllowlists() {
return Collections.singletonMap(IngestScript.CONTEXT, Collections.singletonList(ALLOWLIST));
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.opensearch.ingest.common.ProcessorsWhitelistExtension
org.opensearch.ingest.common.ProcessorsAllowlistExtension
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,12 +43,12 @@
* 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",
Expand All @@ -65,38 +65,38 @@ public final class Whitelist {
"java.util.regex.txt",
"java.util.stream.txt" };

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

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

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

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

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

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

/** Standard constructor. All values must be not {@code null}. */
public Whitelist(
public Allowlist(
ClassLoader classLoader,
List<WhitelistClass> allowlistClasses,
List<WhitelistMethod> allowlistImportedMethods,
List<WhitelistClassBinding> allowlistClassBindings,
List<WhitelistInstanceBinding> allowlistInstanceBindings
List<AllowlistClass> allowlistClasses,
List<AllowlistMethod> allowlistImportedMethods,
List<AllowlistClassBinding> allowlistClassBindings,
List<AllowlistInstanceBinding> allowlistInstanceBindings
) {

this.classLoader = Objects.requireNonNull(classLoader);
this.whitelistClasses = Collections.unmodifiableList(Objects.requireNonNull(allowlistClasses));
this.whitelistImportedMethods = Collections.unmodifiableList(Objects.requireNonNull(allowlistImportedMethods));
this.whitelistClassBindings = Collections.unmodifiableList(Objects.requireNonNull(allowlistClassBindings));
this.whitelistInstanceBindings = Collections.unmodifiableList(Objects.requireNonNull(allowlistInstanceBindings));
this.allowlistClasses = Collections.unmodifiableList(Objects.requireNonNull(allowlistClasses));
this.allowlistImportedMethods = Collections.unmodifiableList(Objects.requireNonNull(allowlistImportedMethods));
this.allowlistClassBindings = Collections.unmodifiableList(Objects.requireNonNull(allowlistClassBindings));
this.allowlistInstanceBindings = Collections.unmodifiableList(Objects.requireNonNull(allowlistInstanceBindings));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,42 +54,42 @@
* Classes will automatically extend other allowlisted classes if the Java class they represent is a
* subclass of other classes including Java interfaces.
*/
public final class WhitelistClass {
public final class AllowlistClass {

/** Information about where this class was white-listed from. */
/** Information about where this class was allow-listed from. */
public final String origin;

/** The Java class name this class represents. */
public final String javaClassName;

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

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

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

/** The {@link Map} of annotations for this class. */
public final Map<Class<?>, Object> painlessAnnotations;

/** Standard constructor. All values must be not {@code null}. */
public WhitelistClass(
public AllowlistClass(
String origin,
String javaClassName,
List<WhitelistConstructor> allowlistConstructors,
List<WhitelistMethod> allowlistMethods,
List<WhitelistField> allowlistFields,
List<AllowlistConstructor> allowlistConstructors,
List<AllowlistMethod> allowlistMethods,
List<AllowlistField> allowlistFields,
List<Object> painlessAnnotations
) {

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

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

if (painlessAnnotations.isEmpty()) {
this.painlessAnnotations = Collections.emptyMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* 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;
Expand All @@ -72,7 +72,7 @@ public class WhitelistClassBinding {
public final Map<Class<?>, Object> painlessAnnotations;

/** Standard constructor. All values must be not {@code null}. */
public WhitelistClassBinding(
public AllowlistClassBinding(
String origin,
String targetJavaClassName,
String methodName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
* 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;
Expand All @@ -60,7 +60,7 @@ public final class WhitelistConstructor {
public final Map<Class<?>, Object> painlessAnnotations;

/** Standard constructor. All values must be not {@code null}. */
public WhitelistConstructor(String origin, List<String> canonicalTypeNameParameters, List<Object> painlessAnnotations) {
public AllowlistConstructor(String origin, List<String> canonicalTypeNameParameters, List<Object> painlessAnnotations) {
this.origin = Objects.requireNonNull(origin);
this.canonicalTypeNameParameters = Collections.unmodifiableList(Objects.requireNonNull(canonicalTypeNameParameters));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* 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;
Expand All @@ -59,7 +59,7 @@ public class WhitelistField {
public final Map<Class<?>, Object> painlessAnnotations;

/** Standard constructor. All values must be not {@code null}. */
public WhitelistField(String origin, String fieldName, String canonicalTypeNameParameter, List<Object> painlessAnnotations) {
public AllowlistField(String origin, String fieldName, String canonicalTypeNameParameter, List<Object> painlessAnnotations) {
this.origin = Objects.requireNonNull(origin);
this.fieldName = Objects.requireNonNull(fieldName);
this.canonicalTypeNameParameter = Objects.requireNonNull(canonicalTypeNameParameter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
* 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;
Expand All @@ -68,7 +68,7 @@ public class WhitelistInstanceBinding {
public final Map<Class<?>, Object> painlessAnnotations;

/** Standard constructor. All values must be not {@code null}. */
public WhitelistInstanceBinding(
public AllowlistInstanceBinding(
String origin,
Object targetInstance,
String methodName,
Expand Down
Loading

0 comments on commit f272405

Please sign in to comment.