]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: sample: add new converter has_ctl() to detect control characters
authorWilly Tarreau <w@1wt.eu>
Thu, 13 Aug 2026 13:03:26 +0000 (15:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Aug 2026 13:32:03 +0000 (15:32 +0200)
commit33374957db657c4845153e644c8c2f4279a8724e
tree33ebe98762a25f337c89e596ac22b9b726222454
parent70b6c5826487118cd774e601aa6b6ed419e48762
MINOR: sample: add new converter has_ctl() to detect control characters

Control characters, as defined by RFC5234, are 0x00 to 0x1F and 0x7F.
They're not easy to insert in a config by definition and difficult to
match. Let's add a sample converter which takes a binary input and
returns a boolean indicating if any such character is found within a
possibly configurable class.

By default with no argument, it checks the range above except TAB (0x9)
which is common. With argument "any", it checks them all. With argument
"http", it only checks the strictly forbidden HTTP ones (CR, LF, NUL)
in headers. Otherwise it takes a mask made of the bits corresponding
to each character, with bit 32 corresponding to character 0x7F.

It can be used to detect anomalies, e.g. by logging or dropping when
any such character is found.
doc/configuration.txt
reg-tests/converter/has_ctl.vtc [new file with mode: 0644]
src/sample.c