Skip to content

Saved Object Mapping for Entity Source Sync Configuration#219680

Merged
CAWilson94 merged 69 commits intoelastic:mainfrom
CAWilson94:ea-12283-monitoring-entity-source-config
Jun 5, 2025
Merged

Saved Object Mapping for Entity Source Sync Configuration#219680
CAWilson94 merged 69 commits intoelastic:mainfrom
CAWilson94:ea-12283-monitoring-entity-source-config

Conversation

@CAWilson94
Copy link
Copy Markdown
Contributor

@CAWilson94 CAWilson94 commented Apr 30, 2025

Summary

This PR introduces a new Saved Object mapping for Monitoring Entity Source Configurations to support Privileged User Monitoring.

✅ Implemented

  • Saved object mapping schema aligned with the current spec
  • DescriptorClient to handle saved object methods
  • OpenAPI schema and generated types
  • Implemented Data Client - SO operations exposed via GET and POST API
  • Created route and registered with privmonRoutes
  • Data Client Unit Testing
  • Rename typename of "monitoring_entity_source-sync" -> "entity-analytics-monitoring-entity-source"

Figma - currently working in the pink box

Testing Steps:

  1. privilegeMonitoringEnabled: true - set this flag
  2. From Dev tools - create a saved object via POST (below) and view this saved object via GET (also below):
POST kbn:/api/entity_analytics/monitoring/entity_source
{
  "type": "some-type-here",
  "name": "name-here",
  "managed": false,
  "indexPattern": "logs-*",
  "enabled": true,
  "integrationName": "Okta",
 "matchers": [
    {
      "fields": ["user.role"],
      "values": ["admin"]
    }
  ],
  "filter": {}
}

Expected output:

{
  "type": "some-type-here",
  "name": "name-here",
  "managed": false,
  "indexPattern": "logs-*",
  "enabled": true,
  "integrationName": "Okta",
  "matchers": [
    {
      "fields": [
        "user.role"
      ],
      "values": [
        "admin"
      ]
    }
  ],
  "filter": {}
}

GET Example

GET kbn:/api/entity_analytics/monitoring/entity_source

Output for get, expected to be the same as that for POST.

@prodsecmachine
Copy link
Copy Markdown
Collaborator

prodsecmachine commented May 1, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@CAWilson94 CAWilson94 requested a review from Copilot May 1, 2025 09:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new saved object mapping for monitoring entity source configurations to support privileged user monitoring. It defines the saved object mapping schema with key fields and implements a descriptor client to manage these objects while also adding an OpenAPI-generated Zod schema for API type validation.

  • Defined mappings for the new saved object type with fields such as type, name, managed, and matchers.
  • Implemented a descriptor client for initializing, updating, and querying the monitoring entity source object.
  • Added a generated API file for validating the monitoring entity source descriptor.

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/privilege_monitoring/saved_object/monitoring_entity_source_type.ts Created a new saved object type with mappings and a model version update.
x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/privilege_monitoring/saved_object/monitoring_entity_source.ts Added a descriptor client for managing the monitoring entity source object.
x-pack/solutions/security/plugins/security_solution/common/api/entity_analytics/privilege_monitoring/monitoring_entity_source/monitoring_entity_source.gen.ts Generated Zod schema for type validation of the monitoring entity source descriptor.
Files not reviewed (1)
  • x-pack/solutions/security/plugins/security_solution/common/api/entity_analytics/privilege_monitoring/monitoring_entity_source/monitoring_entity_source.schema.yaml: Language not supported

@CAWilson94 CAWilson94 requested a review from Copilot May 1, 2025 20:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new saved object mapping and supporting infrastructure (data client and routes) for Monitoring Entity Source Sync Configuration to support Privileged User Monitoring.

  • Adds saved object schema, client, and API routes
  • Integrates the new data client into the request context and registers it with the existing privilege monitoring routes
  • Provides OpenAPI schema and generated types for the configuration

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
x-pack/solutions/security/plugins/security_solution/server/types.ts Added import and context method for the new data client
x-pack/solutions/security/plugins/security_solution/server/saved_objects.ts Registered a new saved object type mapping
x-pack/solutions/security/plugins/security_solution/server/request_context_factory.ts Added memoized method to instantiate the new data client
x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/privilege_monitoring/saved_object/monitoring_entity_source_type.ts Defined the saved object mapping for the monitoring entity source
x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/privilege_monitoring/saved_object/monitoring_entity_source.ts Implemented the saved object client for monitoring entity source operations
x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/privilege_monitoring/routes/monitoring_entity_source_sync.ts Added POST and GET API routes for sync configuration
x-pack/solutions/security/plugins/security_solution/server/lib/entity_analytics/privilege_monitoring/monitoring_entity_source_sync_data_client.ts Provided the data client that wraps saved object operations
x-pack/solutions/security/plugins/security_solution/common/api/entity_analytics/privilege_monitoring/monitoring_entity_source/monitoring_entity_source.gen.ts Introduced auto-generated OpenAPI schema and types
Files not reviewed (1)
  • x-pack/solutions/security/plugins/security_solution/common/api/entity_analytics/privilege_monitoring/monitoring_entity_source/monitoring_entity_source.schema.yaml: Language not supported
