OpenSearch
OpenSearch copied to clipboard
Refactor Grok validate pattern to iterative approach
Description
Unchecked recursive call in https://github.com/opensearch-project/OpenSearch/blob/main/libs/grok/src/main/java/org/opensearch/grok/Grok.java#L183 is expensive and indeterministic.
- Changing the approach to iterative to prevent stack overflow.
- Adding a limit on max depth size for a pattern resolution to prevent OOM.
Related Issues
Check List
- [x] Functionality includes testing.
- [x] API changes companion pull request created, if applicable.
- [x] Public documentation issue/PR created, if applicable.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.