-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Infrastructure UI] Add strict payload validation to inventory_views endpoint #160852
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
Merged
crespocarlos
merged 21 commits into
elastic:main
from
crespocarlos:157505-inventory-view-strict-input-validation
Jul 5, 2023
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
a141531
Add strict payload validation to invntory_views endpoint
crespocarlos bf4a41c
Update README.md
crespocarlos 6e1fe5e
Fix update endpoint payload type
crespocarlos d621f6b
Refactor saved view types
crespocarlos 58b71bb
Revert some type changes and adjust toolbar_control component
crespocarlos c70fb9b
Merge branch 'main' into 157505-inventory-view-strict-input-validation
kibanamachine 10c042d
Merge branch 'main' of github.com:elastic/kibana into 157505-inventor…
crespocarlos ed95718
Decouple Saved View schema
crespocarlos 4e0e533
Inventory Views API type refactoring
crespocarlos c35542b
Fix after changing the find_inventory_view type
crespocarlos c71f345
Fix after changing the find_inventory_view type
crespocarlos 663b389
Merge branch '157505-inventory-view-strict-input-validation' of githu…
crespocarlos fc0256f
Clean up
crespocarlos 1fe79b5
More clean up
crespocarlos f343285
Fix missing attributes
crespocarlos 3cc8ba2
Improve mapper
crespocarlos 4f9933a
Merge branch 'main' into 157505-inventory-view-strict-input-validation
kibanamachine 43cc290
Typo
crespocarlos 5eac15f
Merge branch 'main' into 157505-inventory-view-strict-input-validation
kibanamachine 2d24158
Merge branch 'main' into 157505-inventory-view-strict-input-validation
kibanamachine c00ae1b
Merge branch 'main' into 157505-inventory-view-strict-input-validation
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,8 @@ | ||
| /* | ||
| * 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 * from './types'; |
This file contains hidden or 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,70 @@ | ||
| /* | ||
| * 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 { | ||
| QueryObserverBaseResult, | ||
| UseMutateAsyncFunction, | ||
| UseMutateFunction, | ||
| } from '@tanstack/react-query'; | ||
|
|
||
| import { IHttpFetchError, ResponseErrorBody } from '@kbn/core-http-browser'; | ||
|
|
||
| export type ServerError = IHttpFetchError<ResponseErrorBody>; | ||
|
|
||
| export interface SavedViewState<TView> { | ||
| views?: SavedViewItem[]; | ||
| currentView?: TView | null; | ||
| isCreatingView: boolean; | ||
| isFetchingCurrentView: boolean; | ||
| isFetchingViews: boolean; | ||
| isUpdatingView: boolean; | ||
| } | ||
|
|
||
| export interface SavedViewOperations< | ||
| TView extends { id: TView['id'] }, | ||
| TId extends TView['id'] = TView['id'], | ||
| TPayload = any, | ||
| TConfig = any | ||
| > { | ||
| createView: UseMutateAsyncFunction<TView, ServerError, TPayload>; | ||
| deleteViewById: UseMutateFunction<null, ServerError, string, MutationContext<TView>>; | ||
| fetchViews: QueryObserverBaseResult<SavedViewItem[]>['refetch']; | ||
| updateViewById: UseMutateAsyncFunction<TView, ServerError, UpdateViewParams<TPayload>>; | ||
| switchViewById: (id: TId) => void; | ||
| setDefaultViewById: UseMutateFunction<TConfig, ServerError, string, MutationContext<TView>>; | ||
| } | ||
|
|
||
| export interface SavedViewResult< | ||
| TView extends { | ||
| id: TView['id']; | ||
| }, | ||
| TId extends string = '', | ||
| TPayload = any, | ||
| TConfig = any | ||
| > extends SavedViewState<TView>, | ||
| SavedViewOperations<TView, TId, TPayload, TConfig> {} | ||
|
|
||
| export interface UpdateViewParams<TRequestPayload> { | ||
| id: string; | ||
| attributes: TRequestPayload; | ||
| } | ||
|
|
||
| export interface MutationContext<TView> { | ||
| id?: string; | ||
| previousViews?: TView[]; | ||
| } | ||
|
|
||
| export interface BasicAttributes { | ||
| name?: string; | ||
| time?: number; | ||
| isDefault?: boolean; | ||
| isStatic?: boolean; | ||
| } | ||
| export interface SavedViewItem { | ||
| id: string; | ||
| attributes: BasicAttributes; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
question: I remembered this was a strict type to strip out the non-essential properties for this endpoint when the response is encoded in the server, I think doing so it will now leak all SO attributes on this response for every saved view, could you verify that please?
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.
I didn't see any weird attributes. I'll check it again.
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.
Fixed it. thanks!