-
Notifications
You must be signed in to change notification settings - Fork 431
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
Add optional pattern
attribute
#1834
Add optional pattern
attribute
#1834
Conversation
@andrewkroh Does the proposed implementation match up with your expectations? I added regex validation ECS-side, but I know the support of expressions can vary between different languages/engines/implementations. I'm open to removing the validation step if it's best to remove any sort of regexp validation ECS-side. |
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.
LGTM. Thanks for adding this to the schema.
* add validator for new pattern attribute; also consolidate dup'd logic * remove unused import * add unit tests for validate_pattern_regex * document pattern field attr * add pattern to allow list * add testing for allowed vs. unallowed field values * mark pattern as optional * adding changelog * check example value if pattern is present (cherry picked from commit 9887aef)
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
* add validator for new pattern attribute; also consolidate dup'd logic * remove unused import * add unit tests for validate_pattern_regex * document pattern field attr * add pattern to allow list * add testing for allowed vs. unallowed field values * mark pattern as optional * adding changelog * check example value if pattern is present (cherry picked from commit 9887aef)
Overview
Introduces a new optional field definition attribute:
pattern
. The pattern attribute holds a regular expression (regex) which expresses the expected constraint on a string field's value.The ECS tooling checks the regex itself to ensure validity. However, The ECS tooling cannot evaluate the regex against provided field values.
Motivation
Allow automated testing to use the regex found in the
pattern
fields against values populating ECS fields.Implementation details
Regex validation
If specified, the regex value from
pattern
goes through a check usingre.compile
if the--strict
flag is present. The generator will only generate a warning if--strict
isn't specified.Generated artifacts
The
pattern
field appears in the following generated artifacts:generated/beats/fields.ecs.yml
generated/ecs/ecs_flat.yml
generated/ecs/ecs_nested.yml
Misc refactoring
I took the opportunity to dedup how
--strict
checks are handled inschema.cleaner
.Example usage
Resolves #1741