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
[RAM] Fix filtering tags by special characters #135673
[RAM] Fix filtering tags by special characters #135673
Conversation
Pinging @elastic/response-ops (Team:ResponseOps) |
filters.push(`alert.attributes.tags:(${tagsFilter.join(' or ')})`); | ||
filters.push( | ||
`alert.attributes.tags:(${tagsFilter | ||
.map((tag) => tag.replace(/([\)\(\<\>\}\{\"\:\\])/gm, '\\$&')) |
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.
I am not sure if it is relevant to the PR but you can use escapeKuery
from @kbn/es-query
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.
I tried to use escapeKuery
but it seems like that does not escape {}
. Looking at the source code, it does seem to support that assumption.
function escapeSpecialCharacters(str: string) {
return str.replace(/[\\():<>"*]/g, '\\$&'); // $& means the whole matched string
}
Also I noticed this regex pattern is used in security solutions: x-pack/plugins/security_solution/public/management/common/utils.ts
. But yes I do think it would be ideal if we can just use the same regex across the code base. So I wouldn't mind just using escapeKuery
@elasticmachine merge upstream |
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.
👏
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Page load bundle
History
To update your PR or re-run it, just comment with: |
fixed by this pr: #136312 |
Summary
Resolves: #135599
Fixes the inability to filter on tags with special characters
Checklist