Describe the bug
The regex string changes form the input in yaml to the actually used value in the program. Somewhere along the way extra \ characters get added before the existing \ characters in the string, resulting in a double backslash: \\.
To Reproduce
- Start the following docker-compose file:
services:
socket-proxy:
image: wollomatic/socket-proxy:1
user: 65534:998
command:
- '-loglevel=debug'
- '-listenip=0.0.0.0'
- '-allowGET=/v1\.\d{1,2}/containers/json\?all=1&filters=%7B%22label%22%3A%7B%22lazytainer\.group%3Dminecraft%22%3Atrue%7D%7D'
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- Observe the log:
time=2024-04-16T10:26:59.439Z level=INFO msg="starting socket-proxy" version=1.1.3 os=linux arch=amd64 runtime=go1.22.2 URL=github.com/wollomatic/socket-proxy
time=2024-04-16T10:26:59.439Z level=INFO msg="configuration info" socketpath=/var/run/docker.sock listenaddress=0.0.0.0:2375 loglevel=DEBUG logjson=false allowfrom=127.0.0.1/32 shutdowngracetime=10
time=2024-04-16T10:26:59.439Z level=INFO msg="watchdog disabled"
time=2024-04-16T10:26:59.439Z level=INFO msg="configured allowed request" method=GET regex="^/v1\\.\\d{1,2}/containers/json\\?all=1&filters=%7B%22label%22%3A%7B%22lazytainer\\.group%3Dminecraft%22%3Atrue%7D%7D$"
time=2024-04-16T10:26:59.439Z level=DEBUG msg="checking socket availability" origin=checkSocketAvailability
The log says that the used regular expression is ^/v1\\.\\d{1,2}/containers/json\\?all=1&filters=%7B%22label%22%3A%7B%22lazytainer\\.group%3Dminecraft%22%3Atrue%7D%7D$.
Expected behavior
The expected regex line is ^/v1\.\d{1,2}/containers/json\?all=1&filters=%7B%22label%22%3A%7B%22lazytainer\.group%3Dminecraft%22%3Atrue%7D%7D$, without any double backslashes.
Additional context
regex101.com is perfectly happy with this when selecting the golang syntax:

Note that what I'm trying to match is actually an url-encoded version of /v1.45/containers/json?all=1&filters={"label":{"lazytainer.group=minecraft":true}}'
I don't think this is a problem with yaml as enclosing strings in single quotes (') should mean that no characters are escaped except that you can input an ' by using ''.
Hopefully I haven't overlooked some simple mistake here, but I can't figure this out :D
Describe the bug
The regex string changes form the input in yaml to the actually used value in the program. Somewhere along the way extra
\characters get added before the existing\characters in the string, resulting in a double backslash:\\.To Reproduce
The log says that the used regular expression is
^/v1\\.\\d{1,2}/containers/json\\?all=1&filters=%7B%22label%22%3A%7B%22lazytainer\\.group%3Dminecraft%22%3Atrue%7D%7D$.Expected behavior
The expected regex line is
^/v1\.\d{1,2}/containers/json\?all=1&filters=%7B%22label%22%3A%7B%22lazytainer\.group%3Dminecraft%22%3Atrue%7D%7D$, without any double backslashes.Additional context

regex101.com is perfectly happy with this when selecting the golang syntax:
Note that what I'm trying to match is actually an url-encoded version of
/v1.45/containers/json?all=1&filters={"label":{"lazytainer.group=minecraft":true}}'I don't think this is a problem with yaml as enclosing strings in single quotes (
') should mean that no characters are escaped except that you can input an'by using''.Hopefully I haven't overlooked some simple mistake here, but I can't figure this out :D