Skip to content

Commit

Permalink
Fix the inconsistent variable for DLS (#2056) (#2083)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Liang <[email protected]>

Signed-off-by: Ryan Liang <[email protected]>
(cherry picked from commit 1efc512)

Co-authored-by: Ryan Liang <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and RyanL1997 authored Sep 8, 2022
1 parent 0aedd61 commit 1d32fb1
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static boolean handle(String action, ActionRequest request, ActionListene
private final ThreadContext threadContext;
private final IndexNameExpressionResolver resolver;
private BoolQueryBuilder filterLevelQueryBuilder;
private DocumentAllowList documentWhitelist;
private DocumentAllowList documentAllowlist;

DlsFilterLevelActionHandler(String action, ActionRequest request, ActionListener<?> listener, EvaluatedDlsFlsConfig evaluatedDlsFlsConfig,
Resolved resolved, Client nodeClient, ClusterService clusterService, IndicesService indicesService,
Expand Down Expand Up @@ -178,8 +178,8 @@ private boolean handle() {
}

private boolean handle(SearchRequest searchRequest, StoredContext ctx) {
if (documentWhitelist != null) {
documentWhitelist.applyTo(threadContext);
if (documentAllowlist != null) {
documentAllowlist.applyTo(threadContext);
}

String localClusterAlias = LOCAL_CLUSTER_ALIAS_GETTER.apply(searchRequest);
Expand Down Expand Up @@ -225,8 +225,8 @@ public void onFailure(Exception e) {
}

private boolean handle(GetRequest getRequest, StoredContext ctx) {
if (documentWhitelist != null) {
documentWhitelist.applyTo(threadContext);
if (documentAllowlist != null) {
documentAllowlist.applyTo(threadContext);
}

SearchRequest searchRequest = new SearchRequest(getRequest.indices());
Expand Down Expand Up @@ -270,8 +270,8 @@ public void onFailure(Exception e) {
}

private boolean handle(MultiGetRequest multiGetRequest, StoredContext ctx) {
if (documentWhitelist != null) {
documentWhitelist.applyTo(threadContext);
if (documentAllowlist != null) {
documentAllowlist.applyTo(threadContext);
}

Map<String, Set<String>> idsGroupedByIndex = multiGetRequest.getItems().stream()
Expand Down Expand Up @@ -395,7 +395,7 @@ private boolean createQueryExtension(String localClusterAlias) throws IOExceptio
Map<String, Set<String>> filterLevelQueries = evaluatedDlsFlsConfig.getDlsQueriesByIndex();

BoolQueryBuilder dlsQueryBuilder = QueryBuilders.boolQuery().minimumShouldMatch(1);
DocumentAllowList documentWhitelist = new DocumentAllowList();
DocumentAllowList documentAllowlist = new DocumentAllowList();

int queryCount = 0;

Expand Down Expand Up @@ -450,7 +450,7 @@ private boolean createQueryExtension(String localClusterAlias) throws IOExceptio
for (QueryBuilder queryBuilder : queryBuilders) {
TermsQueryBuilder termsQueryBuilder = (TermsQueryBuilder) queryBuilder;

documentWhitelist.add(termsQueryBuilder.termsLookup().index(), termsQueryBuilder.termsLookup().id());
documentAllowlist.add(termsQueryBuilder.termsLookup().index(), termsQueryBuilder.termsLookup().id());
}
}

Expand All @@ -461,7 +461,7 @@ private boolean createQueryExtension(String localClusterAlias) throws IOExceptio
return false;
} else {
this.filterLevelQueryBuilder = dlsQueryBuilder;
this.documentWhitelist = documentWhitelist;
this.documentAllowlist = documentAllowlist;
return true;
}
}
Expand Down

0 comments on commit 1d32fb1

Please sign in to comment.