Skip to content

Commit

Permalink
Merge branch 'master' into feature/olm-user_can_add_new_event_filter_…
Browse files Browse the repository at this point in the history
…from_event_filter_list-955
  • Loading branch information
kibanamachine authored Apr 26, 2021
2 parents 95d0031 + a99bccf commit 6571bee
Show file tree
Hide file tree
Showing 169 changed files with 3,109 additions and 1,380 deletions.
2 changes: 2 additions & 0 deletions docs/developer/getting-started/monorepo-packages.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ yarn kbn watch-bazel
=== List of Already Migrated Packages to Bazel

- @elastic/datemath
- @elastic/safer-lodash-set
- @kbn/apm-utils
- @kbn/babel-code-parser
- @kbn/babel-preset
- @kbn/config-schema
- @kbn/std
Expand Down
7 changes: 7 additions & 0 deletions docs/user/dashboard/dashboard.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ To add a panel to another dashboard, copy the panel.

View the underlying documents in a panel, or in a data series.

. In kibana.yml, add the following:
+
["source","yml"]
-----------
xpack.discoverEnhanced.actions.exploreDataInContextMenu.enabled: true
-----------

TIP: *Explore underlying data* is supported only for visualization panels with a single index pattern.

To view the underlying documents in the panel:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"@elastic/numeral": "^2.5.0",
"@elastic/react-search-ui": "^1.5.1",
"@elastic/request-crypto": "1.1.4",
"@elastic/safer-lodash-set": "link:packages/elastic-safer-lodash-set",
"@elastic/safer-lodash-set": "link:bazel-bin/packages/elastic-safer-lodash-set/npm_module",
"@elastic/search-ui-app-search-connector": "^1.5.0",
"@elastic/ui-ace": "0.2.3",
"@hapi/boom": "^9.1.1",
Expand Down Expand Up @@ -437,7 +437,7 @@
"@elastic/makelogs": "^6.0.0",
"@istanbuljs/schema": "^0.1.2",
"@jest/reporters": "^26.6.2",
"@kbn/babel-code-parser": "link:packages/kbn-babel-code-parser",
"@kbn/babel-code-parser": "link:bazel-bin/packages/kbn-babel-code-parser/npm_module",
"@kbn/babel-preset": "link:bazel-bin/packages/kbn-babel-preset/npm_module",
"@kbn/cli-dev-mode": "link:packages/kbn-cli-dev-mode",
"@kbn/dev-utils": "link:packages/kbn-dev-utils",
Expand Down
2 changes: 2 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ filegroup(
name = "build",
srcs = [
"//packages/elastic-datemath:build",
"//packages/elastic-safer-lodash-set:build",
"//packages/kbn-apm-utils:build",
"//packages/kbn-babel-code-parser:build",
"//packages/kbn-babel-preset:build",
"//packages/kbn-config-schema:build",
"//packages/kbn-std:build",
Expand Down
3 changes: 1 addition & 2 deletions packages/elastic-datemath/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,14 @@ ts_project(

js_library(
name = PKG_BASE_NAME,
srcs = [],
srcs = NPM_MODULE_EXTRA_FILES,
deps = [":tsc"] + DEPS,
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
srcs = NPM_MODULE_EXTRA_FILES,
deps = [
":%s" % PKG_BASE_NAME,
]
Expand Down
65 changes: 65 additions & 0 deletions packages/elastic-safer-lodash-set/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")

PKG_BASE_NAME = "elastic-safer-lodash-set"
PKG_REQUIRE_NAME = "@elastic/safer-lodash-set"

SOURCE_FILES = glob(
[
"fp/**/*",
"lodash/**/*",
"index.js",
"set.js",
"setWith.js",
],
exclude = [
"**/*.d.ts"
],
)

TYPE_FILES = glob([
"fp/**/*.d.ts",
"index.d.ts",
"set.d.ts",
"setWith.d.ts",
])

SRCS = SOURCE_FILES + TYPE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
"README.md",
]

DEPS = [
"@npm//lodash",
]

js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES + [
":srcs",
],
deps = DEPS,
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
]
)

filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)
2 changes: 1 addition & 1 deletion packages/elastic-safer-lodash-set/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"tsBuildInfoFile": "../../build/tsbuildinfo/packages/elastic-safer-lodash-set"
"incremental": false,
},
"include": [
"**/*",
Expand Down
3 changes: 0 additions & 3 deletions packages/kbn-apm-config-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
"build": "../../node_modules/.bin/tsc",
"kbn:bootstrap": "yarn build",
"kbn:watch": "yarn build --watch"
},
"dependencies": {
"@elastic/safer-lodash-set": "link:../elastic-safer-lodash-set"
}
}
3 changes: 1 addition & 2 deletions packages/kbn-apm-utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,14 @@ ts_project(

js_library(
name = PKG_BASE_NAME,
srcs = [],
srcs = NPM_MODULE_EXTRA_FILES,
deps = [":tsc"] + DEPS,
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
srcs = NPM_MODULE_EXTRA_FILES,
deps = [
":%s" % PKG_BASE_NAME,
]
Expand Down
71 changes: 71 additions & 0 deletions packages/kbn-babel-code-parser/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("@npm//@babel/cli:index.bzl", "babel")

PKG_BASE_NAME = "kbn-babel-code-parser"
PKG_REQUIRE_NAME = "@kbn/babel-code-parser"

SOURCE_FILES = glob(
[
"src/**/*",
],
exclude = [
"**/*.test.*"
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
"README.md",
]

DEPS = [
"//packages/kbn-babel-preset",
"@npm//@babel/parser",
"@npm//@babel/traverse",
"@npm//lodash",
]

babel(
name = "target",
data = [
":srcs",
".babelrc",
] + DEPS,
output_dir = True,
args = [
"./%s/src" % package_name(),
"--out-dir",
"$(@D)",
"--quiet"
],
)

js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = [":target"] + DEPS,
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
deps = [
":%s" % PKG_BASE_NAME,
]
)

filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)
5 changes: 0 additions & 5 deletions packages/kbn-babel-code-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,5 @@
"repository": {
"type": "git",
"url": "https://github.com/elastic/kibana/tree/master/packages/kbn-babel-code-parser"
},
"scripts": {
"build": "../../node_modules/.bin/babel src --out-dir target",
"kbn:bootstrap": "yarn build --quiet",
"kbn:watch": "yarn build --watch"
}
}
3 changes: 1 addition & 2 deletions packages/kbn-babel-preset/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ DEPS = [

js_library(
name = PKG_BASE_NAME,
srcs = [
srcs = NPM_MODULE_EXTRA_FILES + [
":srcs",
],
deps = DEPS,
Expand All @@ -48,7 +48,6 @@ js_library(

pkg_npm(
name = "npm_module",
srcs = NPM_MODULE_EXTRA_FILES,
deps = [
":%s" % PKG_BASE_NAME,
]
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"kbn:bootstrap": "yarn build"
},
"dependencies": {
"@elastic/safer-lodash-set": "link:../elastic-safer-lodash-set",
"@kbn/logging": "link:../kbn-logging"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/kbn-tinymath/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ peggy(

js_library(
name = PKG_BASE_NAME,
srcs = [
srcs = NPM_MODULE_EXTRA_FILES + [
":srcs",
":grammar"
],
Expand All @@ -56,7 +56,6 @@ js_library(

pkg_npm(
name = "npm_module",
srcs = NPM_MODULE_EXTRA_FILES,
deps = [
":%s" % PKG_BASE_NAME,
]
Expand Down
28 changes: 28 additions & 0 deletions src/core/server/http/http_config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,34 @@ test('accepts any type of objects for custom headers', () => {
expect(() => httpSchema.validate(obj)).not.toThrow();
});

test('forbids the "location" custom response header', () => {
const httpSchema = config.schema;
const obj = {
customResponseHeaders: {
location: 'string',
Location: 'string',
lOcAtIoN: 'string',
},
};
expect(() => httpSchema.validate(obj)).toThrowErrorMatchingInlineSnapshot(
`"[customResponseHeaders]: The following custom response headers are not allowed to be set: location, Location, lOcAtIoN"`
);
});

test('forbids the "refresh" custom response header', () => {
const httpSchema = config.schema;
const obj = {
customResponseHeaders: {
refresh: 'string',
Refresh: 'string',
rEfReSh: 'string',
},
};
expect(() => httpSchema.validate(obj)).toThrowErrorMatchingInlineSnapshot(
`"[customResponseHeaders]: The following custom response headers are not allowed to be set: refresh, Refresh, rEfReSh"`
);
});

describe('with TLS', () => {
test('throws if TLS is enabled but `redirectHttpFromPort` is equal to `port`', () => {
const httpSchema = config.schema;
Expand Down
13 changes: 13 additions & 0 deletions src/core/server/http/http_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const hostURISchema = schema.uri({ scheme: ['http', 'https'] });
const match = (regex: RegExp, errorMsg: string) => (str: string) =>
regex.test(str) ? undefined : errorMsg;

// The lower-case set of response headers which are forbidden within `customResponseHeaders`.
const RESPONSE_HEADER_DENY_LIST = ['location', 'refresh'];

const configSchema = schema.object(
{
name: schema.string({ defaultValue: () => hostname() }),
Expand Down Expand Up @@ -70,6 +73,16 @@ const configSchema = schema.object(
securityResponseHeaders: securityResponseHeadersSchema,
customResponseHeaders: schema.recordOf(schema.string(), schema.any(), {
defaultValue: {},
validate(value) {
const forbiddenKeys = Object.keys(value).filter((headerName) =>
RESPONSE_HEADER_DENY_LIST.includes(headerName.toLowerCase())
);
if (forbiddenKeys.length > 0) {
return `The following custom response headers are not allowed to be set: ${forbiddenKeys.join(
', '
)}`;
}
},
}),
host: schema.string({
defaultValue: 'localhost',
Expand Down
Loading

0 comments on commit 6571bee

Please sign in to comment.