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

HTTP Monitor generated receive string is not intended regex #219

Open
notandy opened this issue Apr 28, 2023 · 5 comments
Open

HTTP Monitor generated receive string is not intended regex #219

notandy opened this issue Apr 28, 2023 · 5 comments
Labels
bug Something isn't working as expected good first issue Good for newcomers

Comments

@notandy
Copy link
Collaborator

notandy commented Apr 28, 2023

If in octavia an expected_codes is defined as a range (e.g. 200-399), the generated regex is not correct. Currently, it looks like this:

HTTP/1.(0|1) [200-399]

But it should look like this:

HTTP\/1.(0|1) [2-3][0-9][0-9]

see

recv_text = "HTTP/{} [{}-{}]".format(
for implementation details

@notandy notandy added bug Something isn't working as expected good first issue Good for newcomers labels Apr 28, 2023
@BenjaminLudwigSAP
Copy link
Collaborator

This value is used as the receive parameter of the monitor AS3 class. Since its default value is "HTTP/1." the forward slash probably does not have to be escaped. Both this question as well as the character class behavior (which you're most probably right about) depend on the regex engine being used for evaluating the receive parameter. @m-kratochvil can you please check which one it is?

@m-kratochvil
Copy link
Contributor

Yes, this is documented in:https://my.f5.com/manage/s/article/K5917

With some exceptions, health monitors on BIG-IP systems support the use of POSIX Extended Regular Expressions (ERE). ERE syntax treats most characters as literals, meaning that they match only themselves, and defines metacharacters, which can be used to represent special characters, multiple characters, or a sequences of characters.

I also agree that the forward slash does not seem to require escape in the Big-IP monitor configuration, judging by the fact we normally use expression like HTTP/1.(0|1) 200 OK\r\n\r\n and it works. Testing in various online regex validators gets me varying results.

@notandy
Copy link
Collaborator Author

notandy commented May 5, 2023

it's not about the forward slash....

@m-kratochvil
Copy link
Contributor

m-kratochvil commented May 5, 2023

Of course not. The regex [200-399] is wrong (even though it works most of the times), at least for the use case of matching HTTP response codes 200 - 399.
AFAIK it breaks down to 20 0-3 99 within single character class which is not what we want, not only is the logic broken but it won't match for example any middle digits in the range 4-9 (not that there are any known codes like that but that's beside the point), and it will match for example 002.

@m-kratochvil
Copy link
Contributor

Another use-case where this bug surfaced: https://convergedcloud.slack.com/archives/CSP5GMKD1/p1687332168839529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants