Skip to content

Commit

Permalink
Allow kibana_system to upgrade endpoint hidden indices (#80140) (#80235)
Browse files Browse the repository at this point in the history
Following hidden indices that are included in the Endpoint package cannot be 
upgraded by kibana_system without these privileges:

.logs-endpoint.action.responses-*
.logs-endpoint.diagnostic.collection-*
.logs-endpoint.actions-*

Fixes elastic/kibana#116396
  • Loading branch information
joshdover authored Nov 3, 2021
1 parent 70f286b commit a786add
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -684,9 +684,17 @@ public static RoleDescriptor kibanaSystemRoleDescriptor(String name) {
RoleDescriptor.IndicesPrivileges.builder().indices("metrics-endpoint.policy-*").privileges("read").build(),
// Endpoint metrics. Kibana requires read access to send telemetry
RoleDescriptor.IndicesPrivileges.builder().indices("metrics-endpoint.metrics-*").privileges("read").build(),
// Fleet package upgrade
// Fleet package install and upgrade
RoleDescriptor.IndicesPrivileges.builder()
.indices("logs-*", "synthetics-*", "traces-*", "/metrics-.*&~(metrics-endpoint\\.metadata_current_default)/")
.indices(
"logs-*",
"synthetics-*",
"traces-*",
"/metrics-.*&~(metrics-endpoint\\.metadata_current_default)/",
".logs-endpoint.action.responses-*",
".logs-endpoint.diagnostic.collection-*",
".logs-endpoint.actions-*"
)
.privileges(UpdateSettingsAction.NAME, PutMappingAction.NAME, RolloverAction.NAME)
.build(),
// For src/dest indices of the Endpoint package that ships a transform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,15 @@ public void testKibanaSystemRole() {
assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(mockIndexAbstraction(index)), is(false));
assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(mockIndexAbstraction(index)), is(false));
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(mockIndexAbstraction(index)), is(false));
assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(false));
assertThat(kibanaRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(mockIndexAbstraction(index)), is(true));
assertThat(kibanaRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(mockIndexAbstraction(index)), is(true));
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(mockIndexAbstraction(index)), is(true));
assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(mockIndexAbstraction(index)), is(false));

// Privileges needed for Fleet package upgrades
assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(mockIndexAbstraction(index)), is(true));
assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(mockIndexAbstraction(index)), is(true));
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(mockIndexAbstraction(index)), is(true));
});

Arrays.asList(
Expand Down Expand Up @@ -682,7 +686,11 @@ public void testKibanaSystemRole() {
"logs-" + randomAlphaOfLengthBetween(3, 8),
"metrics-" + randomAlphaOfLengthBetween(3, 8),
"synthetics-" + randomAlphaOfLengthBetween(3, 8),
"traces-" + randomAlphaOfLengthBetween(3, 8)
"traces-" + randomAlphaOfLengthBetween(3, 8),
// Hidden data indices for endpoint package
".logs-endpoint.action.responses-" + randomAlphaOfLengthBetween(3, 8),
".logs-endpoint.diagnostic.collection-" + randomAlphaOfLengthBetween(3, 8),
".logs-endpoint.actions-" + randomAlphaOfLengthBetween(3, 8)
).forEach(indexName -> {
logger.info("index name [{}]", indexName);
final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName);
Expand All @@ -703,9 +711,12 @@ public void testKibanaSystemRole() {
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false));
assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false));
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false));
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(false));
assertThat(kibanaRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(indexAbstraction), is(false));
assertThat(kibanaRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(indexAbstraction), is(false));

// Endpoint diagnostic data stream also has read access, all others should not.
final boolean isAlsoReadIndex = indexName.startsWith(".logs-endpoint.diagnostic.collection-");
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(isAlsoReadIndex));
assertThat(kibanaRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(indexAbstraction), is(isAlsoReadIndex));
assertThat(kibanaRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(indexAbstraction), is(isAlsoReadIndex));
});

// 4. Transform for endpoint package
Expand Down

0 comments on commit a786add

Please sign in to comment.