-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[inspector] show request method, path, and querystring (#169970)
Closes #45931 PR updates data plugin `search` and `bsearch` endpoints to return method, path, and querystring request params from elasticsearch-js client requests. This provides inspector with the exact details used to fetch data from elasticsearch, ensuring inspector displays request exactly as used by elasticsearch-js client. **ESQL** This PR makes it possible to open ESQL searches in console. <img width="500" alt="Screen Shot 2023-09-16 at 4 19 58 PM" src="https://github.com/elastic/kibana/assets/373691/56019fb5-ca88-46cf-a42f-86f5f51edfcc"> ### background If you are thinking to yourself, "haven't I reviewed this before?", you are right. This functionality has been through several iterations. 1) Original PR #166565 was reverted for exposing `headers`. 2) [Fix to only expose method, path, and querystring keys from request parameters](#167544) was rejected because it applied changes to `kibana_utils/server/report_server_error.ts`, which is used extensively throughout Kibana. 3) This iteration moves logic into the data plugin to be as narrow as possible. --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
45d0e32
commit f284454
Showing
29 changed files
with
627 additions
and
43 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
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
41 changes: 41 additions & 0 deletions
41
src/plugins/data/server/search/sanitize_request_params.test.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,41 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { sanitizeRequestParams } from './sanitize_request_params'; | ||
|
||
describe('sanitizeRequestParams', () => { | ||
test('should remove headers and body', () => { | ||
expect( | ||
sanitizeRequestParams({ | ||
method: 'POST', | ||
path: '/endpoint', | ||
querystring: 'param1=value', | ||
headers: { | ||
Connection: 'Keep-Alive', | ||
}, | ||
body: 'response', | ||
}) | ||
).toEqual({ | ||
method: 'POST', | ||
path: '/endpoint', | ||
querystring: 'param1=value', | ||
}); | ||
}); | ||
|
||
test('should not include querystring key when its not provided', () => { | ||
expect( | ||
sanitizeRequestParams({ | ||
method: 'POST', | ||
path: '/endpoint', | ||
}) | ||
).toEqual({ | ||
method: 'POST', | ||
path: '/endpoint', | ||
}); | ||
}); | ||
}); |
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,20 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import type { ConnectionRequestParams } from '@elastic/transport'; | ||
import type { SanitizedConnectionRequestParams } from '../../common'; | ||
|
||
export function sanitizeRequestParams( | ||
requestParams: ConnectionRequestParams | ||
): SanitizedConnectionRequestParams { | ||
return { | ||
method: requestParams.method, | ||
path: requestParams.path, | ||
...(requestParams.querystring ? { querystring: requestParams.querystring } : {}), | ||
}; | ||
} |
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
Oops, something went wrong.