Skip to content

Commit dc2dd28

Browse files
committed
Add read permissions for osquery manager result indices
1 parent ecbc360 commit dc2dd28

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ static RoleDescriptor kibanaSystem(String name) {
319319
".logs-osquery_manager.actions-*",
320320
".logs-osquery_manager.action.responses-*",
321321
"logs-osquery_manager.action.responses-*",
322+
"logs-osquery_manager.result-*",
322323
"profiling-*"
323324
)
324325
.privileges(
@@ -361,6 +362,11 @@ static RoleDescriptor kibanaSystem(String name) {
361362
.indices(".logs-osquery_manager.actions-*")
362363
.privileges("auto_configure", "create_index", "read", "index", "write", "delete")
363364
.build(),
365+
// Osquery manager specific results. Kibana reads from these to display results to the user.
366+
RoleDescriptor.IndicesPrivileges.builder()
367+
.indices("logs-osquery_manager.result-*")
368+
.privileges("read", "view_index_metadata")
369+
.build(),
364370

365371
// Third party agent (that use non-Elastic Defend integrations) info logs
366372
// indices.

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,33 @@ public void testKibanaSystemRole() {
10591059
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true));
10601060
});
10611061

1062+
Arrays.asList("logs-osquery_manager.result-" + randomAlphaOfLength(randomIntBetween(0, 13))).forEach((osqIndex) -> {
1063+
final IndexAbstraction indexAbstraction = mockIndexAbstraction(osqIndex);
1064+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false));
1065+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false));
1066+
assertThat(
1067+
kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction),
1068+
is(false)
1069+
);
1070+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true));
1071+
assertThat(
1072+
kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction),
1073+
is(false)
1074+
);
1075+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false));
1076+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false));
1077+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true));
1078+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true));
1079+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true));
1080+
assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false));
1081+
assertThat(
1082+
kibanaRole.indices().allowedIndicesMatcher(TransportUpdateSettingsAction.TYPE.name()).test(indexAbstraction),
1083+
is(true)
1084+
);
1085+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportPutMappingAction.TYPE.name()).test(indexAbstraction), is(true));
1086+
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true));
1087+
});
1088+
10621089
// Tests for third-party agent indices that `kibana_system` has only `read` access
10631090
Arrays.asList(
10641091
"logs-sentinel_one." + randomAlphaOfLength(randomIntBetween(0, 13)),
@@ -1617,6 +1644,34 @@ public void testKibanaSystemRole() {
16171644
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true));
16181645
});
16191646

1647+
// read-only datastream for osquery_manager
1648+
Arrays.asList("logs-osquery_manager.result-" + randomAlphaOfLength(randomIntBetween(0, 13))).forEach((osqIndex) -> {
1649+
final IndexAbstraction indexAbstraction = mockIndexAbstraction(osqIndex);
1650+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(indexAbstraction), is(false));
1651+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(indexAbstraction), is(false));
1652+
assertThat(
1653+
kibanaRole.indices().allowedIndicesMatcher(TransportDeleteIndexAction.TYPE.name()).test(indexAbstraction),
1654+
is(false)
1655+
);
1656+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(indexAbstraction), is(true));
1657+
assertThat(
1658+
kibanaRole.indices().allowedIndicesMatcher(TransportCreateIndexAction.TYPE.name()).test(indexAbstraction),
1659+
is(false)
1660+
);
1661+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportIndexAction.NAME).test(indexAbstraction), is(false));
1662+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportDeleteAction.NAME).test(indexAbstraction), is(false));
1663+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportSearchAction.TYPE.name()).test(indexAbstraction), is(true));
1664+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportMultiSearchAction.TYPE.name()).test(indexAbstraction), is(true));
1665+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportGetAction.TYPE.name()).test(indexAbstraction), is(true));
1666+
assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(indexAbstraction), is(false));
1667+
assertThat(
1668+
kibanaRole.indices().allowedIndicesMatcher(TransportUpdateSettingsAction.TYPE.name()).test(indexAbstraction),
1669+
is(true)
1670+
);
1671+
assertThat(kibanaRole.indices().allowedIndicesMatcher(TransportPutMappingAction.TYPE.name()).test(indexAbstraction), is(true));
1672+
assertThat(kibanaRole.indices().allowedIndicesMatcher(RolloverAction.NAME).test(indexAbstraction), is(true));
1673+
});
1674+
16201675
// read-only datastream for csp indices
16211676
Arrays.asList("logs-cloud_security_posture.findings-" + randomAlphaOfLength(randomIntBetween(0, 13))).forEach((cspIndex) -> {
16221677
final IndexAbstraction indexAbstraction = mockIndexAbstraction(cspIndex);

0 commit comments

Comments
 (0)