-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Support experimental features in timelines (#189028)
## Summary Adding generic support for experimental features in timelines --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
7e5907e
commit 7db2868
Showing
9 changed files
with
97 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -935,4 +935,3 @@ components: | |
type: http | ||
security: | ||
- BasicAuth: [] | ||
tags: !<tag:yaml.org,2002:js/undefined> '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -863,4 +863,3 @@ components: | |
type: http | ||
security: | ||
- BasicAuth: [] | ||
tags: !<tag:yaml.org,2002:js/undefined> '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export const allowedExperimentalValues = Object.freeze({ | ||
// NOTE: remove this after some actual flags are added, without it line 36 fails ts validation | ||
sample: false, | ||
}); | ||
|
||
export type ExperimentalFeatures = { [K in keyof typeof allowedExperimentalValues]: boolean }; | ||
|
||
const allowedKeys = Object.keys(allowedExperimentalValues); | ||
|
||
type Mutable<T> = { -readonly [P in keyof T]: T[P] }; | ||
|
||
/** | ||
* Parses the string value used in `xpack.timelines.enableExperimental` kibana configuration, | ||
* which should be a string of values delimited by a comma (`,`) | ||
* | ||
* @param configValue | ||
* @throws SecuritySolutionInvalidExperimentalValue | ||
*/ | ||
export const parseExperimentalConfigValue = ( | ||
configValue: string[] | ||
): { features: ExperimentalFeatures; invalid: string[] } => { | ||
const enabledFeatures: Mutable<Partial<ExperimentalFeatures>> = {}; | ||
const invalidKeys: string[] = []; | ||
|
||
for (const value of configValue) { | ||
if (!allowedKeys.includes(value as keyof ExperimentalFeatures)) { | ||
invalidKeys.push(value); | ||
} else { | ||
enabledFeatures[value as keyof ExperimentalFeatures] = true; | ||
} | ||
} | ||
|
||
return { | ||
features: { | ||
...allowedExperimentalValues, | ||
...enabledFeatures, | ||
}, | ||
invalid: invalidKeys, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export interface ConfigSchema { | ||
enableExperimental: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters