Skip to content

Commit dd4ccbb

Browse files
Merge branch 'master' into eui-upgrade-38.2.0
2 parents 54726ea + e32dd1c commit dd4ccbb

120 files changed

Lines changed: 2288 additions & 781 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.

docs/settings/security-settings.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ There is a very limited set of cases when you'd want to change these settings. F
218218
| Determines if HTTP authentication schemes used by the enabled authentication providers should be automatically supported during HTTP authentication. By default, this setting is set to `true`.
219219

220220
| `xpack.security.authc.http.schemes[]`
221-
| List of HTTP authentication schemes that {kib} HTTP authentication should support. By default, this setting is set to `['apikey']` to support HTTP authentication with <<api-keys, `ApiKey`>> scheme.
221+
| List of HTTP authentication schemes that {kib} HTTP authentication should support. By default, this setting is set to `['apikey', 'bearer']` to support HTTP authentication with the <<api-keys, `ApiKey`>> and <<http-authentication, `Bearer`>> schemes.
222222

223223
|===
224224

docs/user/security/authentication/index.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,14 @@ This type of authentication is usually useful for machine-to-machine interaction
437437

438438
By default {kib} supports <<api-keys, `ApiKey`>> authentication scheme _and_ any scheme supported by the currently enabled authentication provider. For example, `Basic` authentication scheme is automatically supported when basic authentication provider is enabled, or `Bearer` scheme when any of the token based authentication providers is enabled (Token, SAML, OpenID Connect, PKI or Kerberos). But it's also possible to add support for any other authentication scheme in the `kibana.yml` configuration file, as follows:
439439

440-
NOTE: Don't forget to explicitly specify default `apikey` scheme when you just want to add a new one to the list.
440+
NOTE: Don't forget to explicitly specify the default `apikey` and `bearer` schemes when you just want to add a new one to the list.
441441

442442
[source,yaml]
443443
--------------------------------------------------------------------------------
444-
xpack.security.authc.http.schemes: [apikey, basic, something-custom]
444+
xpack.security.authc.http.schemes: [apikey, bearer, basic, something-custom]
445445
--------------------------------------------------------------------------------
446446

447-
With this configuration, you can send requests to {kib} with the `Authorization` header using `ApiKey`, `Basic` or `Something-Custom` HTTP schemes (case insensitive). Under the hood, {kib} relays this header to {es}, then {es} authenticates the request using the credentials in the header.
447+
With this configuration, you can send requests to {kib} with the `Authorization` header using `ApiKey`, `Bearer`, `Basic` or `Something-Custom` HTTP schemes (case insensitive). Under the hood, {kib} relays this header to {es}, then {es} authenticates the request using the credentials in the header.
448448

449449
[float]
450450
[[embedded-content-authentication]]

vars/tasks.groovy

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,14 @@ def functionalXpack(Map params = [:]) {
146146
}
147147
}
148148

149-
whenChanged([
150-
'x-pack/plugins/apm/',
151-
]) {
152-
if (githubPr.isPr()) {
153-
task(kibanaPipeline.functionalTestProcess('xpack-APMCypress', './test/scripts/jenkins_apm_cypress.sh'))
154-
}
155-
}
149+
//temporarily disable apm e2e test since it's breaking.
150+
// whenChanged([
151+
// 'x-pack/plugins/apm/',
152+
// ]) {
153+
// if (githubPr.isPr()) {
154+
// task(kibanaPipeline.functionalTestProcess('xpack-APMCypress', './test/scripts/jenkins_apm_cypress.sh'))
155+
// }
156+
// }
156157