Comments suppressed due to low confidence (1)

x-pack/solutions/security/plugins/security_solution/server/request_context_factory.ts:268

  • Consider renaming this function to 'getMonitoringEntitySourceSyncDataClient' to match the naming of the underlying class and reflect the intended naming conventions mentioned in the PR.
getMonitoringEntitySourceDataClient: memoize(() => {

@CAWilson94 CAWilson94 self-assigned this May 1, 2025
…e to move blockers while debugging joi issues
@CAWilson94 CAWilson94 marked this pull request as ready for review May 7, 2025 13:14
@CAWilson94 CAWilson94 requested review from a team as code owners May 7, 2025 13:14
@CAWilson94 CAWilson94 requested a review from hop-dev May 7, 2025 13:14
@CAWilson94 CAWilson94 requested a review from Copilot May 7, 2025 13:15
@kibanamachine
Copy link
Copy Markdown
Contributor

Flaky Test Runner Stats

🟠 Some tests failed. - kibana-flaky-test-suite-runner#8315

[❌] x-pack/test_serverless/functional/test_suites/observability/config.ts: 69/100 tests passed.

see run history

"type": "object"
},
"indexPattern": {
"index": false,
Copy link
Copy Markdown
Member

@afharo afharo Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using index: false is discouraged. Refer to https://docs.elastic.dev/kibana-dev-docs/tutorials/saved-objects to know more:

Never use enabled: false or index: false in your mappings. Elasticsearch does not support toggling these mapping options, so if your plugin ever needs to query the data, you will not be able to do so. Since these fields cannot be queried, they would require migrating to a new field and making associated code changes. Instead, use dynamic: false which provides the same flexibility while maintaining the future ability to query fields if necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I was trying to change these to using dynamic: false but I am unsure of this use case --

properties": {
          "fields": {
            "index": false,
            "type": "keyword"
          },
          "values": {
            "index": false,
            "type": "keyword"
          }
        },
        "type": "object"
      },

My aim here is to make both matchers.find and matchers.values required and non searchable. To achieve this, can I change this to something like this where I rely on the top level - the child attributes should pick be non searchable from here?

properties": {
    "dynamic": false 
          "fields": {
            "type": "keyword"
          },
          "values": {        
            "type": "keyword"
          }
        },
        "type": "object"
      },

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I think I have my answer from the docs, this should be good according to the example below:


> export const dashboardVisualization: SavedObjectsType = {
>   name: 'dashboard_visualization',
>   ...
>   mappings: {
>     properties: {
>       dynamic: false,  // ✅ Do this instead
>       metadata: {
>         // dynamic: false gets inherited from above
>         properties: {
>           // `created_by` can now be stored but won't be queryable
>         }
>       },
>       // `description` can now be stored but won't be queryable
>     }
>   }
> };

Copy link
Copy Markdown
Contributor Author

@CAWilson94 CAWilson94 Jun 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hop-dev I have updated to dynamic now :D but quick reference for the mappings - properties I was a bit blocked with. Time to merge? 🥳

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go for it!

@CAWilson94 CAWilson94 requested a review from hop-dev June 4, 2025 09:04
Copy link
Copy Markdown
Contributor

@hop-dev hop-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Just the dynamic: true question to resolve and lets get this merged!

@CAWilson94 CAWilson94 requested a review from afharo June 4, 2025 13:37
},
indexPattern: {
type: 'keyword',
dynamic: false,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is failing with the following error:

info [o.e.c.m.MetadataCreateIndexService] [node-01] failed on parsing mappings on index creation [.kibana_security_solution_9.1.0_001] org.elasticsearch.index.mapper.MapperParsingException: Failed to parse mapping: unknown parameter [dynamic] on mapper [indexPattern] of type [keyword]

AFAIK, dynamic: false is only compatible with objects, not final fields. Since the parent object already has dynamic: false, I'd recommend that you don't declare the field indexPattern if you don't need to index it for now.
You can always add it later if needed.

The same recommendation applies to the other fields that used to have index: false. If you don't plan on using them to query/aggregate, just don't declare them in the mappings (and make sure that dynamic: false is in the parent object).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining that, that makes more sense knowing we can leave it out if we aren't searching on it.

Copy link
Copy Markdown
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SO changes LGTM. Thanks for iterating and bearing with me.

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Jun 5, 2025

💔 Build Failed

Failed CI Steps

History

cc @CAWilson94

@elasticmachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #29 / EQL execution logic API @ess @serverless @serverlessQA EQL type rules uses the provided timestamp_field

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
securitySolution 128 129 +1

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
securitySolution 35 36 +1
Unknown metric groups

API count

id before after diff
securitySolution 197 198 +1

ESLint disabled in files

id before after diff
securitySolution 94 95 +1

Total ESLint disabled count

id before after diff
securitySolution 703 704 +1

History

cc @CAWilson94

@CAWilson94 CAWilson94 merged commit a3de6d8 into elastic:main Jun 5, 2025
10 checks passed
pmuellr pushed a commit to pmuellr/kibana that referenced this pull request Jun 11, 2025
…9680)

