Skip to content
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

header_regexp does not behave as expected in an expression #6501

Open
mininmobile opened this issue Aug 9, 2024 · 0 comments
Open

header_regexp does not behave as expected in an expression #6501

mininmobile opened this issue Aug 9, 2024 · 0 comments

Comments

@mininmobile
Copy link

something is different in the way header_regexp is parsed when in a CEL expression than as a regular matcher. this may be the case for path_regexp as well


i used to have a matcher like this to detect bots. note the \b in the regex

@badbot header_regexp User-Agent (?i).*(bot\b|-ai\b|google|copilot|baidu|...).*
abort @badbot

it worked great! it matched everything i specified, and everything else that reported as a bot (eg. discordbot matches, despite not having discord explicitly in my regex)

curl -A "bot" aborts, but curl -A "bottom" does not

this fell apart when i had to combine it with other matchers. since there is no or { ... } matcher, i had to convert it to an expression. though, even if i do not OR it with anything, the same header_regexp does not work as expected

@badbot `header_regexp('User-Agent','(?i).*(bot\b|-ai\b|google|copilot|baidu|...).*'`
abort @badbot

curl -A "bot" does not get aborted!!???!??

the workaround is to have a normal matcher just for my regex with a word boundary, and then duplicate my abort @bot directive, but this is the exact thing expressions are supposed to help avoid!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant