kibana/packages
Thomas Watson 723a55ec12
[8.5] Add CSP header to all requests, including api requests (#144902) (#145552)
# Backport

This will backport the following commits from `main` to `8.5`:
- [Add CSP header to all requests, including api requests
(#144902)](https://github.com/elastic/kibana/pull/144902)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Thomas
Watson","email":"watson@elastic.co"},"sourceCommit":{"committedDate":"2022-11-16T20:45:10Z","message":"Add
CSP header to all requests, including api requests
(#144902)\n\nPreviously `/api/*` requests didn't include a
`Content-Security-Policy`\r\nheader, now they do.\r\n\r\nCloses
#143871","sha":"5550ab6cb10fbfddf437a74900103bb33dd1afa4","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","backport:all-open","v8.6.0","v8.7.0"],"number":144902,"url":"https://github.com/elastic/kibana/pull/144902","mergeCommit":{"message":"Add
CSP header to all requests, including api requests
(#144902)\n\nPreviously `/api/*` requests didn't include a
`Content-Security-Policy`\r\nheader, now they do.\r\n\r\nCloses
#143871","sha":"5550ab6cb10fbfddf437a74900103bb33dd1afa4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/145449","number":145449,"state":"MERGED","mergeCommit":{"sha":"a9f7ba61f128e61beb936d2caff143e93e3321ea","message":"[8.6]
Add CSP header to all requests, including api requests (#144902)
(#145449)\n\n# Backport\n\nThis will backport the following commits from
`main` to `8.6`:\n- [Add CSP header to all requests, including api
requests\n(#144902)](https://github.com/elastic/kibana/pull/144902)\n\n<!---
Backport version: 8.9.7 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Thomas\nWatson\",\"email\":\"watson@elastic.co\"},\"sourceCommit\":{\"committedDate\":\"2022-11-16T20:45:10Z\",\"message\":\"Add\nCSP
header to all requests, including api
requests\n(#144902)\\n\\nPreviously `/api/*` requests didn't include
a\n`Content-Security-Policy`\\r\\nheader, now they
do.\\r\\n\\r\\nCloses\n#143871\",\"sha\":\"5550ab6cb10fbfddf437a74900103bb33dd1afa4\",\"branchLabelMapping\":{\"^v8.7.0$\":\"main\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"release_note:enhancement\",\"backport:all-open\",\"v8.7.0\"],\"number\":144902,\"url\":\"https://github.com/elastic/kibana/pull/144902\",\"mergeCommit\":{\"message\":\"Add\nCSP
header to all requests, including api
requests\n(#144902)\\n\\nPreviously `/api/*` requests didn't include
a\n`Content-Security-Policy`\\r\\nheader, now they
do.\\r\\n\\r\\nCloses\n#143871\",\"sha\":\"5550ab6cb10fbfddf437a74900103bb33dd1afa4\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v8.7.0\",\"labelRegex\":\"^v8.7.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/144902\",\"number\":144902,\"mergeCommit\":{\"message\":\"Add\nCSP
header to all requests, including api
requests\n(#144902)\\n\\nPreviously `/api/*` requests didn't include
a\n`Content-Security-Policy`\\r\\nheader, now they
do.\\r\\n\\r\\nCloses\n#143871\",\"sha\":\"5550ab6cb10fbfddf437a74900103bb33dd1afa4\"}}]}]\nBACKPORT-->\n\nCo-authored-by:
Thomas Watson
<watson@elastic.co>"}},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/144902","number":144902,"mergeCommit":{"message":"Add
CSP header to all requests, including api requests
(#144902)\n\nPreviously `/api/*` requests didn't include a
`Content-Security-Policy`\r\nheader, now they do.\r\n\r\nCloses
#143871","sha":"5550ab6cb10fbfddf437a74900103bb33dd1afa4"}}]}]
BACKPORT-->
2022-11-17 06:21:35 -07:00
..
analytics add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
content-management [TableListView] Group title description and tags (#140947) (#141618) 2022-09-23 06:26:43 -07:00
core [8.5] Add CSP header to all requests, including api requests (#144902) (#145552) 2022-11-17 06:21:35 -07:00
home add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-ace add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-alerts add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-ambient-storybook-types add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-ambient-ui-types add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-analytics Remove dependencies for empty @types/* packages (#144324) (#144686) 2022-11-07 05:55:56 -07:00
kbn-apm-config-loader [pkgs/manifest] allow owner to be an array of users/teams (#140740) 2022-09-14 09:39:01 -07:00
kbn-apm-synthtrace [APM] Synthtrace: Add distributed trace helper (#142593) (#143158) 2022-10-12 01:15:35 -07:00
kbn-apm-utils add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-axe-config add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-babel-plugin-synthetic-packages add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-babel-preset Update dependency core-js to ^3.25.1 (main) (#140776) 2022-09-16 07:28:22 +09:30
kbn-bazel-packages [Table list view] Improve UX (phase 1) (#135892) 2022-09-19 12:29:23 +02:00
kbn-bazel-runner add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-chart-icons add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-ci-stats-core add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-ci-stats-performance-metrics add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-ci-stats-reporter add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-cli-dev-mode add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-coloring add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-config add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-config-mocks Fix another static version snapshot in tests (#141345) (#141568) 2022-09-23 01:22:19 -07:00
kbn-config-schema Remove dependencies for empty @types/* packages (#144324) (#144686) 2022-11-07 05:55:56 -07:00
kbn-crypto add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-crypto-browser add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-datemath add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-dev-cli-errors add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-dev-cli-runner add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-dev-proc-runner [ftr] support redirecting server logs to a file (#140334) 2022-09-09 10:44:00 -07:00
kbn-dev-utils add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-doc-links [8.5] [Enterprise Search] Remove unused crawlerGettingStarted doclink (#143690) (#143737) 2022-10-20 15:31:37 +02:00
kbn-docs-utils add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-ebt-tools add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-es [ftr] support redirecting server logs to a file (#140334) 2022-09-09 10:44:00 -07:00
kbn-es-archiver add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-es-errors add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-es-query Remove dependencies for empty @types/* packages (#144324) (#144686) 2022-11-07 05:55:56 -07:00
kbn-es-types Move src/core/types/elasticsearch to @kbn/es-types (#140522) 2022-09-20 10:32:13 +02:00
kbn-eslint-config add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-eslint-plugin-disable add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-eslint-plugin-eslint add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-eslint-plugin-imports add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-expect add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-field-types add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-find-used-node-modules add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-flot-charts add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-generate [pkgs/manifest] allow owner to be an array of users/teams (#140740) 2022-09-14 09:39:01 -07:00
kbn-get-repo-files add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-handlebars add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-hapi-mocks add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-i18n add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-i18n-react add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-import-resolver add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-interpreter add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-io-ts-utils add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-jest-serializers add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-kibana-manifest-schema [pkgs/manifest] allow owner to be an array of users/teams (#140740) 2022-09-14 09:39:01 -07:00
kbn-logging add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-logging-mocks add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-managed-vscode-config add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-managed-vscode-config-cli add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-mapbox-gl add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-monaco add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-optimizer [8.5] Upgrade loader-utils dependency (1.1.32.0.3). (#144879) (#144917) 2022-11-09 11:17:53 -07:00
kbn-optimizer-webpack-helpers add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-osquery-io-ts-types [8.5] [Osquery] Response Actions fixes (#141041) (#141742) 2022-09-26 03:24:07 -07:00
kbn-performance-testing-dataset-extractor add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-plugin-discovery add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-plugin-generator add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-plugin-helpers add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-react-field add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-repo-source-classifier add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-repo-source-classifier-cli add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-rule-data-utils add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-safer-lodash-set add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-securitysolution-autocomplete [Security Solution] Updates value list exceptions doc link (#142909) (#143240) 2022-10-12 15:29:23 -07:00
kbn-securitysolution-es-utils add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-securitysolution-hook-utils add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-securitysolution-io-ts-alerting-types [Security Solution] Don't mute rules when bulk editing rule actions (#140626) (#141977) 2022-09-27 10:49:53 -07:00
kbn-securitysolution-io-ts-list-types [Security Solution] Value list exceptions (#133254) 2022-09-19 22:41:28 +02:00
kbn-securitysolution-io-ts-types [Security Solution] Don't mute rules when bulk editing rule actions (#140626) (#141977) 2022-09-27 10:49:53 -07:00
kbn-securitysolution-io-ts-utils add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-securitysolution-list-api [Security Solution] Value list exceptions (#133254) 2022-09-19 22:41:28 +02:00
kbn-securitysolution-list-constants [Security Solution] Value list exceptions (#133254) 2022-09-19 22:41:28 +02:00
kbn-securitysolution-list-hooks [Security Solution] Value list exceptions (#133254) 2022-09-19 22:41:28 +02:00
kbn-securitysolution-list-utils [Security Solution] Value list exceptions (#133254) 2022-09-19 22:41:28 +02:00
kbn-securitysolution-rules add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-securitysolution-t-grid add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-securitysolution-utils add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-server-http-tools Remove dependencies for empty @types/* packages (#144324) (#144686) 2022-11-07 05:55:56 -07:00
kbn-server-route-repository add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-shared-svg add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-shared-ux-utility add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-some-dev-log add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-sort-package-json add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-spec-to-console add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-std add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-stdio-dev-helpers add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-storybook Migrate client-side coreApp domain to packages - again (#140662) 2022-09-13 15:29:08 -07:00
kbn-synthetic-package-map add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-telemetry-tools [UsageCollection] Allow pass_through on Record<string, unknown> types (#144571) (#144587) 2022-11-04 02:35:38 -07:00
kbn-test Remove dependencies for empty @types/* packages (#144324) (#144686) 2022-11-07 05:55:56 -07:00
kbn-test-jest-helpers Remove dependencies for empty @types/* packages (#144324) (#144686) 2022-11-07 05:55:56 -07:00
kbn-test-subj-selector modernize test-subj-selector (#140847) 2022-09-15 22:08:51 -07:00
kbn-timelion-grammar add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-tinymath add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-tooling-log add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-type-summarizer add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-type-summarizer-cli add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-type-summarizer-core add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-typed-react-router-config [Profiling] Add Profiling application (#140722) 2022-09-15 19:24:41 +02:00
kbn-ui-framework add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-ui-shared-deps-npm add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-ui-shared-deps-src add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-ui-theme add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-user-profile-components Add no assignees option to user profiles selectable (#140036) 2022-09-14 16:52:34 +01:00
kbn-utility-types add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-utility-types-jest add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-utils add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
kbn-yarn-lock-validator add kibana.jsonc files to existing packages (#138965) 2022-09-08 13:31:57 -07:00
shared-ux Bumping EUI to version 64.0.4 (#140323) 2022-09-20 08:50:15 -05:00
BUILD.bazel [8.5] [Osquery] Response Actions fixes (#141041) (#141742) 2022-09-26 03:24:07 -07:00
README.md [kbn/pm] rewrite to avoid needing a build process (#136207) 2022-07-18 08:46:13 -07:00

Kibana-related packages

This folder contains packages that are intended for use in Kibana and Kibana plugins.

tl;dr:

  • Don't publish to npm registry
  • Always use the @kbn namespace
  • Always set "private": true in package.json

Using these packages

We no longer publish these packages to the npm registry. Now, instead of specifying a version when including these packages, we rely on yarn workspaces, which sets up a symlink to the package.

For example if you want to use the @kbn/i18n package in Kibana itself, you can specify the dependency like this:

"@kbn/i18n": "1.0.0"

However, if you want to use this from a Kibana plugin, you need to use a link: dependency and account for the relative location of the Kibana repo, so it would instead be:

"@kbn/i18n": "link:../../kibana/packages/kbn-i18n"

Creating a new package

Create a new sub-folder. The name of the folder should mirror the name in the package's package.json. E.g. if the name is @kbn/i18n the folder name should be kbn-i18n.

All new packages should use the @kbn namespace, and should be marked with "private": true.

Unit tests for a package

Currently there is only one tool being used in order to test packages which is Jest. Below we will explain how it should be done.

Jest

A package should follow the pattern of having .test.js files as siblings of the source code files, and these run by Jest.

A package using the .test.js naming convention will have those tests automatically picked up by Jest and run by the unit test runner, currently mapped to the Kibana test script in the root package.json.

  • yarn test runs all unit tests.
  • yarn jest runs all Jest tests in Kibana.

In order for the plugin or package to use Jest, a jest.config.js file must be present in it's root. However, there are safeguards for this in CI should a test file be added without a corresponding config file.


Each package can also specify its own test script in the package's package.json, for cases where you'd prefer to run the tests from the local package directory.