-
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.
- Loading branch information
Showing
8 changed files
with
65 additions
and
39 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
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
47 changes: 47 additions & 0 deletions
47
...n_engine/rule_management/logic/detection_rules_client/converters/normalize_rule_params.ts
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. | ||
*/ | ||
import type { BaseRuleParams, RuleSourceCamelCased } from '../../../../rule_schema'; | ||
|
||
interface NormalizeRuleSourceParams { | ||
immutable: BaseRuleParams['immutable']; | ||
ruleSource: BaseRuleParams['ruleSource']; | ||
} | ||
|
||
/* | ||
* Since there's no mechanism to migrate all rules at the same time, | ||
* we cannot guarantee that the ruleSource params is present in all rules. | ||
* This function will normalize the ruleSource param, creating it if does | ||
* not exist in ES, based on the immutable param. | ||
*/ | ||
export const normalizeRuleSource = ({ | ||
immutable, | ||
ruleSource, | ||
}: NormalizeRuleSourceParams): RuleSourceCamelCased => { | ||
if (!ruleSource) { | ||
const normalizedRuleSource: RuleSourceCamelCased = immutable | ||
? { | ||
type: 'external', | ||
isCustomized: false, | ||
} | ||
: { | ||
type: 'internal', | ||
}; | ||
|
||
return normalizedRuleSource; | ||
} | ||
return ruleSource; | ||
}; | ||
|
||
export const normalizeRuleParams = (params: BaseRuleParams) => { | ||
return { | ||
...params, | ||
ruleSource: normalizeRuleSource({ | ||
immutable: params.immutable, | ||
ruleSource: params.ruleSource, | ||
}), | ||
}; | ||
}; |
32 changes: 0 additions & 32 deletions
32
...n_engine/rule_management/logic/detection_rules_client/converters/normalize_rule_source.ts
This file was deleted.
Oops, something went wrong.
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