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.
[Security solution] [Endpoint] Adds API check for existing policies w…
…hen saving/creating trusted apps (elastic#106110) (elastic#106975) * Adds API check for existing policies when saving/creating trusted apps * Fixes wrong error message * Fixes tests and replaces policy id by policy name in error message * Updates error message text * Address pr comments and remove old comments in code * Addressed some pr comments and added type to the error response in order to know which kind of response it is * removed unused imports Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: David Sánchez <[email protected]>
- Loading branch information
1 parent
9c28da7
commit 3e2a915
Showing
8 changed files
with
377 additions
and
52 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
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
62 changes: 62 additions & 0 deletions
62
x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/mocks.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,62 @@ | ||
/* | ||
* 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 { PackagePolicy } from '../../../../../fleet/common'; | ||
|
||
import { | ||
ConditionEntryField, | ||
OperatingSystem, | ||
TrustedApp, | ||
} from '../../../../common/endpoint/types'; | ||
import { createConditionEntry } from './mapping'; | ||
|
||
export const getTrustedAppByPolicy = function (): TrustedApp { | ||
return { | ||
id: '123', | ||
version: 'abc123', | ||
created_at: '11/11/2011T11:11:11.111', | ||
created_by: 'admin', | ||
updated_at: '11/11/2011T11:11:11.111', | ||
updated_by: 'admin', | ||
name: 'linux trusted app 1', | ||
description: 'Linux trusted app 1', | ||
os: OperatingSystem.LINUX, | ||
effectScope: { | ||
type: 'policy', | ||
policies: ['e5cbb9cf-98aa-4303-a04b-6a1165915079', '9da95be9-9bee-4761-a8c4-28d6d9bd8c71'], | ||
}, | ||
entries: [ | ||
createConditionEntry(ConditionEntryField.HASH, 'match', '1234234659af249ddf3e40864e9fb241'), | ||
createConditionEntry(ConditionEntryField.PATH, 'match', '/bin/malware'), | ||
], | ||
}; | ||
}; | ||
|
||
export const getPackagePoliciesResponse = function (): PackagePolicy[] { | ||
return [ | ||
// Next line is ts-ignored as this is the response when the policy doesn't exists but the type is complaining about it. | ||
// @ts-ignore | ||
{ id: '9da95be9-9bee-4761-a8c4-28d6d9bd8c71', version: undefined }, | ||
{ | ||
id: 'e5cbb9cf-98aa-4303-a04b-6a1165915079', | ||
version: 'Wzc0NDk5LDFd', | ||
name: 'EI 2', | ||
description: '', | ||
namespace: 'default', | ||
policy_id: '9fd2ac50-e86f-11eb-a87f-51e16104076a', | ||
enabled: true, | ||
output_id: '', | ||
inputs: [], | ||
package: { name: 'endpoint', title: 'Endpoint Security', version: '0.20.1' }, | ||
revision: 3, | ||
created_at: '2021-07-19T09:00:45.608Z', | ||
created_by: 'elastic', | ||
updated_at: '2021-07-19T09:02:47.193Z', | ||
updated_by: 'system', | ||
}, | ||
]; | ||
}; |
Oops, something went wrong.