Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete privilege to kibana_system for APM #85085

Merged
merged 6 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/85085.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 85085
summary: Add delete privilege to `kibana_system` for APM
area: Authorization
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,15 @@ public static RoleDescriptor kibanaSystemRoleDescriptor(String name) {
.build(),
// For ILM policy for APM & Endpoint packages that have delete action
RoleDescriptor.IndicesPrivileges.builder()
.indices(".logs-endpoint.diagnostic.collection-*", "traces-apm.sampled-*")
.indices(
".logs-endpoint.diagnostic.collection-*",
"logs-apm-*",
"logs-apm.*-*",
"metrics-apm-*",
"metrics-apm.*-*",
"traces-apm-*",
"traces-apm.*-*"
)
.privileges(DeleteIndexAction.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 @@ -865,9 +865,14 @@ public void testKibanaSystemRole() {
assertThat(kibanaRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(indexAbstraction), is(isAlsoReadIndex));
assertThat(kibanaRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(indexAbstraction), is(isAlsoReadIndex));

// Endpoint diagnostic and sampled traces data streams also have an ILM policy with a delete action, all others should not.
// Endpoint diagnostic and APM data streams also have an ILM policy with a delete action, all others should not.
final boolean isAlsoIlmDeleteIndex = indexName.startsWith(".logs-endpoint.diagnostic.collection-")
|| indexName.startsWith("traces-apm.sampled-");
|| indexName.startsWith("logs-apm-")
|| indexName.startsWith("logs-apm.")
|| indexName.startsWith("metrics-apm-")
|| indexName.startsWith("metrics-apm.")
|| indexName.startsWith("traces-apm-")
|| indexName.startsWith("traces-apm.");
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(isAlsoIlmDeleteIndex));
});

Expand Down Expand Up @@ -928,28 +933,21 @@ public void testKibanaSystemRole() {
});

// Ensure privileges necessary for ILM policies in APM & Endpoint packages
Arrays.asList(
"metrics-apm.app-" + randomAlphaOfLengthBetween(3, 8),
"metrics-apm.internal-" + randomAlphaOfLengthBetween(3, 8),
"metrics-apm.profiling-" + randomAlphaOfLengthBetween(3, 8),
"logs-apm.error_logs-" + randomAlphaOfLengthBetween(3, 8),
"traces-apm-" + randomAlphaOfLengthBetween(3, 8)
).forEach(indexName -> {
logger.info("index name [{}]", indexName);
final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName);

assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true));
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true));
});
Arrays.asList(
".logs-endpoint.diagnostic.collection-" + randomAlphaOfLengthBetween(3, 8),
"traces-apm.sampled-" + randomAlphaOfLengthBetween(3, 8)
"logs-apm-" + randomAlphaOfLengthBetween(3, 8),
"logs-apm." + randomAlphaOfLengthBetween(3, 8) + "-" + randomAlphaOfLengthBetween(3, 8),
"metrics-apm-" + randomAlphaOfLengthBetween(3, 8),
"metrics-apm." + randomAlphaOfLengthBetween(3, 8) + "-" + randomAlphaOfLengthBetween(3, 8),
"traces-apm-" + randomAlphaOfLengthBetween(3, 8),
"traces-apm." + randomAlphaOfLengthBetween(3, 8) + "-" + randomAlphaOfLengthBetween(3, 8)
).forEach(indexName -> {
logger.info("index name [{}]", indexName);
final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName);

assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(true));
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true));
assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true));
});
}

Expand Down