-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[SECURITY_SOLUTION][ENDPOINT] Trusted Apps Create API #76178
Changes from 8 commits
f7916c3
2bcdb8f
85da730
2d6eb5f
dabdc0d
9d97356
993d31a
13c072e
34b3da6
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 |
---|---|---|
|
@@ -5,9 +5,15 @@ | |
*/ | ||
|
||
import { IRouter } from 'kibana/server'; | ||
import { GetTrustedAppsRequestSchema } from '../../../../common/endpoint/schema/trusted_apps'; | ||
import { TRUSTED_APPS_LIST_API } from '../../../../common/endpoint/constants'; | ||
import { getTrustedAppsListRouteHandler } from './handlers'; | ||
import { | ||
GetTrustedAppsRequestSchema, | ||
PostTrustedAppCreateRequestSchema, | ||
} from '../../../../common/endpoint/schema/trusted_apps'; | ||
import { | ||
TRUSTED_APPS_CREATE_API, | ||
TRUSTED_APPS_LIST_API, | ||
} from '../../../../common/endpoint/constants'; | ||
import { getTrustedAppsCreateRouteHandler, getTrustedAppsListRouteHandler } from './handlers'; | ||
import { EndpointAppContext } from '../../types'; | ||
|
||
export const registerTrustedAppsRoutes = ( | ||
|
@@ -23,4 +29,14 @@ export const registerTrustedAppsRoutes = ( | |
}, | ||
getTrustedAppsListRouteHandler(endpointAppContext) | ||
); | ||
|
||
// CREATE | ||
router.post( | ||
{ | ||
path: TRUSTED_APPS_CREATE_API, | ||
validate: PostTrustedAppCreateRequestSchema, | ||
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. if the schema doesn't validate here, we get a 400 error? Do we get a meaningful message from the error? From your tests, it looks like an error will be thrown as expected - 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. they are "typical" errors thrown by the schema lib. Here are a few examples: // entries was an empty array
{
'statusCode': 400,
'error': 'Bad Request',
'message': '[request body.entries]: array size is [0], but cannot be smaller than [1]',
} // enty had os set to `winz`
{
'statusCode': 400,
'error': 'Bad Request',
'message': '[request body.os]: types that failed validation:\n- [request body.os.0]: expected value to equal [linux]\n- [request body.os.1]: expected value to equal [macos]\n- [request body.os.2]: expected value to equal [windows]',
} |
||
options: { authRequired: true }, | ||
}, | ||
getTrustedAppsCreateRouteHandler(endpointAppContext) | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will check if the list is created first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes - the
createTrustedAppsLists()
method will not create it if it already exists - a warning is logged to the kibana log. Ref:kibana/x-pack/plugins/lists/server/services/exception_lists/create_endpoint_trusted_apps_list.ts
Lines 70 to 72 in d462274
(FYI: I just noticed the
?
in the above code - will remove it (no longer needed)