-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SecuritySolution] Migrate away from browser-side SO client (#154174)
## Summary Issue: #154040 Apis added: 1. Get all the tags with name `Security Solution` or Create a Security Solution tag if no results found #### GET /internal/tags ``` [ { "id": "ba964280-d211-11ed-890b-153ddf1a08e9", "name": "Security Solution", "description": "Security Solution auto-generated tag", "color": "#2c7b82" } ] ``` 2. Get dashboards with Security Solution tags #### GET /internal/dashboards ``` [ { "type": "dashboard", "id": "7de391b0-c1ca-11e7-8995-936807a28b16-ecs", "namespaces": [ "default" ], "attributes": { "description": "Overview of kernel executions", "hits": 0, "kibanaSavedObjectMeta": { "searchSourceJSON": "{\"filter\":[],\"highlightAll\":true,\"query\":{\"language\":\"kuery\",\"query\":\"\"},\"version\":true}" }, "optionsJSON": "{\"darkTheme\":false,\"useMargins\":false}", "panelsJSON": "[{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"h\":12,\"i\":\"1\",\"w\":16,\"x\":16,\"y\":0},\"panelIndex\":\"1\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_1\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"h\":12,\"i\":\"3\",\"w\":16,\"x\":32,\"y\":0},\"panelIndex\":\"3\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_3\"},{\"version\":\"7.3.0\",\"type\":\"visualization\",\"gridData\":{\"h\":12,\"i\":\"5\",\"w\":16,\"x\":0,\"y\":0},\"panelIndex\":\"5\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_5\"},{\"version\":\"7.3.0\",\"type\":\"search\",\"gridData\":{\"h\":20,\"i\":\"6\",\"w\":48,\"x\":0,\"y\":12},\"panelIndex\":\"6\",\"embeddableConfig\":{\"enhancements\":{}},\"panelRefName\":\"panel_6\"}]", "timeRestore": false, "title": "[Auditbeat Auditd] Executions ECS", "version": 1 }, "references": [ { "name": "1:panel_1", "id": "20a8e8d0-c1c8-11e7-8995-936807a28b16-ecs", "type": "visualization" }, { "name": "3:panel_3", "id": "f81a6de0-c1c1-11e7-8995-936807a28b16-ecs", "type": "visualization" }, { "name": "5:panel_5", "id": "2efac370-c1ca-11e7-8995-936807a28b16-ecs", "type": "visualization" }, { "name": "6:panel_6", "id": "d382f5b0-c1c6-11e7-8995-936807a28b16-ecs", "type": "search" }, { "name": "tag-ref-ba964280-d211-11ed-890b-153ddf1a08e9", "id": "ba964280-d211-11ed-890b-153ddf1a08e9", "type": "tag" } ], "coreMigrationVersion": "8.8.0", "typeMigrationVersion": "8.7.0", "updated_at": "2023-04-03T11:38:00.902Z", "created_at": "2023-04-03T11:20:46.473Z", "version": "WzE4NzMsMV0=", "score": 0 } ] ``` <img width="2557" alt="Screenshot 2023-03-31 at 16 10 49" src="https://user-images.githubusercontent.com/6295984/229166859-6d765332-aa04-4da2-acde-456b04682914.png"> <img width="2547" alt="Screenshot 2023-03-31 at 16 09 28" src="https://user-images.githubusercontent.com/6295984/229166834-0b61c1cd-53a8-4c5c-892e-94f19deb95f2.png"> ### Checklist Delete any items that are not applicable to this PR. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [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
25 changed files
with
834 additions
and
191 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
12 changes: 12 additions & 0 deletions
12
x-pack/plugins/security_solution/public/common/containers/dashboards/__mocks__/utils.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,12 @@ | ||
/* | ||
* 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 { MOCK_TAG_ID, DEFAULT_DASHBOARDS_RESPONSE } from '../api/__mocks__'; | ||
|
||
export const getSecurityTagIds = jest.fn().mockResolvedValue([MOCK_TAG_ID]); | ||
|
||
export const getSecurityDashboards = jest.fn().mockResolvedValue(DEFAULT_DASHBOARDS_RESPONSE); |
53 changes: 53 additions & 0 deletions
53
x-pack/plugins/security_solution/public/common/containers/dashboards/api/__mocks__/index.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,53 @@ | ||
/* | ||
* 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 { SECURITY_TAG_NAME, SECURITY_TAG_DESCRIPTION } from '../../../../../../common/constants'; | ||
|
||
export const MOCK_TAG_ID = 'securityTagId'; | ||
|
||
export const DEFAULT_TAGS_RESPONSE = [ | ||
{ | ||
id: MOCK_TAG_ID, | ||
name: SECURITY_TAG_NAME, | ||
description: SECURITY_TAG_DESCRIPTION, | ||
color: '#2c7b82', | ||
}, | ||
]; | ||
|
||
export const DEFAULT_DASHBOARDS_RESPONSE = [ | ||
{ | ||
type: 'dashboard', | ||
id: 'c0ac2c00-c1c0-11e7-8995-936807a28b16-ecs', | ||
namespaces: ['default'], | ||
attributes: { | ||
description: 'Summary of Linux kernel audit events.', | ||
title: '[Auditbeat Auditd] Overview ECS', | ||
version: 1, | ||
}, | ||
references: [ | ||
{ | ||
name: 'tag-ref-ba964280-d211-11ed-890b-153ddf1a08e9', | ||
id: 'ba964280-d211-11ed-890b-153ddf1a08e9', | ||
type: 'tag', | ||
}, | ||
], | ||
coreMigrationVersion: '8.8.0', | ||
typeMigrationVersion: '8.7.0', | ||
updated_at: '2023-04-03T11:38:00.902Z', | ||
created_at: '2023-04-03T11:20:50.603Z', | ||
version: 'WzE4NzQsMV0=', | ||
score: 0, | ||
}, | ||
]; | ||
|
||
export const getSecuritySolutionTags = jest | ||
.fn() | ||
.mockImplementation(() => Promise.resolve(DEFAULT_TAGS_RESPONSE)); | ||
|
||
export const getSecuritySolutionDashboards = jest | ||
.fn() | ||
.mockImplementation(() => Promise.resolve(DEFAULT_DASHBOARDS_RESPONSE)); |
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/security_solution/public/common/containers/dashboards/api/index.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,20 @@ | ||
/* | ||
* 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 { HttpSetup } from '@kbn/core/public'; | ||
import type { Tag } from '@kbn/saved-objects-tagging-plugin/public'; | ||
import { INTERNAL_TAGS_URL, INTERNAL_DASHBOARDS_URL } from '../../../../../common/constants'; | ||
import type { DashboardTableItem } from '../types'; | ||
|
||
export const getSecuritySolutionTags = ({ http }: { http: HttpSetup }): Promise<Tag[] | null> => | ||
http.get(INTERNAL_TAGS_URL); | ||
|
||
export const getSecuritySolutionDashboards = ({ | ||
http, | ||
}: { | ||
http: HttpSetup; | ||
}): Promise<DashboardTableItem[] | null> => http.get(INTERNAL_DASHBOARDS_URL); |
16 changes: 16 additions & 0 deletions
16
x-pack/plugins/security_solution/public/common/containers/dashboards/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,16 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export interface DashboardTableItem { | ||
id: string; | ||
type: string; | ||
attributes: { | ||
title: string; | ||
description: string; | ||
}; | ||
references: Array<{ name: string; type: string; id: string }>; | ||
} |
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
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
Oops, something went wrong.