Skip to content

Commit 7ab9f52

Browse files
committed
Merge branch 'master' of github.com:elastic/kibana into implement/kbn-optimizer
2 parents 654ad79 + 3d338c1 commit 7ab9f52

16 files changed

Lines changed: 304 additions & 17 deletions

File tree

packages/kbn-babel-preset/node_preset.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ module.exports = (_, options = {}) => {
5454
// on their own
5555
useBuiltIns: 'entry',
5656
modules: 'cjs',
57-
corejs: 3,
57+
// right now when using `corejs: 3` babel does not use the latest available
58+
// core-js version due to a bug: https://github.com/babel/babel/issues/10816
59+
// Because of that we should use for that value the same version we install
60+
// in the package.json in order to have the same polyfills between the environment
61+
// and the tests
62+
corejs: '3.2.1',
5863

5964
...(options['@babel/preset-env'] || {}),
6065
},

packages/kbn-babel-preset/webpack_preset.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ module.exports = () => {
2525
{
2626
useBuiltIns: 'entry',
2727
modules: false,
28-
corejs: 3,
28+
// Please read the explanation for this
29+
// in node_preset.js
30+
corejs: '3.2.1',
2931
},
3032
],
3133
require('./common_preset'),

src/plugins/console/server/lib/spec_definitions/es_6_0/mappings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export default function(api) {
9696
doc_values: BOOLEAN,
9797
eager_global_ordinals: BOOLEAN,
9898
norms: BOOLEAN,
99+
coerce: BOOLEAN,
99100

100101
// Not actually available in V6 of ES. Add when updating the autocompletion system.
101102
// index_phrases: BOOLEAN,

x-pack/legacy/plugins/alerting/server/plugin.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,34 @@ import { licensingMock } from '../../../../plugins/licensing/server/mocks';
1010
import { encryptedSavedObjectsMock } from '../../../../plugins/encrypted_saved_objects/server/mocks';
1111

1212
describe('Alerting Plugin', () => {
13+
describe('setup()', () => {
14+
it('should log warning when Encrypted Saved Objects plugin is using an ephemeral encryption key', async () => {
15+
const context = coreMock.createPluginInitializerContext();
16+
const plugin = new Plugin(context);
17+
18+
const coreSetup = coreMock.createSetup();
19+
const encryptedSavedObjectsSetup = encryptedSavedObjectsMock.createSetup();
20+
await plugin.setup(
21+
{
22+
...coreSetup,
23+
http: {
24+
...coreSetup.http,
25+
route: jest.fn(),
26+
},
27+
} as any,
28+
{
29+
licensing: licensingMock.createSetup(),
30+
encryptedSavedObjects: encryptedSavedObjectsSetup,
31+
} as any
32+
);
33+
34+
expect(encryptedSavedObjectsSetup.usingEphemeralEncryptionKey).toEqual(true);
35+
expect(context.logger.get().warn).toHaveBeenCalledWith(
36+
'APIs are disabled due to the Encrypted Saved Objects plugin using an ephemeral encryption key. Please set xpack.encryptedSavedObjects.encryptionKey in kibana.yml.'
37+
);
38+
});
39+
});
40+
1341
describe('start()', () => {
1442
/**
1543
* HACK: This test has put together to ensuire the function "getAlertsClientWithRequest"

x-pack/legacy/plugins/alerting/server/plugin.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ export class Plugin {
6969
this.isESOUsingEphemeralEncryptionKey =
7070
plugins.encryptedSavedObjects.usingEphemeralEncryptionKey;
7171

72+
if (this.isESOUsingEphemeralEncryptionKey) {
73+
this.logger.warn(
74+
'APIs are disabled due to the Encrypted Saved Objects plugin using an ephemeral encryption key. Please set xpack.encryptedSavedObjects.encryptionKey in kibana.yml.'
75+
);
76+
}
77+
7278
// Encrypted attributes
7379
plugins.encryptedSavedObjects.registerType({
7480
type: 'alert',

x-pack/plugins/actions/server/action_type_registry.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import { configUtilsMock } from './actions_config.mock';
1313
const mockTaskManager = taskManagerMock.setup();
1414
const actionTypeRegistryParams = {
1515
taskManager: mockTaskManager,
16-
taskRunnerFactory: new TaskRunnerFactory(new ActionExecutor()),
16+
taskRunnerFactory: new TaskRunnerFactory(
17+
new ActionExecutor({ isESOUsingEphemeralEncryptionKey: false })
18+
),
1719
actionsConfigUtils: configUtilsMock,
1820
};
1921

x-pack/plugins/actions/server/actions_client.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ const mockTaskManager = taskManagerMock.setup();
2727

2828
const actionTypeRegistryParams = {
2929
taskManager: mockTaskManager,
30-
taskRunnerFactory: new TaskRunnerFactory(new ActionExecutor()),
30+
taskRunnerFactory: new TaskRunnerFactory(
31+
new ActionExecutor({ isESOUsingEphemeralEncryptionKey: false })
32+
),
3133
actionsConfigUtils: configUtilsMock,
3234
};
3335

@@ -204,7 +206,9 @@ describe('create()', () => {
204206

205207
const localActionTypeRegistryParams = {
206208
taskManager: mockTaskManager,
207-
taskRunnerFactory: new TaskRunnerFactory(new ActionExecutor()),
209+
taskRunnerFactory: new TaskRunnerFactory(
210+
new ActionExecutor({ isESOUsingEphemeralEncryptionKey: false })
211+
),
208212
actionsConfigUtils: localConfigUtils,
209213
};
210214

x-pack/plugins/actions/server/builtin_action_types/index.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ export function createActionTypeRegistry(): {
2121
const logger = loggingServiceMock.create().get() as jest.Mocked<Logger>;
2222
const actionTypeRegistry = new ActionTypeRegistry({
2323
taskManager: taskManagerMock.setup(),
24-
taskRunnerFactory: new TaskRunnerFactory(new ActionExecutor()),
24+
taskRunnerFactory: new TaskRunnerFactory(
25+
new ActionExecutor({ isESOUsingEphemeralEncryptionKey: false })
26+
),
2527
actionsConfigUtils: configUtilsMock,
2628
});
2729
registerBuiltInActionTypes({

x-pack/plugins/actions/server/create_execute_function.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('execute()', () => {
2020
getBasePath,
2121
taskManager: mockTaskManager,
2222
getScopedSavedObjectsClient: jest.fn().mockReturnValueOnce(savedObjectsClient),
23+
isESOUsingEphemeralEncryptionKey: false,
2324
});
2425
savedObjectsClient.get.mockResolvedValueOnce({
2526
id: '123',
@@ -71,6 +72,7 @@ describe('execute()', () => {
7172
getBasePath,
7273
taskManager: mockTaskManager,
7374
getScopedSavedObjectsClient,
75+
isESOUsingEphemeralEncryptionKey: false,
7476
});
7577
savedObjectsClient.get.mockResolvedValueOnce({
7678
id: '123',
@@ -118,6 +120,7 @@ describe('execute()', () => {
118120
getBasePath,
119121
taskManager: mockTaskManager,
120122
getScopedSavedObjectsClient,
123+
isESOUsingEphemeralEncryptionKey: false,
121124
});
122125
savedObjectsClient.get.mockResolvedValueOnce({
123126
id: '123',
@@ -155,4 +158,24 @@ describe('execute()', () => {
155158
},
156159
});
157160
});
161+
162+
test('throws when passing isESOUsingEphemeralEncryptionKey with true as a value', async () => {
163+
const getScopedSavedObjectsClient = jest.fn().mockReturnValueOnce(savedObjectsClient);
164+
const executeFn = createExecuteFunction({
165+
getBasePath,
166+
taskManager: mockTaskManager,
167+
getScopedSavedObjectsClient,
168+
isESOUsingEphemeralEncryptionKey: true,
169+
});
170+
await expect(
171+
executeFn({
172+
id: '123',
173+
params: { baz: false },
174+
spaceId: 'default',
175+
apiKey: null,
176+
})
177+
).rejects.toThrowErrorMatchingInlineSnapshot(
178+
`"Unable to execute action due to the Encrypted Saved Objects plugin using an ephemeral encryption key. Please set xpack.encryptedSavedObjects.encryptionKey in kibana.yml"`
179+
);
180+
});
158181
});

x-pack/plugins/actions/server/create_execute_function.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface CreateExecuteFunctionOptions {
1212
taskManager: TaskManagerStartContract;
1313
getScopedSavedObjectsClient: (request: any) => SavedObjectsClientContract;
1414
getBasePath: GetBasePathFunction;
15+
isESOUsingEphemeralEncryptionKey: boolean;
1516
}
1617

1718
export interface ExecuteOptions {
@@ -25,8 +26,15 @@ export function createExecuteFunction({
2526
getBasePath,
2627
taskManager,
2728
getScopedSavedObjectsClient,
29+
isESOUsingEphemeralEncryptionKey,
2830
}: CreateExecuteFunctionOptions) {
2931
return async function execute({ id, params, spaceId, apiKey }: ExecuteOptions) {
32+
if (isESOUsingEphemeralEncryptionKey === true) {
33+
throw new Error(
34+
`Unable to execute action due to the Encrypted Saved Objects plugin using an ephemeral encryption key. Please set xpack.encryptedSavedObjects.encryptionKey in kibana.yml`
35+
);
36+
}
37+
3038
const requestHeaders: Record<string, string> = {};
3139

3240
if (apiKey) {

0 commit comments

Comments
 (0)