157158
whenChanged([
158159
'x-pack/plugins/uptime/',

x-pack/plugins/alerting/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ The following table describes the properties of the `options` object.
122122
|useSavedObjectReferences.extractReferences|(Optional) When developing a rule type, you can choose to implement hooks for extracting saved object references from rule parameters. This hook will be invoked when a rule is created or updated. Implementing this hook is optional, but if an extract hook is implemented, an inject hook must also be implemented.|Function
123123
|useSavedObjectReferences.injectReferences|(Optional) When developing a rule type, you can choose to implement hooks for injecting saved object references into rule parameters. This hook will be invoked when a rule is retrieved (get or find). Implementing this hook is optional, but if an inject hook is implemented, an extract hook must also be implemented.|Function
124124
|isExportable|Whether the rule type is exportable from the Saved Objects Management UI.|boolean|
125+
|defaultScheduleInterval|The default interval that will show up in the UI when creating a rule of this rule type.|boolean|
126+
|minimumScheduleInterval|The minimum interval that will be allowed for all rules of this rule type.|boolean|
125127

126128
### Executor
127129

x-pack/plugins/alerting/common/alert_type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export interface AlertType<
2121
producer: string;
2222
minimumLicenseRequired: LicenseType;
2323
isExportable: boolean;
24+
defaultScheduleInterval?: string;
25+
minimumScheduleInterval?: string;
2426
}
2527

2628
export interface ActionGroup<ActionGroupIds extends string> {

x-pack/plugins/alerting/server/routes/rule_types.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ describe('ruleTypesRoute', () => {
5757
},
5858
producer: 'test',
5959
enabledInLicense: true,
60+
minimumScheduleInterval: '1m',
61+
defaultScheduleInterval: '10m',
6062
} as RegistryAlertTypeWithAuth,
6163
];
6264
const expectedResult: Array<AsApiContract<RegistryAlertTypeWithAuth>> = [
@@ -70,7 +72,9 @@ describe('ruleTypesRoute', () => {
7072
},
7173
],
7274
default_action_group_id: 'default',
75+
default_schedule_interval: '10m',
7376
minimum_license_required: 'basic',
77+
minimum_schedule_interval: '1m',
7478
is_exportable: true,
7579
recovery_action_group: RecoveredActionGroup,
7680
authorized_consumers: {},
@@ -102,10 +106,12 @@ describe('ruleTypesRoute', () => {
102106
},
103107
"authorized_consumers": Object {},
104108
"default_action_group_id": "default",
109+
"default_schedule_interval": "10m",
105110
"enabled_in_license": true,
106111
"id": "1",
107112
"is_exportable": true,
108113
"minimum_license_required": "basic",
114+
"minimum_schedule_interval": "1m",
109115
"name": "name",
110116
"producer": "test",
111117
"recovery_action_group": Object {

x-pack/plugins/alerting/server/routes/rule_types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const rewriteBodyRes: RewriteResponseCase<RegistryAlertTypeWithAuth[]> = (result
2222
isExportable,
2323
actionVariables,
2424
authorizedConsumers,
25+
minimumScheduleInterval,
26+
defaultScheduleInterval,
2527
...rest
2628
}) => ({
2729
...rest,
@@ -33,6 +35,8 @@ const rewriteBodyRes: RewriteResponseCase<RegistryAlertTypeWithAuth[]> = (result
3335
is_exportable: isExportable,
3436
action_variables: actionVariables,
3537
authorized_consumers: authorizedConsumers,
38+
minimum_schedule_interval: minimumScheduleInterval,
39+
default_schedule_interval: defaultScheduleInterval,
3640
})
3741
);
3842
};

x-pack/plugins/alerting/server/rule_type_registry.test.ts

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('register()', () => {
114114

115115
test('throws if AlertType ruleTaskTimeout is not a valid duration', () => {
116116
const alertType: AlertType<never, never, never, never, never, 'default'> = {
117-
id: 123 as unknown as string,
117+
id: '123',
118118
name: 'Test',
119119
actionGroups: [
120120
{
@@ -138,6 +138,59 @@ describe('register()', () => {
138138
);
139139
});
140140

141+
test('throws if defaultScheduleInterval isnt valid', () => {
142+
const alertType: AlertType<never, never, never, never, never, 'default'> = {
143+
id: '123',
144+
name: 'Test',
145+
actionGroups: [
146+
{
147+
id: 'default',
148+
name: 'Default',
149+
},
150+
],
151+
152+
defaultActionGroupId: 'default',
153+
minimumLicenseRequired: 'basic',
154+
isExportable: true,
155+
executor: jest.fn(),
156+
producer: 'alerts',
157+
defaultScheduleInterval: 'foobar',
158+
};
159+
const registry = new RuleTypeRegistry(ruleTypeRegistryParams);
160+
161+
expect(() => registry.register(alertType)).toThrowError(
162+
new Error(
163+
`Rule type \"123\" has invalid default interval: string is not a valid duration: foobar.`
164+
)
165+
);
166+
});
167+
168+
test('throws if minimumScheduleInterval isnt valid', () => {
169+
const alertType: AlertType<never, never, never, never, never, 'default'> = {
170+
id: '123',
171+
name: 'Test',
172+
actionGroups: [
173+
{
174+
id: 'default',
175+
name: 'Default',
176+
},
177+
],
178+
defaultActionGroupId: 'default',
179+
minimumLicenseRequired: 'basic',
180+
isExportable: true,
181+
executor: jest.fn(),
182+
producer: 'alerts',
183+
minimumScheduleInterval: 'foobar',
184+
};
185+
const registry = new RuleTypeRegistry(ruleTypeRegistryParams);
186+
187+
expect(() => registry.register(alertType)).toThrowError(
188+
new Error(
189+
`Rule type \"123\" has invalid minimum interval: string is not a valid duration: foobar.`
190+
)
191+
);
192+
});
193+
141194
test('throws if RuleType action groups contains reserved group id', () => {
142195
const alertType: AlertType<never, never, never, never, never, 'default' | 'NotReserved'> = {
143196
id: 'test',
@@ -465,10 +518,12 @@ describe('list()', () => {
465518
"state": Array [],
466519
},
467520
"defaultActionGroupId": "testActionGroup",
521+
"defaultScheduleInterval": undefined,
468522
"enabledInLicense": false,
469523
"id": "test",
470524
"isExportable": true,
471525
"minimumLicenseRequired": "basic",
526+
"minimumScheduleInterval": undefined,
472527
"name": "Test",
473528
"producer": "alerts",
474529
"recoveryActionGroup": Object {

x-pack/plugins/alerting/server/rule_type_registry.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export interface RegistryRuleType
4848
| 'producer'
4949
| 'minimumLicenseRequired'
5050
| 'isExportable'
51+
| 'minimumScheduleInterval'
52+
| 'defaultScheduleInterval'
5153
> {
5254
id: string;
5355
enabledInLicense: boolean;
@@ -188,6 +190,44 @@ export class RuleTypeRegistry {
188190
}
189191
alertType.actionVariables = normalizedActionVariables(alertType.actionVariables);
190192

193+
// validate defaultScheduleInterval here
194+
if (alertType.defaultScheduleInterval) {
195+
const invalidDefaultTimeout = validateDurationSchema(alertType.defaultScheduleInterval);
196+
if (invalidDefaultTimeout) {
197+
throw new Error(
198+
i18n.translate(
199+
'xpack.alerting.ruleTypeRegistry.register.invalidDefaultTimeoutAlertTypeError',
200+
{
201+
defaultMessage: 'Rule type "{id}" has invalid default interval: {errorMessage}.',
202+
values: {
203+
id: alertType.id,
204+
errorMessage: invalidDefaultTimeout,
205+
},
206+
}
207+
)
208+
);
209+
}
210+
}
211+
212+
// validate minimumScheduleInterval here
213+
if (alertType.minimumScheduleInterval) {
214+
const invalidMinimumTimeout = validateDurationSchema(alertType.minimumScheduleInterval);
215+
if (invalidMinimumTimeout) {
216+
throw new Error(
217+
i18n.translate(
218+
'xpack.alerting.ruleTypeRegistry.register.invalidMinimumTimeoutAlertTypeError',
219+
{
220+
defaultMessage: 'Rule type "{id}" has invalid minimum interval: {errorMessage}.',
221+
values: {
222+
id: alertType.id,
223+
errorMessage: invalidMinimumTimeout,
224+
},
225+
}
226+
)
227+
);
228+
}
229+
}
230+
191231
const normalizedAlertType = augmentActionGroupsWithReserved<
192232
Params,
193233
ExtractedParams,
@@ -287,6 +327,8 @@ export class RuleTypeRegistry {
287327
producer,
288328
minimumLicenseRequired,
289329
isExportable,
330+
minimumScheduleInterval,
331+
defaultScheduleInterval,
290332
},
291333
]: [string, UntypedNormalizedAlertType]) => ({
292334
id,
@@ -298,6 +340,8 @@ export class RuleTypeRegistry {
298340
producer,
299341
minimumLicenseRequired,
300342
isExportable,
343+
minimumScheduleInterval,
344+
defaultScheduleInterval,
301345
enabledInLicense: !!this.licenseState.getLicenseCheckForAlertType(
302346
id,
303347
name,

x-pack/plugins/alerting/server/rules_client/rules_client.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,17 @@ export class RulesClient {
296296

297297
await this.validateActions(ruleType, data.actions);
298298

299+
// Validate intervals, if configured
300+
if (ruleType.minimumScheduleInterval) {
301+
const intervalInMs = parseDuration(data.schedule.interval);
302+
const minimumScheduleIntervalInMs = parseDuration(ruleType.minimumScheduleInterval);
303+
if (intervalInMs < minimumScheduleIntervalInMs) {
304+
throw Boom.badRequest(
305+
`Error updating rule: the interval is less than the minimum interval of ${ruleType.minimumScheduleInterval}`
306+
);
307+
}
308+
}
309+
299310
// Extract saved object references for this rule
300311
const {
301312
references,
@@ -847,6 +858,17 @@ export class RulesClient {
847858
);
848859
await this.validateActions(ruleType, data.actions);
849860

861+
// Validate intervals, if configured
862+
if (ruleType.minimumScheduleInterval) {
863+
const intervalInMs = parseDuration(data.schedule.interval);
864+
const minimumScheduleIntervalInMs = parseDuration(ruleType.minimumScheduleInterval);
865+
if (intervalInMs < minimumScheduleIntervalInMs) {
866+
throw Boom.badRequest(
867+
`Error updating rule: the interval is less than the minimum interval of ${ruleType.minimumScheduleInterval}`
868+
);
869+
}
870+
}
871+
850872
// Extract saved object references for this rule
851873
const {
852874
references,

0 commit comments

Comments
 (0)