## Summary

This PR introduces a new Saved Object mapping for Monitoring Entity
Source Configurations to support Privileged User Monitoring.

### ✅ Implemented
* Saved object mapping schema aligned with the [current
spec](https://docs.google.com/document/d/1-c6A82p2CCjYz8Mb6tL6R7BXXemQ4mpWZliKqki0SWo/edit?tab=t.0#heading=h.4axxr154e1lc)
* DescriptorClient to handle saved object methods
* OpenAPI schema and generated types
* Implemented Data Client - SO operations exposed via GET and POST API
* Created route and registered with privmonRoutes
* Data Client Unit Testing
* Rename typename of "monitoring_entity_source-sync" ->
"entity-analytics-monitoring-entity-source"

[Figma
](https://www.figma.com/board/yBr1pBDGu4JqNxb5ZrULtk/MonEntitySourceSyncTask?node-id=0-1&p=f&t=4hQaGsdvOpghi4QS-0)-
currently working in the pink box


## Testing Steps: 
1. privilegeMonitoringEnabled: true - set this flag
2. From Dev tools - create a saved object via POST (below) and view this
saved object via GET (also below):


```
POST kbn:/api/entity_analytics/monitoring/entity_source
{
  "type": "some-type-here",
  "name": "name-here",
  "managed": false,
  "indexPattern": "logs-*",
  "enabled": true,
  "integrationName": "Okta",
 "matchers": [
    {
      "fields": ["user.role"],
      "values": ["admin"]
    }
  ],
  "filter": {}
}

```
**Expected output:** 
``` 
{
  "type": "some-type-here",
  "name": "name-here",
  "managed": false,
  "indexPattern": "logs-*",
  "enabled": true,
  "integrationName": "Okta",
  "matchers": [
    {
      "fields": [
        "user.role"
      ],
      "values": [
        "admin"
      ]
    }
  ],
  "filter": {}
}
```
GET Example
```
GET kbn:/api/entity_analytics/monitoring/entity_source
```
Output for get, expected to be the same as that for POST.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
nickpeihl pushed a commit to nickpeihl/kibana that referenced this pull request Jun 12, 2025
…9680)

## Summary

This PR introduces a new Saved Object mapping for Monitoring Entity
Source Configurations to support Privileged User Monitoring.

### ✅ Implemented
* Saved object mapping schema aligned with the [current
spec](https://docs.google.com/document/d/1-c6A82p2CCjYz8Mb6tL6R7BXXemQ4mpWZliKqki0SWo/edit?tab=t.0#heading=h.4axxr154e1lc)
* DescriptorClient to handle saved object methods
* OpenAPI schema and generated types
* Implemented Data Client - SO operations exposed via GET and POST API
* Created route and registered with privmonRoutes
* Data Client Unit Testing
* Rename typename of "monitoring_entity_source-sync" ->
"entity-analytics-monitoring-entity-source"

[Figma
](https://www.figma.com/board/yBr1pBDGu4JqNxb5ZrULtk/MonEntitySourceSyncTask?node-id=0-1&p=f&t=4hQaGsdvOpghi4QS-0)-
currently working in the pink box


## Testing Steps: 
1. privilegeMonitoringEnabled: true - set this flag
2. From Dev tools - create a saved object via POST (below) and view this
saved object via GET (also below):


```
POST kbn:/api/entity_analytics/monitoring/entity_source
{
  "type": "some-type-here",
  "name": "name-here",
  "managed": false,
  "indexPattern": "logs-*",
  "enabled": true,
  "integrationName": "Okta",
 "matchers": [
    {
      "fields": ["user.role"],
      "values": ["admin"]
    }
  ],
  "filter": {}
}

```
**Expected output:** 
``` 
{
  "type": "some-type-here",
  "name": "name-here",
  "managed": false,
  "indexPattern": "logs-*",
  "enabled": true,
  "integrationName": "Okta",
  "matchers": [
    {
      "fields": [
        "user.role"
      ],
      "values": [
        "admin"
      ]
    }
  ],
  "filter": {}
}
```
GET Example
```
GET kbn:/api/entity_analytics/monitoring/entity_source
```
Output for get, expected to be the same as that for POST.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Entity Analytics Security Solution Entity Analytics features release_note:skip Skip the PR/issue when compiling release notes Team:Entity Analytics Security Entity Analytics Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Theme: entity_analytics v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants