Skip to content

Commit 32820f9

Browse files
[Entity Analytics][Privmon] swap labels.monitoring.privileged_users (string) to user.is_privileged (boolean) (#224623)
## Summary We have [this RFC](elastic/ecs#2493) in, I think this is a safer bet and might save us a migration in the future: --------- Co-authored-by: kibanamachine <[email protected]>
1 parent 1fbbe29 commit 32820f9

File tree

10 files changed

+28
-57
lines changed

10 files changed

+28
-57
lines changed

oas_docs/output/kibana.serverless.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66877,14 +66877,6 @@ components:
6687766877
labels:
6687866878
type: object
6687966879
properties:
66880-
monitoring:
66881-
type: object
66882-
properties:
66883-
privileged_users:
66884-
enum:
66885-
- monitored
66886-
- deleted
66887-
type: string
6688866880
source_indices:
6688966881
items:
6689066882
type: string
@@ -66903,6 +66895,9 @@ components:
6690366895
user:
6690466896
type: object
6690566897
properties:
66898+
is_privileged:
66899+
description: Indicates if the user is privileged.
66900+
type: boolean
6690666901
name:
6690766902
type: string
6690866903
Security_Entity_Analytics_API_MonitoringEngineDescriptor:

oas_docs/output/kibana.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76440,14 +76440,6 @@ components:
7644076440
labels:
7644176441
type: object
7644276442
properties:
76443-
monitoring:
76444-
type: object
76445-
properties:
76446-
privileged_users:
76447-
enum:
76448-
- monitored
76449-
- deleted
76450-
type: string
7645176443
source_indices:
7645276444
items:
7645376445
type: string
@@ -76466,6 +76458,9 @@ components:
7646676458
user:
7646776459
type: object
7646876460
properties:
76461+
is_privileged:
76462+
description: Indicates if the user is privileged.
76463+
type: boolean
7646976464
name:
7647076465
type: string
7647176466
Security_Entity_Analytics_API_MonitoringEngineDescriptor:

x-pack/solutions/security/plugins/security_solution/common/api/entity_analytics/privilege_monitoring/users/common.gen.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ export const MonitoredUserDoc = z.object({
4040
user: z
4141
.object({
4242
name: z.string().optional(),
43+
/**
44+
* Indicates if the user is privileged.
45+
*/
46+
is_privileged: z.boolean().optional(),
4347
})
4448
.optional(),
4549
labels: z
4650
.object({
47-
monitoring: z
48-
.object({
49-
privileged_users: z.enum(['monitored', 'deleted']).optional(),
50-
})
51-
.optional(),
5251
sources: z.array(z.unknown()).optional(),
5352
source_indices: z.array(z.string()).optional(),
5453
source_integrations: z.array(z.string()).optional(),

x-pack/solutions/security/plugins/security_solution/common/api/entity_analytics/privilege_monitoring/users/common.schema.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,12 @@ components:
3838
properties:
3939
name:
4040
type: string
41-
41+
is_privileged:
42+
type: boolean
43+
description: Indicates if the user is privileged.
4244
labels:
4345
type: object
4446
properties:
45-
monitoring:
46-
type: object
47-
properties:
48-
privileged_users:
49-
type: string
50-
enum:
51-
- monitored
52-
- deleted
53-
5447
sources:
5548
type: array
5649
items:

x-pack/solutions/security/plugins/security_solution/docs/openapi/ess/security_solution_entity_analytics_api_2023_10_31.bundled.schema.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,14 +1624,6 @@ components:
16241624
labels:
16251625
type: object
16261626
properties:
1627-
monitoring:
1628-
type: object
1629-
properties:
1630-
privileged_users:
1631-
enum:
1632-
- monitored
1633-
- deleted
1634-
type: string
16351627
source_indices:
16361628
items:
16371629
type: string
@@ -1650,6 +1642,9 @@ components:
16501642
user:
16511643
type: object
16521644
properties:
1645+
is_privileged:
1646+
description: Indicates if the user is privileged.
1647+
type: boolean
16531648
name:
16541649
type: string
16551650
MonitoringEngineDescriptor:

x-pack/solutions/security/plugins/security_solution/docs/openapi/serverless/security_solution_entity_analytics_api_2023_10_31.bundled.schema.yaml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,14 +1624,6 @@ components:
16241624
labels:
16251625
type: object
16261626
properties:
1627-
monitoring:
1628-
type: object
1629-
properties:
1630-
privileged_users:
1631-
enum:
1632-
- monitored
1633-
- deleted
1634-
type: string
16351627
source_indices:
16361628
items:
16371629
type: string
@@ -1650,6 +1642,9 @@ components:
16501642
user:
16511643
type: object
16521644
properties:
1645+
is_privileged:
1646+
description: Indicates if the user is privileged.
1647+
type: boolean
16531648
name:
16541649
type: string
16551650
MonitoringEngineDescriptor:

x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/privileged_user_monitoring/helpers.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ export const getPrivilegedMonitorUsersJoin = (
1212
) => `| RENAME @timestamp AS event_timestamp
1313
| LOOKUP JOIN ${getPrivilegedMonitorUsersIndex(namespace)} ON user.name
1414
| RENAME event_timestamp AS @timestamp
15-
| EVAL is_privileged = labels.monitoring.privileged_users == "monitored"
16-
| WHERE is_privileged == true`;
15+
| WHERE user.is_privileged == true`;

x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/privilege_monitoring/privilege_monitoring_data_client.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,10 @@ export class PrivilegeMonitoringDataClient {
211211
source: PrivMonUserSource
212212
): Promise<CreatePrivMonUserResponse> {
213213
const doc = merge(user, {
214+
user: {
215+
is_privileged: true,
216+
},
214217
labels: {
215-
monitoring: { privileged_users: 'monitored' },
216218
sources: [source],
217219
},
218220
});

x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/privilege_monitoring/users/bulk/soft_delete_omitted_usrs.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ export const softDeleteOmittedUsers =
3434
index,
3535
query: {
3636
bool: {
37-
must: [
38-
{ term: { 'labels.monitoring.privileged_users': 'monitored' } },
39-
{ term: { 'labels.sources': 'csv' } },
40-
],
37+
must: [{ term: { 'user.is_privileged': true } }, { term: { 'labels.sources': 'csv' } }],
4138
must_not: [{ terms: { 'user.name': uploaded } }],
4239
},
4340
},
@@ -57,7 +54,9 @@ export const softDeleteOmittedUsers =
5754
{ update: { _id: id } },
5855
{
5956
doc: {
60-
labels: { monitoring: { privileged_users: 'deleted' } },
57+
user: {
58+
is_privileged: false,
59+
},
6160
},
6261
},
6362
];

x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/privilege_monitoring/users/bulk/update_from_csv.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,13 @@ export const bulkBatchUpsertFromCSV =
4949
onDocument: (row) => {
5050
const id = batch.existingUsers[row.username];
5151
const labels = {
52-
monitoring: { privileged_users: 'monitored' },
5352
sources: ['csv'],
5453
};
5554
if (!id) {
5655
return [
5756
{ create: {} },
5857
{
59-
user: { name: row.username },
58+
user: { name: row.username, is_privileged: true },
6059
labels,
6160
},
6261
];

0 commit comments

Comments
 (0)