From 40109946f627e597f58294a8b76482812306b000 Mon Sep 17 00:00:00 2001 From: Julian Gentges <13141309+gentges@users.noreply.github.com> Date: Fri, 17 Apr 2026 22:34:37 +0200 Subject: [PATCH] Improve regex pattern for parsing ban entries Adjusted the whitespace handling in the first part of the regex and allowed for negative numbers in the ban duration part. --- fail2ban-client/fail2ban-client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fail2ban-client/fail2ban-client.go b/fail2ban-client/fail2ban-client.go index a1a7a4a..01d63bf 100644 --- a/fail2ban-client/fail2ban-client.go +++ b/fail2ban-client/fail2ban-client.go @@ -250,7 +250,7 @@ func (f2bc *Fail2BanClient) GetBanned(jailName string) (*JailEntry, error) { for index := 0; index < banListLen; index++ { if listEnty, listEntyOk := banList.Get(index).(string); listEntyOk { log.Tracef("GetBanned: Parsing ban entry: %s", listEnty) - re := regexp.MustCompile(`^(\d{1,3}(?:\.\d{1,3}){3}) \t(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) \+ (\d+) = (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})$`) + re := regexp.MustCompile(`^(\d{1,3}(?:\.\d{1,3}){3})[ \t]+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) \+ (-?\d+) = (\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})$`) matches := re.FindStringSubmatch(listEnty) if matches == nil {