forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SecuritySolution] Fix entity-store to support asset criticality dele…
…te (elastic#196680) ## Summary Update the entity store API so it does not return the asset criticality field when the value is 'deleted'. ### How to test it * Open kibana with data * Install the entity store * Update asset criticality for a host or user * Wait for the engine to run (I don't know a reliable way to do this) * Refresh the entity analytics dashboard, and it should show empty fields for deleted asset criticality - [ ] Backport it to 8.16 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- Loading branch information
Showing
5 changed files
with
146 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/security_solution/server/lib/entity_analytics/entity_store/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { HostEntity, UserEntity } from '../../../../common/api/entity_analytics'; | ||
import type { CriticalityValues } from '../asset_criticality/constants'; | ||
|
||
export interface HostEntityRecord extends Omit<HostEntity, 'asset'> { | ||
asset?: { | ||
criticality: CriticalityValues; | ||
}; | ||
} | ||
|
||
export interface UserEntityRecord extends Omit<UserEntity, 'asset'> { | ||
asset?: { | ||
criticality: CriticalityValues; | ||
}; | ||
} | ||
|
||
/** | ||
* It represents the data stored in the entity store index. | ||
*/ | ||
export type EntityRecord = HostEntityRecord | UserEntityRecord; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...curity_solution_api_integration/test_suites/entity_analytics/entity_store/utils/ingest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { Client } from '@elastic/elasticsearch'; | ||
import { IngestProcessorContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; | ||
import { ToolingLog } from '@kbn/tooling-log'; | ||
|
||
export const applyIngestProcessorToDoc = async ( | ||
steps: IngestProcessorContainer[], | ||
docSource: any, | ||
es: Client, | ||
log: ToolingLog | ||
): Promise<any> => { | ||
const doc = { | ||
_index: 'index', | ||
_id: 'id', | ||
_source: docSource, | ||
}; | ||
|
||
const res = await es.ingest.simulate({ | ||
pipeline: { | ||
description: 'test', | ||
processors: steps, | ||
}, | ||
docs: [doc], | ||
}); | ||
|
||
const firstDoc = res.docs?.[0]; | ||
|
||
// @ts-expect-error error is not in the types | ||
const error = firstDoc?.error; | ||
if (error) { | ||
log.error('Full painless error below: '); | ||
log.error(JSON.stringify(error, null, 2)); | ||
throw new Error('Painless error running pipeline see logs for full detail : ' + error?.type); | ||
} | ||
|
||
return firstDoc?.doc?._source; | ||
}; |