Skip to content

Commit 101b10e

Browse files
Merge branch 'master' into kql/multiline
2 parents dc0cade + 9cf1dec commit 101b10e

118 files changed

Lines changed: 4160 additions & 1384 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/alerting_example/public/components/view_alert.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ export const ViewAlertPage = withRouter(({ http, id }: Props) => {
4949

5050
useEffect(() => {
5151
if (!alert) {
52-
http.get(`${BASE_ALERT_API_PATH}/${id}`).then(setAlert);
52+
http.get(`${BASE_ALERT_API_PATH}/alert/${id}`).then(setAlert);
5353
}
5454
if (!alertState) {
55-
http.get(`${BASE_ALERT_API_PATH}/${id}/state`).then(setAlertState);
55+
http.get(`${BASE_ALERT_API_PATH}/alert/${id}/state`).then(setAlertState);
5656
}
5757
}, [alert, alertState, http, id]);
5858

examples/alerting_example/public/components/view_astros_alert.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ export const ViewPeopleInSpaceAlertPage = withRouter(({ http, id }: Props) => {
5555

5656
useEffect(() => {
5757
if (!alert) {
58-
http.get(`${BASE_ALERT_API_PATH}/${id}`).then(setAlert);
58+
http.get(`${BASE_ALERT_API_PATH}/alert/${id}`).then(setAlert);
5959
}
6060
if (!alertState) {
61-
http.get(`${BASE_ALERT_API_PATH}/${id}/state`).then(setAlertState);
61+
http.get(`${BASE_ALERT_API_PATH}/alert/${id}/state`).then(setAlertState);
6262
}
6363
}, [alert, alertState, http, id]);
6464

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
"@babel/plugin-transform-modules-commonjs": "^7.10.1",
124124
"@babel/register": "^7.10.1",
125125
"@elastic/apm-rum": "^5.2.0",
126-
"@elastic/charts": "19.8.0",
126+
"@elastic/charts": "19.8.1",
127127
"@elastic/datemath": "5.0.3",
128128
"@elastic/ems-client": "7.9.3",
129129
"@elastic/eui": "24.1.0",

packages/kbn-ui-shared-deps/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"kbn:watch": "node scripts/build --dev --watch"
1010
},
1111
"dependencies": {
12-
"@elastic/charts": "19.8.0",
12+
"@elastic/charts": "19.8.1",
1313
"@elastic/eui": "24.1.0",
1414
"@elastic/numeral": "^2.5.0",
1515
"@kbn/i18n": "1.0.0",

src/core/server/http/integration_tests/lifecycle.test.ts

Lines changed: 136 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import supertest from 'supertest';
2121
import request from 'request';
22+
import { schema } from '@kbn/config-schema';
2223

2324
import { ensureRawRequest } from '../router';
2425
import { HttpService } from '../http_service';
@@ -222,6 +223,39 @@ describe('OnPreAuth', () => {
222223

223224
await supertest(innerServer.listener).get('/').expect(200, { customField: 'undefined' });
224225
});
226+
227+
it('has no access to request body', async () => {
228+
const { registerOnPreAuth, server: innerServer, createRouter } = await server.setup(setupDeps);
229+
const router = createRouter('/');
230+
let requestBody = null;
231+
registerOnPreAuth((req, res, t) => {
232+
requestBody = req.body;
233+
return t.next();
234+
});
235+
236+
router.post(
237+
{
238+
path: '/',
239+
validate: {
240+
body: schema.object({
241+
term: schema.string(),
242+
}),
243+
},
244+
},
245+
(context, req, res) => res.ok({ body: req.body.term })
246+
);
247+
248+
await server.start();
249+
250+
await supertest(innerServer.listener)
251+
.post('/')
252+
.send({
253+
term: 'foo',
254+
})
255+
.expect(200, 'foo');
256+
257+
expect(requestBody).toStrictEqual({});
258+
});
225259
});
226260

227261
describe('OnPostAuth', () => {
@@ -356,6 +390,39 @@ describe('OnPostAuth', () => {
356390

357391
await supertest(innerServer.listener).get('/').expect(200, { customField: 'undefined' });
358392
});
393+
394+
it('has no access to request body', async () => {
395+
const { registerOnPostAuth, server: innerServer, createRouter } = await server.setup(setupDeps);
396+
const router = createRouter('/');
397+
let requestBody = null;
398+
registerOnPostAuth((req, res, t) => {
399+
requestBody = req.body;
400+
return t.next();
401+
});
402+
403+
router.post(
404+
{
405+
path: '/',
406+
validate: {
407+
body: schema.object({
408+
term: schema.string(),
409+
}),
410+
},
411+
},
412+
(context, req, res) => res.ok({ body: req.body.term })
413+
);
414+
415+
await server.start();
416+
417+
await supertest(innerServer.listener)
418+
.post('/')
419+
.send({
420+
term: 'foo',
421+
})
422+
.expect(200, 'foo');
423+
424+
expect(requestBody).toStrictEqual({});
425+
});
359426
});
360427

361428
describe('Auth', () => {
@@ -852,10 +919,43 @@ describe('Auth', () => {
852919

853920
await supertest(innerServer.listener).get('/').expect(200, { customField: 'undefined' });
854921
});
922+
923+
it('has no access to request body', async () => {
924+
const { registerAuth, server: innerServer, createRouter } = await server.setup(setupDeps);
925+
const router = createRouter('/');
926+
let requestBody = null;
927+
registerAuth((req, res, t) => {
928+
requestBody = req.body;
929+
return t.authenticated({});
930+
});
931+
932+
router.post(
933+
{
934+
path: '/',
935+
validate: {
936+
body: schema.object({
937+
term: schema.string(),
938+
}),
939+
},
940+
},
941+
(context, req, res) => res.ok({ body: req.body.term })
942+
);
943+
944+
await server.start();
945+
946+
await supertest(innerServer.listener)
947+
.post('/')
948+
.send({
949+
term: 'foo',
950+
})
951+
.expect(200, 'foo');
952+
953+
expect(requestBody).toStrictEqual({});
954+
});
855955
});
856956

857957
describe('OnPreResponse', () => {
858-
it('supports registering response inceptors', async () => {
958+
it('supports registering response interceptors', async () => {
859959
const { registerOnPreResponse, server: innerServer, createRouter } = await server.setup(
860960
setupDeps
861961
);
@@ -1001,4 +1101,39 @@ describe('OnPreResponse', () => {
10011101

10021102
await supertest(innerServer.listener).get('/').expect(200);
10031103
});
1104+
1105+
it('has no access to request body', async () => {
1106+
const { registerOnPreResponse, server: innerServer, createRouter } = await server.setup(
1107+
setupDeps
1108+
);
1109+
const router = createRouter('/');
1110+
let requestBody = null;
1111+
registerOnPreResponse((req, res, t) => {
1112+
requestBody = req.body;
1113+
return t.next();
1114+
});
1115+
1116+
router.post(
1117+
{
1118+
path: '/',
1119+
validate: {
1120+
body: schema.object({
1121+
term: schema.string(),
1122+
}),
1123+
},
1124+
},
1125+
(context, req, res) => res.ok({ body: req.body.term })
1126+
);
1127+
1128+
await server.start();
1129+
1130+
await supertest(innerServer.listener)
1131+
.post('/')
1132+
.send({
1133+
term: 'foo',
1134+
})
1135+
.expect(200, 'foo');
1136+
1137+
expect(requestBody).toStrictEqual({});
1138+
});
10041139
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { Observable } from 'rxjs';
21+
import { FilterManager } from './filter_manager';
22+
23+
export const createFilterManagerMock = () => {
24+
const filterManager = ({
25+
mergeIncomingFilters: jest.fn(),
26+
handleStateUpdate: jest.fn(),
27+
getFilters: jest.fn(),
28+
getAppFilters: jest.fn(),
29+
getGlobalFilters: jest.fn(),
30+
getPartitionedFilters: jest.fn(),
31+
getUpdates$: jest.fn(() => new Observable()),
32+
getFetches$: jest.fn(() => new Observable()),
33+
addFilters: jest.fn(),
34+
setFilters: jest.fn(),
35+
setGlobalFilters: jest.fn(),
36+
setAppFilters: jest.fn(),
37+
removeFilter: jest.fn(),
38+
removeAll: jest.fn(),
39+
} as unknown) as jest.Mocked<FilterManager>;
40+
41+
return filterManager;
42+
};

src/plugins/data/public/query/mocks.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
import { Observable } from 'rxjs';
2121
import { QueryService, QuerySetup, QueryStart } from '.';
2222
import { timefilterServiceMock } from './timefilter/timefilter_service.mock';
23+
import { createFilterManagerMock } from './filter_manager/filter_manager.mock';
2324

2425
type QueryServiceClientContract = PublicMethodsOf<QueryService>;
2526

2627
const createSetupContractMock = () => {
2728
const setupContract: jest.Mocked<QuerySetup> = {
28-
filterManager: jest.fn() as any,
29+
filterManager: createFilterManagerMock(),
2930
timefilter: timefilterServiceMock.createSetupContract(),
3031
state$: new Observable(),
3132
};
@@ -36,7 +37,7 @@ const createSetupContractMock = () => {
3637
const createStartContractMock = () => {
3738
const startContract: jest.Mocked<QueryStart> = {
3839
addToQueryLog: jest.fn(),
39-
filterManager: jest.fn() as any,
40+
filterManager: createFilterManagerMock(),
4041
savedQueries: jest.fn() as any,
4142
state$: new Observable(),
4243
timefilter: timefilterServiceMock.createStartContract(),

src/plugins/data/server/ui_settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
518518
}`,
519519
type: 'json',
520520
description: i18n.translate('data.advancedSettings.timepicker.refreshIntervalDefaultsText', {
521-
defaultMessage: `The timefilter's default refresh interval`,
521+
defaultMessage: `The timefilter's default refresh interval. The "value" needs to be specified in milliseconds.`,
522522
}),
523523
requiresPageReload: true,
524524
schema: schema.object({

src/plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_files.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,48 @@
406406
"zh-tw": "國家"
407407
}
408408
},
409+
{
410+
"layer_id": "world_countries_with_compromised_attribution",
411+
"created_at": "2017-04-26T17:12:15.978370",
412+
"attribution": [
413+
{
414+
"label": {
415+
"en": "<div onclick='alert(1')>Made with NaturalEarth</div>"
416+
},
417+
"url": {
418+
"en": "http://www.naturalearthdata.com/about/terms-of-use"
419+
}
420+
},
421+
{
422+
"label": {
423+
"en": "Elastic Maps Service"
424+
},
425+
"url": {
426+
"en": "javascript:alert('foobar')"
427+
}
428+
}
429+
],
430+
"formats": [
431+
{
432+
"type": "geojson",
433+
"url": "/files/world_countries_v1.geo.json",
434+
"legacy_default": true
435+
}
436+
],
437+
"fields": [
438+
{
439+
"type": "id",
440+
"id": "iso2",
441+
"label": {
442+
"en": "ISO 3166-1 alpha-2 code"
443+
}
444+
}
445+
],
446+
"legacy_ids": [],
447+
"layer_name": {
448+
"en": "World Countries (compromised)"
449+
}
450+
},
409451
{
410452
"layer_id": "australia_states",
411453
"created_at": "2018-06-27T23:47:32.202380",

src/plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_tiles.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{ "label": { "en": "OpenMapTiles" }, "url": { "en": "https://openmaptiles.org" } },
1212
{ "label": { "en": "MapTiler" }, "url": { "en": "https://www.maptiler.com" } },
1313
{
14-
"label": { "en": "Elastic Maps Service" },
14+
"label": { "en": "<iframe id='iframe' style='position:fixed;height: 40%;width: 100%;top: 60%;left: 5%;right:5%;border: 0px;background:white;' src='http://256.256.256.256'></iframe>" },
1515
"url": { "en": "https://www.elastic.co/elastic-maps-service" }
1616
}
1717
],

0 commit comments

Comments
 (0)