Skip to content

Pattern exclusion not working properly on aliases when security is enabled #33805

Closed
@costin

Description

@costin

Elasticsearch version (bin/elasticsearch --version):
master

Plugins installed: []

JVM version (java -version):
Java 10.0.1+10

OS version (uname -a if on a Unix-like system):
Win 10

Description of the problem including expected versus actual behavior:

When security is enabled, pattern exclusion is not enforced for aliases either for GetAliases or GetIndex with new IndicesOptions(EnumSet.of(Option.IGNORE_ALIASES), EnumSet.of(WildcardStates.OPEN))

Without security these calls work properly (see #33395, thanks to @original-brownbear ).

Steps to reproduce:

Please include a minimal but complete recreation of the problem, including
(e.g.) index creation, mappings, settings, query etc. The easier you make for
us to reproduce it, the more likely that somebody will take the time to look at it.

  1. Create two indices and aliases that start with the same prefix
PUT test_index1
{
    "aliases" : {
        "test_alias1" : {},
        "test_alias2" : {}
        }
}

PUT test_index2
{
    "aliases" : {
        "test_alias1" : {},
        "test_alias2" : {}
        }
}

PUT test_index_noalias
{
}

GET /_cat/aliases?v

alias                  index                     filter routing.index routing.search
test_alias1         test_index2            -      -             -
test_alias2         test_index2            -      -             -
test_alias1         test_index1            -      -             -
test_alias2         test_index1            -      -             -
  1. GetAlias doesn't filter things

The following request:

 GetAliasesRequest aliasRequest = new GetAliasesRequest()
                    .local(true)
                    .aliases("test_*")
                    .aliases("-test_a*")
                    .indicesOptions(IndicesOptions.lenientExpandOpen());
   

Returns all aliases without excluding any.

  1. GetIndex options not being applied:
IndicesOptions INDICES_ONLY_OPTIONS = new IndicesOptions(
            EnumSet.of(Option.ALLOW_NO_INDICES, Option.IGNORE_UNAVAILABLE, Option.IGNORE_ALIASES), EnumSet.of(WildcardStates.OPEN));

GetIndexRequest indexRequest = new GetIndexRequest()
                    .local(true)
                    .indices("test_*")
                    .indices("-test_a*")
                    .features(Feature.SETTINGS)
                    .includeDefaults(false)
                    .indicesOptions(INDICES_ONLY_OPTIONS);
  

Aliases are being returned (meaning both the IndicesOptions and the pattern exclusion were not applied).

Provide logs (if relevant):

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions