Skip to content

Commit

Permalink
Improves pattern matching for data telemetry (elastic#197876)
Browse files Browse the repository at this point in the history
## Summary

Addresses concerns with Regex matching.

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
2 people authored and tiansivive committed Oct 29, 2024
1 parent 7275a82 commit 2120423
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ function findMatchingDescriptors({
// avoid system indices caught by very fuzzy index patterns (i.e.: *log* would catch `.kibana-log-...`)
return false;
}
return new RegExp(`^${pattern.replace(/\./g, '\\.').replace(/\*/g, '.*')}$`).test(name);
const escapedPattern = pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
return new RegExp(`^${escapedPattern.replace(/\\\*/g, '.*')}$`).test(name);
});
}

Expand Down

0 comments on commit 2120423

Please sign in to comment.