-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Security Solution] Create Map of upgradable rule fields by type #190128
Merged
jpdjere
merged 33 commits into
elastic:main
from
jpdjere:create-upgradable-rule-fields-map
Sep 12, 2024
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
b9ed7aa
Create map of upgradable rule fields by type
jpdjere 502c98c
Change comment
jpdjere 570357c
Rework
jpdjere e1641d0
Added tests
jpdjere 999d227
Delete test
jpdjere 2218f1c
lint
jpdjere a1ca8ec
Remove test
jpdjere 46618fd
Fix test
jpdjere 4499eb5
Address changes
jpdjere 448549d
Address feedback
jpdjere 77dbb2f
Alternatives to generate fields prop
jpdjere bacd2bb
Cleanup
jpdjere f3fccc2
Update
jpdjere ac5f6ae
Adds comments
jpdjere d762af3
Fix type
jpdjere e0d998e
Lint
jpdjere b8f4ccd
Fix lint
jpdjere 8a3b286
lint
jpdjere 2a07a5d
fix
jpdjere 4b23cce
Created Zod schema and types
jpdjere b698273
Add unit tests
jpdjere 6d8e138
Unit tests
jpdjere 5c40989
remove comments
jpdjere 57ae7dd
remove export
jpdjere a7ba65c
fixes
jpdjere 2f3f205
remove change
jpdjere 5406026
Fix moved import
jpdjere d76ad7e
Fix types
jpdjere 870a2d7
Fix incorrect mock values for tests
jpdjere cac237a
refactored code
jpdjere 11b5857
Add comment
jpdjere 5b3e6c1
Export internal types
jpdjere d5c0618
[CI] Auto-commit changed files from 'yarn openapi:generate'
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
25 changes: 25 additions & 0 deletions
25
...common/api/detection_engine/prebuilt_rules/model/diff/diffable_rule/diffable_rule.test.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,25 @@ | ||
/* | ||
* 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 { DiffableFieldsByTypeUnion, DiffableAllFields, DiffableRuleTypes } from './diffable_rule'; | ||
|
||
describe('Diffable rule schema', () => { | ||
describe('DiffableAllFields', () => { | ||
it('includes all possible rules types listed in the diffable rule schemas', () => { | ||
const diffableAllFieldsRuleTypes = DiffableAllFields.shape.type.options.map((x) => x.value); | ||
const diffableRuleTypes = DiffableRuleTypes.options.map((x) => x.value); | ||
expect(diffableAllFieldsRuleTypes).toStrictEqual(diffableRuleTypes); | ||
}); | ||
}); | ||
|
||
describe('DiffableRule', () => { | ||
it('includes all possible rules types listed in the diffable rule schemas', () => { | ||
const diffableRuleTypes = DiffableFieldsByTypeUnion.options.map((x) => x.shape.type.value); | ||
const ruleTypes = DiffableRuleTypes.options.map((x) => x.value); | ||
expect(diffableRuleTypes).toStrictEqual(ruleTypes); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maximpn @tomsonpl
I'm introducing this change as a follow-up to #191830.
There's some use cases where the Zod type needs to be used before being casted
as z.ZodType<{{@key}}>
: in the case of this PR, once a Zod discriminated union is typed as ZodType, it looses some of its useful properties such asoptions
.I'm exporting these Internal schemas as well where they need to be used externally. Any objections?