-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[SECURITY_SOLUTION][ENDPOINT] Fix created_by for Trusted Apps Create api to reflect current logged in user
#76557
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] Fix created_by for Trusted Apps Create api to reflect current logged in user
#76557
Conversation
…ed-apps-create_by # Conflicts: # x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/handlers.ts # x-pack/plugins/security_solution/server/endpoint/routes/trusted_apps/trusted_apps.test.ts
|
Pinging @elastic/endpoint-management (Team:Endpoint Management) |
|
Pinging @elastic/endpoint-app-team (Feature:Endpoint) |
| import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock'; | ||
|
|
||
| type RequestHandlerContextWithLists = ReturnType<typeof xpackMocks.createRequestHandlerContext> & { | ||
| lists?: { |
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.
@madirey , @FrankHassanabad ,
I would like to define this lists type here by referencing a Type in Lists plugin. You currently have this type defined in server/types.ts:
kibana/x-pack/plugins/lists/server/types.ts
Lines 43 to 46 in fe1c508
| export type ContextProviderReturn = Promise<{ | |
| getListClient: () => ListClient; | |
| getExceptionListClient: () => ExceptionListClient; | |
| }>; |
Would you be ok if I break out the object that this Promise<> wraps into a separate interface so that I can reference it? so it would be something like:
export interface ListsRequestHandlerContext {
getListClient: () => ListClient;
getExceptionListClient: () => ExceptionListClient;
}
export type ContextProviderReturn = Promise<ListsRequestHandlerContext>;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.
That's fine with me, but I'd get @FrankHassanabad or @yctercero to sign off...
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.
Thanks for the feedback @madirey :)
If @FrankHassanabad does get some time to comment here 😬 , I have also been wondering the following:
I see that the context provided by Kibana server to each route handler some how "knows" about the lists namespace in it although the RequestHandler<> generic type does not have a way to set it. Is it because of this definition in the server/types:
kibana/x-pack/plugins/lists/server/types.ts
Lines 47 to 54 in fe1c508
| declare module 'src/core/server' { | |
| interface RequestHandlerContext { | |
| lists?: { | |
| getExceptionListClient: () => ExceptionListClient; | |
| getListClient: () => ListClient; | |
| }; | |
| } | |
| } |
|
👍 from me, but would like @madirey or @FrankHassanabad to also take a look |
pzl
left a comment
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.
lgtm
|
@elasticmachine merge upstream |
💚 Build SucceededBuild metrics
History
To update your PR or re-run it, just comment with: |
…e api to reflect current logged in user (elastic#76557) * Fix: use exceptionLists client from route handler context * Adjust test to use `listMock` * Remove exceptionListClient service from `EndpointAppContextService` * Added UT for Trusted Apps to validate that ExceptionListClient from context is used Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…e api to reflect current logged in user (#76557) (#76974) * Fix: use exceptionLists client from route handler context * Adjust test to use `listMock` * Remove exceptionListClient service from `EndpointAppContextService` * Added UT for Trusted Apps to validate that ExceptionListClient from context is used Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Summary
Fixed Trusted Apps API implementation so that the it uses the
ExceptionListClientscope to the API request handler context, which reflects the current user doing the API call.With this in place, the EndpointAppContextService was adjusted and the prior changes that stored the
ExceptionListClientfrom the.start()phase was removed (no longer used)To Test
superuserrolecreated_by: