Skip to content

Commit cda4b86

Browse files
authored
cloud_defend index read priv added to kibana_system role (for usageCollection) (#97288)
* cloud_defend index read priv added to kibana_system role * fixes
1 parent da81686 commit cda4b86

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,12 @@ public static RoleDescriptor kibanaSystemRoleDescriptor(String name) {
967967
)
968968
.privileges("create_index", "read", "index", "delete", IndicesAliasesAction.NAME, UpdateSettingsAction.NAME)
969969
.build(),
970-
RoleDescriptor.IndicesPrivileges.builder().indices("risk-score.risk-*").privileges("all").build() },
970+
RoleDescriptor.IndicesPrivileges.builder().indices("risk-score.risk-*").privileges("all").build(),
971+
// For cloud_defend usageCollection
972+
RoleDescriptor.IndicesPrivileges.builder()
973+
.indices("logs-cloud_defend.*", "metrics-cloud_defend.*")
974+
.privileges("read", "view_index_metadata")
975+
.build() },
971976
null,
972977
new ConfigurableClusterPrivilege[] {
973978
new ManageApplicationPrivileges(Set.of("kibana-*")),

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,31 @@ public void testKibanaSystemRole() {
12161216
);
12171217
});
12181218

1219+
// cloud_defend
1220+
// read-only datastream for cloud_defend indices (for usageCollection)
1221+
Arrays.asList(
1222+
"logs-cloud_defend.file-" + randomAlphaOfLength(randomIntBetween(0, 13)),
1223+
"logs-cloud_defend.process-" + randomAlphaOfLength(randomIntBetween(0, 13)),
1224+
"logs-cloud_defend.alerts-" + randomAlphaOfLength(randomIntBetween(0, 13)),
1225+
"metrics-cloud_defend.metrics-" + randomAlphaOfLength(randomIntBetween(0, 13))
1226+
).forEach((indexName) -> {
1227+
final IndexAbstraction indexAbstraction = mockIndexAbstraction(indexName);
1228+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false));
1229+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false));
1230+
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(indexAbstraction), is(false));
1231+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true));
1232+
assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(indexAbstraction), is(false));
1233+
assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(indexAbstraction), is(false));
1234+
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(indexAbstraction), is(false));
1235+
assertThat(kibanaRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(indexAbstraction), is(true));
1236+
assertThat(kibanaRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(indexAbstraction), is(true));
1237+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(indexAbstraction), is(true));
1238+
assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false));
1239+
assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(indexAbstraction), is(true));
1240+
assertThat(kibanaRole.indices().allowedIndicesMatcher(PutMappingAction.NAME).test(indexAbstraction), is(true));
1241+
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true));
1242+
});
1243+
12191244
// Ensure privileges necessary for ILM policies in APM & Endpoint packages
12201245
Arrays.asList(
12211246
".logs-endpoint.diagnostic.collection-" + randomAlphaOfLengthBetween(3, 8),

0 commit comments

Comments
 (0)