[9.3] [HTTP] Safer client calls and new browser buildPath utility (#257230)#265811
Closed
jeramysoucy wants to merge 1 commit into
Closed
[9.3] [HTTP] Safer client calls and new browser buildPath utility (#257230)#265811jeramysoucy wants to merge 1 commit into
buildPath utility (#257230)#265811jeramysoucy wants to merge 1 commit into
Conversation
…c#257230) - Create a new best-effort ESLint rule that checks if `http<method>` calls are used dangerously: direct path injection - Adds a new `buildPath` utility that can be used with server-side routes `/api/myapi/{id}` to safely build and encode path parameters (**bonus**: server-side path `const`s can be reused by the client directly, no need to build these separately by hand) - Updates existing usages ### No unsafe `http` path usage Will flag usages of `http` like: ```ts core.http.delete(`/api/myapi/${id}`, {...}); ``` With a message to use `buildPath` or `encodeURIComponent` in order to safely encode parameters. ### `buildPath` Not strictly needed in this PR, this utility allows for using server side paths like `/api/myapi/{id}` in a parameterised fashion like: ```ts import { buildPath } from '@kbn/core-http-browser'; buildPath('/api/dashboard/{id}' /* same as { path: ... } server side */, { id }) // => /api/dashboard/encoded-id ``` Happy to exclude this utility if it simplifies things. (Made with cursor y'all) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Gerard Soldevila <gerard.soldevila@elastic.co> (cherry picked from commit 2d72284) # Conflicts: # .eslintrc.js # packages/kbn-optimizer/limits.yml # src/platform/plugins/shared/dashboard/moon.yml # src/platform/plugins/shared/dashboard/public/dashboard_client/dashboard_client.ts # src/platform/plugins/shared/dashboard/tsconfig.json # src/platform/plugins/shared/dashboard_markdown/moon.yml # src/platform/plugins/shared/dashboard_markdown/public/markdown_client/markdown_client.ts # src/platform/plugins/shared/dashboard_markdown/tsconfig.json # src/platform/plugins/shared/data/public/search/search_interceptor/search_interceptor.ts # x-pack/platform/plugins/private/canvas/moon.yml # x-pack/platform/plugins/private/canvas/tsconfig.json # x-pack/platform/plugins/private/logstash/moon.yml # x-pack/platform/plugins/private/logstash/tsconfig.json # x-pack/platform/plugins/shared/lens/moon.yml # x-pack/platform/plugins/shared/lens/public/persistence/lens_client.ts # x-pack/platform/plugins/shared/lens/tsconfig.json # x-pack/platform/plugins/shared/osquery/moon.yml # x-pack/platform/plugins/shared/osquery/tsconfig.json
Contributor
|
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
auto-merge was automatically disabled
April 27, 2026 15:01
Pull request was converted to draft
Contributor
|
🤖 Jobs for this PR can be triggered through checkboxes. 🚧
ℹ️ To trigger the CI, please tick the checkbox below 👇
|
Contributor
Author
|
Duplicate of #265250 |
Contributor
💔 Build Failed
Failed CI StepsMetrics [docs]Module Count
Async chunks
Page load bundle
History |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport
This will backport the following commits from
mainto9.3:buildPathutility (#257230)Questions ?
Please refer to the Backport tool documentation