Commit graph

55 commits

Author SHA1 Message Date
Kibana Machine
358b2795f2
[8.x] Update deprecations carried over from 8 (#195491) (#195654)
# Backport

This will backport the following commits from `main` to `8.x`:
- [Update deprecations carried over from 8
(#195491)](https://github.com/elastic/kibana/pull/195491)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Christiane (Tina)
Heiligers","email":"christiane.heiligers@elastic.co"},"sourceCommit":{"committedDate":"2024-10-09T17:12:52Z","message":"Update
deprecations carried over from 8 (#195491)\n\nFix
https://github.com/elastic/kibana/issues/142915\r\n\r\n### Risk
Matrix\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Third party plugin types throw type errors | Low | Low | type
checks\r\nwill error when using a deprecated type. Plugin authors should
extend\r\nthe supported types or define new ones inline |\r\n\r\n### For
maintainers\r\n\r\n- [X] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n(no
breaking
changes)","sha":"5ed13ee4a4b4325bae2f3e117a4fc400540fa542","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","v9.0.0","backport:prev-minor","v8.16.0"],"title":"Update
deprecations carried over from
8","number":195491,"url":"https://github.com/elastic/kibana/pull/195491","mergeCommit":{"message":"Update
deprecations carried over from 8 (#195491)\n\nFix
https://github.com/elastic/kibana/issues/142915\r\n\r\n### Risk
Matrix\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Third party plugin types throw type errors | Low | Low | type
checks\r\nwill error when using a deprecated type. Plugin authors should
extend\r\nthe supported types or define new ones inline |\r\n\r\n### For
maintainers\r\n\r\n- [X] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n(no
breaking
changes)","sha":"5ed13ee4a4b4325bae2f3e117a4fc400540fa542"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195491","number":195491,"mergeCommit":{"message":"Update
deprecations carried over from 8 (#195491)\n\nFix
https://github.com/elastic/kibana/issues/142915\r\n\r\n### Risk
Matrix\r\n\r\n| Risk | Probability | Severity | Mitigation/Notes
|\r\n\r\n|---------------------------|-------------|----------|-------------------------|\r\n|
Third party plugin types throw type errors | Low | Low | type
checks\r\nwill error when using a deprecated type. Plugin authors should
extend\r\nthe supported types or define new ones inline |\r\n\r\n### For
maintainers\r\n\r\n- [X] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n(no
breaking
changes)","sha":"5ed13ee4a4b4325bae2f3e117a4fc400540fa542"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Christiane (Tina) Heiligers <christiane.heiligers@elastic.co>
2024-10-09 21:14:11 +02:00
Kibana Machine
d57df631aa
[8.x] Consume elasticsearch.publicBaseUrl where possible (#192741) (#193442)
# Backport

This will backport the following commits from `main` to `8.x`:
- [Consume elasticsearch.publicBaseUrl where possible
(#192741)](https://github.com/elastic/kibana/pull/192741)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Sander
Philipse","email":"94373878+sphilipse@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-09-19T14:57:47Z","message":"Consume
elasticsearch.publicBaseUrl where possible (#192741)\n\n##
Summary\r\n\r\nThis actually consumes the public base url in the cloud
plugin and the\r\nplaces depending on the `elasticsearchUrl` value
populated there.\r\n\r\n---------\r\n\r\nCo-authored-by: Rodney Norris
<rodney@tattdcodemonkey.com>","sha":"b4a7b2e2164974e5dd9b8c1708c35d58bd021105","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","backport:prev-major","v8.16.0"],"title":"Consume
elasticsearch.publicBaseUrl where
possible","number":192741,"url":"https://github.com/elastic/kibana/pull/192741","mergeCommit":{"message":"Consume
elasticsearch.publicBaseUrl where possible (#192741)\n\n##
Summary\r\n\r\nThis actually consumes the public base url in the cloud
plugin and the\r\nplaces depending on the `elasticsearchUrl` value
populated there.\r\n\r\n---------\r\n\r\nCo-authored-by: Rodney Norris
<rodney@tattdcodemonkey.com>","sha":"b4a7b2e2164974e5dd9b8c1708c35d58bd021105"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192741","number":192741,"mergeCommit":{"message":"Consume
elasticsearch.publicBaseUrl where possible (#192741)\n\n##
Summary\r\n\r\nThis actually consumes the public base url in the cloud
plugin and the\r\nplaces depending on the `elasticsearchUrl` value
populated there.\r\n\r\n---------\r\n\r\nCo-authored-by: Rodney Norris
<rodney@tattdcodemonkey.com>","sha":"b4a7b2e2164974e5dd9b8c1708c35d58bd021105"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Sander Philipse <94373878+sphilipse@users.noreply.github.com>
2024-09-24 06:33:17 -05:00
Kibana Machine
022813ba21
[8.x] [core] get headers from fakeRequest in secondary user client (#192394) (#193815)
# Backport

This will backport the following commits from `main` to `8.x`:
- [[core] get headers from fakeRequest in secondary user client
(#192394)](https://github.com/elastic/kibana/pull/192394)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kevin
Lacabane","email":"kevin.lacabane@elastic.co"},"sourceCommit":{"committedDate":"2024-09-13T02:32:13Z","message":"[core]
get headers from fakeRequest in secondary user client (#192394)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/192004\r\n\r\nCalling
`client.asSecondaryAuthUser` from a client scoped to a fake\r\nrequest
instantiated with `getKibanaFakeRequest` returns the
following\r\nerror:\r\n`Error: asSecondaryAuthUser called from a client
scoped to a request\r\nwithout 'authorization' header.`.\r\n\r\nThis is
because we use the same branch when dealing with a real or
fake\r\nrequest and expect the headers to be cached. There are existing
tests to\r\nverify a fake request works but these requests are raw
objects not\r\ncreated through `getKibanaFakeRequest`\r\n\r\n###
Testing\r\nThis snippet does not throw\r\n```\r\nconst fakeRequest =
getFakeKibanaRequest({ id: apiKey.id, api_key: apiKey.apiKey
});\r\nconst esClient =
server.core.elasticsearch.client.asScoped(fakeRequest).asSecondaryAuthUser;\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"0987f70112aeeef0ffa9b670d86a5b5f82d60454","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor"],"title":"[core]
get headers from fakeRequest in secondary user
client","number":192394,"url":"https://github.com/elastic/kibana/pull/192394","mergeCommit":{"message":"[core]
get headers from fakeRequest in secondary user client (#192394)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/192004\r\n\r\nCalling
`client.asSecondaryAuthUser` from a client scoped to a fake\r\nrequest
instantiated with `getKibanaFakeRequest` returns the
following\r\nerror:\r\n`Error: asSecondaryAuthUser called from a client
scoped to a request\r\nwithout 'authorization' header.`.\r\n\r\nThis is
because we use the same branch when dealing with a real or
fake\r\nrequest and expect the headers to be cached. There are existing
tests to\r\nverify a fake request works but these requests are raw
objects not\r\ncreated through `getKibanaFakeRequest`\r\n\r\n###
Testing\r\nThis snippet does not throw\r\n```\r\nconst fakeRequest =
getFakeKibanaRequest({ id: apiKey.id, api_key: apiKey.apiKey
});\r\nconst esClient =
server.core.elasticsearch.client.asScoped(fakeRequest).asSecondaryAuthUser;\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"0987f70112aeeef0ffa9b670d86a5b5f82d60454"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192394","number":192394,"mergeCommit":{"message":"[core]
get headers from fakeRequest in secondary user client (#192394)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/192004\r\n\r\nCalling
`client.asSecondaryAuthUser` from a client scoped to a fake\r\nrequest
instantiated with `getKibanaFakeRequest` returns the
following\r\nerror:\r\n`Error: asSecondaryAuthUser called from a client
scoped to a request\r\nwithout 'authorization' header.`.\r\n\r\nThis is
because we use the same branch when dealing with a real or
fake\r\nrequest and expect the headers to be cached. There are existing
tests to\r\nverify a fake request works but these requests are raw
objects not\r\ncreated through `getKibanaFakeRequest`\r\n\r\n###
Testing\r\nThis snippet does not throw\r\n```\r\nconst fakeRequest =
getFakeKibanaRequest({ id: apiKey.id, api_key: apiKey.apiKey
});\r\nconst esClient =
server.core.elasticsearch.client.asScoped(fakeRequest).asSecondaryAuthUser;\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"0987f70112aeeef0ffa9b670d86a5b5f82d60454"}}]}]
BACKPORT-->

Co-authored-by: Kevin Lacabane <kevin.lacabane@elastic.co>
2024-09-24 01:57:44 -05:00
Alejandro Fernández Haro
71ad243504
[8.x] [Feature Flags Service] Hello world 👋 (#188562) (#193519)
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Feature Flags Service] Hello world 👋
(#188562)](https://github.com/elastic/kibana/pull/188562)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Alejandro Fernández
Haro","email":"alejandro.haro@elastic.co"},"sourceCommit":{"committedDate":"2024-09-18T16:02:55Z","message":"[Feature
Flags Service] Hello world 👋 (#188562)\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Jean-Louis Leysens
<jloleysens@gmail.com>","sha":"02ce1b91014eb59f019854b01325bbdf983d2218","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","Team:Operations","Team:Security","release_note:skip","Team:Observability","Team:Fleet","v9.0.0","Team:
SecuritySolution","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-logs"],"number":188562,"url":"https://github.com/elastic/kibana/pull/188562","mergeCommit":{"message":"[Feature
Flags Service] Hello world 👋 (#188562)\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Jean-Louis Leysens
<jloleysens@gmail.com>","sha":"02ce1b91014eb59f019854b01325bbdf983d2218"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/188562","number":188562,"mergeCommit":{"message":"[Feature
Flags Service] Hello world 👋 (#188562)\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by:
Jean-Louis Leysens
<jloleysens@gmail.com>","sha":"02ce1b91014eb59f019854b01325bbdf983d2218"}}]}]
BACKPORT-->
2024-09-20 12:21:41 +02:00
Luke Elmers
b6287708f6
Adds AGPL 3.0 license (#192025)
Updates files outside of x-pack to be triple-licensed under Elastic
License 2.0, AGPL 3.0, or SSPL 1.0.
2024-09-06 19:02:41 -06:00
Sander Philipse
d21d3987e8
Add publicBaseUrl to Elasticsearch config (#191837)
## Summary

This adds a publicBaseUrl to the Elasticsearch plugin config so users
can set a publicly accessible URL for Elasticsearch.

---------

Co-authored-by: Rudolf Meijering <skaapgif@gmail.com>
2024-09-04 13:45:27 +02:00
Larry Gregory
74d88580a5
Migrate codebase to use Object.hasOwn instead of Object.hasOwnProperty (#186829)
## Summary

This PR has breadth, but not depth. This adds 3 new `eslint` rules. The
first two protect against the use of code generated from strings (`eval`
and friends), which will not work client-side due to our CSP, and is not
something we wish to support server-side. The last rule aims to prevent
a subtle class of bugs, and to defend against a subset of prototype
pollution exploits:

- `no-new-func` to be compliant with our CSP, and to prevent code
execution from strings server-side:
https://eslint.org/docs/latest/rules/no-new-func
- `no-implied-eval` to be compliant with our CSP, and to prevent code
execution from strings server-side:
https://eslint.org/docs/latest/rules/no-implied-eval. Note that this
function implies that it prevents no-new-func, but I don't see [test
cases](https://github.com/eslint/eslint/blob/main/tests/lib/rules/no-implied-eval.js)
covering this behavior, so I think we should play it safe and enable
both rules.
- `no-prototype-builtins` to prevent accessing shadowed properties:
https://eslint.org/docs/latest/rules/no-prototype-builtins


In order to be compliant with `no-prototype-builtins`, I've migrated all
usages and variants of `Object.hasOwnProperty` to use the newer
[`Object.hasOwn`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwn).
2024-08-13 10:30:19 -05:00
Jean-Louis Leysens
7e46462ec1
[Status] Log every error message even during setup phase (#189417)
## Summary

It's possible that during setup phase we run into errors connecting to
ES. For support it would be useful to log those too.
2024-08-01 13:03:17 +02:00
Alejandro Fernández Haro
11b750b10a
Minimize shared-common everywhere (#188606)
## Summary


![8xfggo](https://github.com/user-attachments/assets/f3d9312f-2ad3-4fa2-9daf-01e2b1ad6cac)

At the moment, our package generator creates all packages with the type
`shared-common`. This means that we cannot enforce boundaries between
server-side-only code and the browser, and vice-versa.

- [x] I started fixing `packages/core/*`
- [x] It took me to fixing `src/core/` type to be identified by the
`plugin` pattern (`public` and `server` directories) vs. a package
(either common, or single-scoped)
- [x] Unsurprisingly, this extended to packages importing core packages
hitting the boundaries eslint rules. And other packages importing the
latter.
- [x] Also a bunch of `common` logic that shouldn't be so _common_ 🙃 

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-07-29 12:47:46 -06:00
Pierre Gayvallet
85f67dd39a
Implement elasticsearch.maxResponseSize config option (#186291)
## Summary

Fix https://github.com/elastic/kibana/issues/185042

- Add a new `elasticsearch.maxResponseSize` config option 
- Set this value to `100mb` on our serverless configuration file

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-06-19 11:04:33 +02:00
Pierre Gayvallet
350b34b246
Add secondary authentication to Core ES client (#184901)
## Summary

Fix https://github.com/elastic/kibana/issues/179458

Add a third method to `IScopedClusterClient`, `asSecondaryAuth` which
allow performing requests on behalf of the kibana system users with the
current user as secondary authentication (via the
`es-secondary-authorization` header)
2024-06-13 05:55:30 -07:00
Alejandro Fernández Haro
7d5ddbd418
[DNS caching] Use duration as setting (#185923) 2024-06-11 07:43:28 -07:00
Alejandro Fernández Haro
b1ff240cc4
Use DNS caching (#184760)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Jean-Louis Leysens <jeanlouis.leysens@elastic.co>
2024-06-10 14:33:38 +02:00
Pierre Gayvallet
65b1d9489a
Add log entry and telemetry info about time Kibana waits for ES during startup (#180765)
## Summary

This PR attempts to make it easier to quantity the time we're spending
waiting on ES during Kibana startup.

- Add a log entry once successfully connected to ES, surfacing the info
of how much time we waited.
- Add two new metric to our `kibana_started` event:
  - the time we spent waiting for ES
  - the time it took to perform the SO migration
 
Note that for "BWC" reasons (primarily - and simplicity's sake too)
we've not subtracting the time we spent from the `start` lifecycle
timing we already had.
2024-04-16 00:46:06 -07:00
Alejandro Fernández Haro
1c1e20afdb
Use rxjs instead of rxjs/operators (#179553) 2024-04-02 11:41:33 -07:00
Pierre Gayvallet
c0ad45f527
Use a shorter ES health check interval before initial green (#179023)
## Summary

Use a shorter interval for Elasticsearch healthchecks before the first
green status, to overall reduce the time spent waiting for ES when both
Kibana and ES are starting at the same time.
2024-03-22 16:41:03 +01:00
Gerard Soldevila
e5e32f74e2
Get rid of the undesired 404 Not Found on fresh startup (#176797)
## Summary

When starting with a clean ES (with no SO indices), Kibana fails to find
the `.kibana` index, and logs a _warning_ message.
This PR aims at removing that undesired line from the logs.
2024-02-23 05:15:55 -07:00
Aleh Zasypkin
74210343a2
Allow using JWT credentials to grant API keys. (#172444)
## Summary

In this PR we:
* Allow using JWT credentials to grant API keys
* Extend default value of `elasticsearch.requestHeadersWhitelist` to
include both `authorization` and `es-client-authentication` to support
JWT with required client authentication _by default_. See
https://www.elastic.co/guide/en/elasticsearch/reference/8.11/jwt-auth-realm.html#jwt-realm-configuration
* Add API integration tests for both JWTs with client authentication and
without it


__NOTE:__ We're not gating this functionality with the config flag
(`xpack.security.authc.http.jwt.taggedRoutesOnly`) as we did for the
Serverless offering. It'd be a breaking change as we already implicitly
support JWT authentication without client authentication, and to be
honest, it's not really necessary anyway.

## Testing

Refer to the `Testing` section in this PR description:
https://github.com/elastic/kibana/pull/159117.

Or run already pre-configured Kibana functional test server: 
1. `node scripts/functional_tests_server.js --config
x-pack/test/security_api_integration/api_keys.config.ts`
2. Create a role mapping for JWT user:
```bash
curl -X POST --location "http://localhost:9220/_security/role_mapping/jwt" \
    -H "Authorization: Basic ZWxhc3RpYzpjaGFuZ2VtZQ==" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -d "{
          \"roles\": [ \"superuser\" ],
          \"enabled\": true,
          \"rules\": { \"all\": [{\"field\" : { \"realm.name\" : \"jwt_with_secret\" }}] }
        }"
```
3. Send any Kibana API request with the following credentials:
```bash
curl -X POST --location "xxxx"
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2tpYmFuYS5lbGFzdGljLmNvL2p3dC8iLCJzdWIiOiJlbGFzdGljLWFnZW50IiwiYXVkIjoiZWxhc3RpY3NlYXJjaCIsIm5hbWUiOiJFbGFzdGljIEFnZW50IiwiaWF0Ijo5NDY2ODQ4MDAsImV4cCI6NDA3MDkwODgwMH0.P7RHKZlLskS5DfVRqoVO4ivoIq9rXl2-GW6hhC9NvTSkwphYivcjpTVcyENZvxTTvJJNqcyx6rF3T-7otTTIHBOZIMhZauc5dob-sqcN_mT2htqm3BpSdlJlz60TBq6diOtlNhV212gQCEJMPZj0MNj7kZRj_GsECrTaU7FU0A3HAzkbdx15vQJMKZiFbbQCVI7-X2J0bZzQKIWfMHD-VgHFwOe6nomT-jbYIXtCBDd6fNj1zTKRl-_uzjVqNK-h8YW1h6tE4xvZmXyHQ1-9yNKZIWC7iEaPkBLaBKQulLU5MvW3AtVDUhzm6--5H1J85JH5QhRrnKYRon7ZW5q1AQ'
  -H 'ES-Client-Authentication: SharedSecret my_super_secret'

....for example....
curl -X GET --location "http://localhost:5620/internal/security/me" \
    -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2tpYmFuYS5lbGFzdGljLmNvL2p3dC8iLCJzdWIiOiJlbGFzdGljLWFnZW50IiwiYXVkIjoiZWxhc3RpY3NlYXJjaCIsIm5hbWUiOiJFbGFzdGljIEFnZW50IiwiaWF0Ijo5NDY2ODQ4MDAsImV4cCI6NDA3MDkwODgwMH0.P7RHKZlLskS5DfVRqoVO4ivoIq9rXl2-GW6hhC9NvTSkwphYivcjpTVcyENZvxTTvJJNqcyx6rF3T-7otTTIHBOZIMhZauc5dob-sqcN_mT2htqm3BpSdlJlz60TBq6diOtlNhV212gQCEJMPZj0MNj7kZRj_GsECrTaU7FU0A3HAzkbdx15vQJMKZiFbbQCVI7-X2J0bZzQKIWfMHD-VgHFwOe6nomT-jbYIXtCBDd6fNj1zTKRl-_uzjVqNK-h8YW1h6tE4xvZmXyHQ1-9yNKZIWC7iEaPkBLaBKQulLU5MvW3AtVDUhzm6--5H1J85JH5QhRrnKYRon7ZW5q1AQ' \
    -H 'ES-Client-Authentication: SharedSecret my_super_secret' \
    -H "Accept: application/json"
----
{
  "username": "elastic-agent",
  "roles": [
    "superuser"
  ],
  "full_name": null,
  "email": null,
  "metadata": {
    "jwt_claim_sub": "elastic-agent",
    "jwt_token_type": "access_token",
    "jwt_claim_iss": "https://kibana.elastic.co/jwt/",
    "jwt_claim_name": "Elastic Agent",
    "jwt_claim_aud": [
      "elasticsearch"
    ]
  },
  "enabled": true,
  "authentication_realm": {
    "name": "jwt_with_secret",
    "type": "jwt"
  },
  "lookup_realm": {
    "name": "jwt_with_secret",
    "type": "jwt"
  },
  "authentication_type": "realm",
  "authentication_provider": {
    "type": "http",
    "name": "__http__"
  },
  "elastic_cloud_user": false
}
```

__Fixes:__ https://github.com/elastic/kibana/issues/171522

----

Release note: The default value of the
`elasticsearch.requestHeadersWhitelist` configuration option has been
expanded to include the `es-client-authentication` HTTP header, in
addition to `authorization`.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-12-04 20:07:41 +01:00
Gerard Soldevila
b232a113c5
Retry ES calls when receiving 504 Gateway Timeout (#172439)
## Summary

Address https://github.com/elastic/kibana/issues/172352
2023-12-04 15:05:52 +01:00
Alejandro Fernández Haro
ac16c65bae
[Elasticsearch] Limit maxSockets to 800 by default (#151911)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Dzmitry Lemechko <dzmitry.lemechko@elastic.co>
2023-11-28 23:17:39 -05:00
Alejandro Fernández Haro
a77c4c0b69
[ES] Handle non-semver-compliant versions (#172093) 2023-11-28 13:36:23 -07:00
Pierre Gayvallet
11eb73ee1d
Add custom inspect representation for ES client's errors (#171304)
Follow-up of #171018
2023-11-15 17:20:45 +01:00
Alejandro Fernández Haro
da3833e513
[ES] cluster_build_flavor may be undefined (#171112) 2023-11-14 03:02:08 -07:00
Pierre Gayvallet
c43e6997af
redact ES client errors (#171018)
## Summary

Define a custom `toJSON` method on errors from the ES client to have
better control of the format of the output of their JSON serialization
2023-11-10 15:42:14 +01:00
Pierre Gayvallet
3647891f60
ES query logging: do not compute logging data when not necessary (#170319)
## Summary

Small performance optimization: don't compute the query/deprecation log
messages and meta if the appropriate log level isn't enabled.
2023-11-02 08:07:47 +01:00
Pierre Gayvallet
30ae931208
@kbn/config-schema: add option to accept numeric values for string type (#170214)
## Summary

Also use it for `elastic.password` config option.

Fix https://github.com/elastic/kibana/issues/55031
2023-11-01 09:47:05 +01:00
Pierre Gayvallet
8868d08745
make isInlineScriptingEnabled resilient to ES errors (#170208)
## Summary

Fix https://github.com/elastic/kibana/issues/163787

Change the way `isInlineScriptingEnabled` function to retry retryable
errors from ES (similar to how the valid connection or migration ES
calls do)
2023-10-31 13:55:03 +01:00
Alejandro Fernández Haro
5475946662
[Serverless] ES should ignore the version mismatch (#168076) 2023-10-05 14:27:29 +02:00
Pierre Gayvallet
53173f1033
Introducing the concept of ES capabilities (#164850)
## Summary

We recently got problems because some index creation settings are
rejected by stateless ES, causing the whole system to fail and Kibana to
terminate.

We can't really use feature flags for this, given:
1. it doesn't really make sense to use manual flags for something that
strictly depend on one of our dependency's capabilities
2. we're mixing the concept of "serverless" offering and "serverless"
build. Atm we sometimes run "serverless" Kibana against traditional ES,
meaning that the "serverless" info **cannot** be used to determine if
we're connected against a default or serverless version of ES.

This was something that was agreed a few weeks back, but never acted
upon.

## Introducing ES capabilities

This PR introduces the concept of elasticsearch "capabilities".

Those capabilities are built exclusively from info coming from the ES
cluster (and not by some config flag).

This first implementation simply exposes a `serverless` flag, that is
populated depending on the `build_flavor` field of the `info` API (`/`
endpoint).

The end goal would be to expose a real capabilities (e.g "what is
supported") list instead. But ideally this would be provided by some ES
API and not by us guessing what is supported depending on the build
flavor, so for now, just exposing whether we're connected to a default
of serverless ES will suffice.

### Using it to adapt some API calls during SO migration

This PR also adapts the `createIndex` and `cloneIndex` migration action
to use this information and change their request against ES accordingly
(removing some index creation parameters that are not supported).

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-08-28 10:20:27 +02:00
Alex Szabo
8cf68dc6ba
[Ops] Bump Node.js to version 18 (#160289)
## Summary

Bumps node.js to 18.17.0 (replacement for PR #144012 which was later
reverted)

As a result, these categorical additions were needed: 
- `node` evocations will need the `--openssl-legacy-provider` flag,
wherever it would use certain crypto functionalities
- tests required updating of the expected HTTPS Agent call arguments,
`noDelay` seems to be a default
 - `window.[NAME]` fields cannot be written directly
 - some stricter typechecks

This is using our in-house built node.js 18 versions through the URLs
the proxy-cache. (built with
https://github.com/elastic/kibana-custom-nodejs-builds/pull/4)

These urls are served from a bucket, where the RHEL7/Centos7 compatible
node distributables are. (see:
https://github.com/elastic/kibana-ci-proxy-cache/pull/7)

Further todos: 
 - [x] check docs wording and consistency
 - [ ] update the dependency report
 - [x] explain custom builds in documentation
 - [x] node_sass prebuilts

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Tiago Costa <tiago.costa@elastic.co>
Co-authored-by: Thomas Watson <w@tson.dk>
2023-07-27 14:12:48 +02:00
Aleh Zasypkin
303575544a
Updates header filters for request logs. (#162062)
## Summary

Updates
[header](https://www.elastic.co/guide/en/elasticsearch/reference/master/jwt-auth-realm.html#hmac-oidc-example-request-headers)
filters for request logs.

/cc @elastic/kibana-security
2023-07-18 10:56:07 +02:00
Pierre Gayvallet
37b48d344f
[root] only shutdown once (#161869)
## Summary

Analyzing the MKI QA logs, I discovered that errors encountered during
shutdown were effectively triggering a second shutdown process, making
the logs unclear:

<img width="1564" alt="Screenshot 2023-07-13 at 16 07 22"
src="8d718a99-2187-4fa3-b6f6-9c3f0e7a3925">

it has the side effect to also make "normals" shutdown (e.g via SIGINT
like in the screenshot) to appear as error shutdowns because of the
error thrown during the shutdown.

This PR addresses it, by making sure that `Root` only shutdown once.
Errors occurring during the shutdown will be appearing in the logs, but
they will not surface as the cause of the shutdown (no `FATAL` log
entry).
2023-07-14 11:41:49 +02:00
Gerard Soldevila
06c337f903
Refactor KibanaMigrator, improve readability, maintainability and UT (#155693)
Addresses the following feedback:
https://github.com/elastic/kibana/pull/154151#discussion_r1158470566

Similar to what has been done for ZDT, the goal of this PR is to extract
the logic of the `runV2Migration()` from the `KibanaMigrator` into a
separate file.

The PR also fixes some incomplete / incorrect UTs and adds a few missing
ones.
2023-06-01 14:47:40 +02:00
Alejandro Fernández Haro
ff6943376d
[Config Service] Expose serverless contextRef (#156837) 2023-05-08 17:39:12 +02:00
Alejandro Fernández Haro
1146d0387b
[Serverless] ES should ignore the version mismatch (#155984) 2023-04-27 15:19:30 +02:00
Alejandro Fernández Haro
5142d73243
[Elasticsearch] Redact logs from known APIs (#153049)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-03-18 10:50:09 +01:00
Alejandro Fernández Haro
f10777e5d5
[Elasticsearch] Log queued requests (#152571)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2023-03-06 14:25:44 +01:00
Christiane (Tina) Heiligers
b9f31afc23
Flags core mocks packages as devOnly (#149466)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Fix https://github.com/elastic/kibana/issues/145064
2023-01-26 08:46:06 -07:00
Spencer
afb09ccf8a
Transpile packages on demand, validate all TS projects (#146212)
## Dearest Reviewers 👋 

I've been working on this branch with @mistic and @tylersmalley and
we're really confident in these changes. Additionally, this changes code
in nearly every package in the repo so we don't plan to wait for reviews
to get in before merging this. If you'd like to have a concern
addressed, please feel free to leave a review, but assuming that nobody
raises a blocker in the next 24 hours we plan to merge this EOD pacific
tomorrow, 12/22.

We'll be paying close attention to any issues this causes after merging
and work on getting those fixed ASAP. 🚀

---

The operations team is not confident that we'll have the time to achieve
what we originally set out to accomplish by moving to Bazel with the
time and resources we have available. We have also bought ourselves some
headroom with improvements to babel-register, optimizer caching, and
typescript project structure.

In order to make sure we deliver packages as quickly as possible (many
teams really want them), with a usable and familiar developer
experience, this PR removes Bazel for building packages in favor of
using the same JIT transpilation we use for plugins.

Additionally, packages now use `kbn_references` (again, just copying the
dx from plugins to packages).

Because of the complex relationships between packages/plugins and in
order to prepare ourselves for automatic dependency detection tools we
plan to use in the future, this PR also introduces a "TS Project Linter"
which will validate that every tsconfig.json file meets a few
requirements:

1. the chain of base config files extended by each config includes
`tsconfig.base.json` and not `tsconfig.json`
1. the `include` config is used, and not `files`
2. the `exclude` config includes `target/**/*`
3. the `outDir` compiler option is specified as `target/types`
1. none of these compiler options are specified: `declaration`,
`declarationMap`, `emitDeclarationOnly`, `skipLibCheck`, `target`,
`paths`

4. all references to other packages/plugins use their pkg id, ie:
	
	```js
    // valid
    {
      "kbn_references": ["@kbn/core"]
    }
    // not valid
    {
      "kbn_references": [{ "path": "../../../src/core/tsconfig.json" }]
    }
    ```

5. only packages/plugins which are imported somewhere in the ts code are
listed in `kbn_references`

This linter is not only validating all of the tsconfig.json files, but
it also will fix these config files to deal with just about any
violation that can be produced. Just run `node scripts/ts_project_linter
--fix` locally to apply these fixes, or let CI take care of
automatically fixing things and pushing the changes to your PR.

> **Example:** [`64e93e5`
(#146212)](64e93e5806)
When I merged main into my PR it included a change which removed the
`@kbn/core-injected-metadata-browser` package. After resolving the
conflicts I missed a few tsconfig files which included references to the
now removed package. The TS Project Linter identified that these
references were removed from the code and pushed a change to the PR to
remove them from the tsconfig.json files.

## No bazel? Does that mean no packages??
Nope! We're still doing packages but we're pretty sure now that we won't
be using Bazel to accomplish the 'distributed caching' and 'change-based
tasks' portions of the packages project.

This PR actually makes packages much easier to work with and will be
followed up with the bundling benefits described by the original
packages RFC. Then we'll work on documentation and advocacy for using
packages for any and all new code.

We're pretty confident that implementing distributed caching and
change-based tasks will be necessary in the future, but because of
recent improvements in the repo we think we can live without them for
**at least** a year.

## Wait, there are still BUILD.bazel files in the repo
Yes, there are still three webpack bundles which are built by Bazel: the
`@kbn/ui-shared-deps-npm` DLL, `@kbn/ui-shared-deps-src` externals, and
the `@kbn/monaco` workers. These three webpack bundles are still created
during bootstrap and remotely cached using bazel. The next phase of this
project is to figure out how to get the package bundling features
described in the RFC with the current optimizer, and we expect these
bundles to go away then. Until then any package that is used in those
three bundles still needs to have a BUILD.bazel file so that they can be
referenced by the remaining webpack builds.

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-12-22 19:00:29 -06:00
Tiago Costa
e41569b4a6
fix(NA): wrongly spread stripInternal and rootDir configs across packages (#144463)
* chore(NA): remove overrides for rootDir on packages

* chore(NA): replace './target_types' with 'target_types' on packages

* chore(NA): removes stripInternal false configs

* chore(NA): remove unused strip internals
2022-11-03 01:04:55 +00:00
spalger
52f2b33a07
[auto] migrate existing plugin/package configs 2022-10-28 14:06:46 -05:00
spalger
e5d186a6f0
[ts] stop building @types packages in bootstrap 2022-10-28 14:03:55 -05:00
Rudolf Meijering
441469262a
Add maxIdleSockets and idleSocketTimeout to Elasticsearch config (#142019)
* Add maxIdleSockets and idleSocketTimeout to Elasticsearch config

* Simplify agent manager

* Fix types

* Fix types

* Reduce idleSocketTimeout default to 60s

* Fix tests

* Update docs/setup/settings.asciidoc

* Address review comments

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-10-10 03:34:00 -07:00
Gerard Soldevila
25b79a9cdb
Collect metrics about the active/idle connections to ES nodes (#141434)
* Collect metrics about the connections from esClient to ES nodes

* Misc enhancements following PR remarks and comments

* Fix UTs

* Fix mock typings

* Minimize API surface, fix mocks typings

* Fix incomplete mocks

* Fix renameed agentManager => agentStore in remaining UT

* Cover edge cases for getAgentsSocketsStats()

* Misc NIT enhancements

* Revert incorrect import type statements
2022-10-04 17:43:41 +02:00
Seth Michael Larson
681e2b5c72
Add a default 'User-Agent' HTTP header 2022-09-23 08:24:04 -05:00
Pierre Gayvallet
f3a3243d00
Fix another static version snapshot in tests (#141345)
* Fix another static version snapshot in tests

* switch import order

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-09-23 00:19:27 -07:00
Gerard Soldevila
1186e35dbb
Fix default value for keepAliveMsecs, to be iso-functional with elastic-transport-js (#141234) 2022-09-21 17:04:41 +02:00
Gerard Soldevila
a77f8ff052
Create HTTP Agent manager (#137748)
* Create HTTP Agent factory

* Properly extract agent options

* Use independent Agent for preboot

* Create AgentManager to obtain factories

* Make client type mandatory, fix outdated mocks

* Temporarily force new Agent creation

* Revert changes in utils

* Add correct defaults for Agent Options, support proxy agent.

* Forgot to push package.json

* Add hpagent dependency in BUILD.bazel

* Get rid of hpagent (proxy param is not exposed in kibana.yml)

* Remove hpagent from BUILD.bazel

* Use different agents for normal Vs scoped client

* Fix Agent constructor params

* Fix incorrect access to err.message

* Use separate Agent for scoped client

* Create different agents for std vs scoped

* Provide different Agent instances if config differs

* Create a new Agent for each ES Client

* Restructure agent store. Add UTs

* Remove obsolete comment

* Simplify AgentManager store structure (no type needed)

* Fine tune client_config return type

* Misc enhancements following PR comments

* Fix missing param in cli_setup/utils
2022-09-14 11:00:06 +02:00
Pierre Gayvallet
12466d8b17
Migrate server-side status service to packages (#140067)
* create empty packages

* start moving things to packages

* move status types to common package

* create internal common package

* start adapting usages

* more import fixes

* fix more usages

* some test file fixes

* fix some more usages

* fix test_utils import

* fix mixed import

* fix test imports

* updating READMEs

* explicit export of service setup deps

* add jsonc files to new packages

* [CI] Auto-commit changed files from 'node scripts/generate codeowners'

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-09-09 00:22:12 -07:00
Spencer
32491462a9
add kibana.jsonc files to existing packages (#138965)
* [packages] add kibana.jsonc files

* auto-migrate to kibana.jsonc

* support interactive pkg id selection too

* remove old codeowners entry

* skip codeowners generation when .github/CODEOWNERS doesn't exist

* fall back to format validation if user is offline

* update question style

* [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-09-08 13:31:57 -07:00