-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[SECURITY_SOLUTION][ENDPOINT] Add creation of Trusted Apps Agnostic List #74868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
da5ced5
630ee85
c296a57
53285e9
a842f0e
2235d07
79750f9
13c7889
76846b8
77f0068
b1cdb44
adf91f6
996ac21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import { SavedObjectsClientContract } from 'kibana/server'; | ||
| import uuid from 'uuid'; | ||
|
|
||
| import { | ||
| ENDPOINT_TRUSTED_APPS_LIST_DESCRIPTION, | ||
| ENDPOINT_TRUSTED_APPS_LIST_ID, | ||
| ENDPOINT_TRUSTED_APPS_LIST_NAME, | ||
| } from '../../../common/constants'; | ||
| import { ExceptionListSchema, ExceptionListSoSchema, Version } from '../../../common/schemas'; | ||
|
|
||
| import { getSavedObjectType, transformSavedObjectToExceptionList } from './utils'; | ||
|
|
||
| interface CreateEndpointListOptions { | ||
| savedObjectsClient: SavedObjectsClientContract; | ||
| user: string; | ||
| tieBreaker?: string; | ||
| version: Version; | ||
| } | ||
|
|
||
| /** | ||
| * Creates the Endpoint Trusted Apps agnostic list if it does not yet exist | ||
| * | ||
| * @param savedObjectsClient | ||
| * @param user | ||
| * @param tieBreaker | ||
| * @param version | ||
| */ | ||
| export const createEndpointTrustedAppsList = async ({ | ||
| savedObjectsClient, | ||
| user, | ||
| tieBreaker, | ||
| version, | ||
| }: CreateEndpointListOptions): Promise<ExceptionListSchema | null> => { | ||
| const savedObjectType = getSavedObjectType({ namespaceType: 'agnostic' }); | ||
| const dateNow = new Date().toISOString(); | ||
| try { | ||
| const savedObject = await savedObjectsClient.create<ExceptionListSoSchema>( | ||
| savedObjectType, | ||
| { | ||
| _tags: [], | ||
paul-tavares marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| comments: undefined, | ||
| created_at: dateNow, | ||
| created_by: user, | ||
| description: ENDPOINT_TRUSTED_APPS_LIST_DESCRIPTION, | ||
| entries: undefined, | ||
| immutable: false, | ||
| item_id: undefined, | ||
| list_id: ENDPOINT_TRUSTED_APPS_LIST_ID, | ||
| list_type: 'list', | ||
| meta: undefined, | ||
| name: ENDPOINT_TRUSTED_APPS_LIST_NAME, | ||
| tags: [], | ||
| tie_breaker_id: tieBreaker ?? uuid.v4(), | ||
| type: 'endpoint', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this list has different restrictions I would use a different list type such as
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, we should be thinking about this as a different
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thiiiiink the convention for IDs/types like this is hyphen-delimited though, as opposed to camelcase. So maybe something like
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. I will create a new type (was trying to minimize the impact to manifest_manager, but its a minor refactoring there). |
||
| updated_by: user, | ||
| version, | ||
| }, | ||
| { | ||
| // We intentionally hard coding the id so that there can only be one Trusted apps list within the space | ||
| id: ENDPOINT_TRUSTED_APPS_LIST_ID, | ||
| } | ||
| ); | ||
| return transformSavedObjectToExceptionList({ savedObject }); | ||
| } catch (err) { | ||
| if (savedObjectsClient.errors.isConflictError(err)) { | ||
| return null; | ||
| } else { | ||
| throw err; | ||
| } | ||
| } | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.