From 5db35450a28a8e7472314bd7c4a256da55663369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Tue, 23 Sep 2025 11:51:31 +0200 Subject: [PATCH] Fix: Remove regex pattern length restriction (#2087) In this PR I removed the regex pattern length restriction because from multi value variables this length can be easly reached, also if the regex is going to be too long it will be caught in the timeout. Fixes #2086 --- .changeset/soft-kids-watch.md | 5 +++++ pkg/zabbix/utils.go | 5 ----- pkg/zabbix/utils_test.go | 8 -------- 3 files changed, 5 insertions(+), 13 deletions(-) create mode 100644 .changeset/soft-kids-watch.md diff --git a/.changeset/soft-kids-watch.md b/.changeset/soft-kids-watch.md new file mode 100644 index 0000000..3f34ccd --- /dev/null +++ b/.changeset/soft-kids-watch.md @@ -0,0 +1,5 @@ +--- +'grafana-zabbix': patch +--- + +Fix: Remove regex pattern length restriction diff --git a/pkg/zabbix/utils.go b/pkg/zabbix/utils.go index 6afa87e..e97657b 100644 --- a/pkg/zabbix/utils.go +++ b/pkg/zabbix/utils.go @@ -155,11 +155,6 @@ func parseFilter(filter string) (*regexp2.Regexp, error) { return nil, backend.DownstreamErrorf("error parsing regexp: potentially dangerous regex pattern detected") } - // Security: Limit regex pattern length - if len(regexPattern) > 1000 { - return nil, backend.DownstreamErrorf("error parsing regexp: pattern too long (max 1000 characters)") - } - pattern := "" if matches[2] != "" { if flagRE.MatchString(matches[2]) { diff --git a/pkg/zabbix/utils_test.go b/pkg/zabbix/utils_test.go index 02e6f37..697a39f 100644 --- a/pkg/zabbix/utils_test.go +++ b/pkg/zabbix/utils_test.go @@ -2,7 +2,6 @@ package zabbix import ( "reflect" - "strings" "testing" "github.com/dlclark/regexp2" @@ -124,13 +123,6 @@ func TestParseFilter(t *testing.T) { expectNoError: false, expectedError: "error parsing regexp: potentially dangerous regex pattern detected", }, - { - name: "Pattern too long", - filter: "/" + strings.Repeat("a", 1001) + "/", - want: nil, - expectNoError: false, - expectedError: "error parsing regexp: pattern too long (max 1000 characters)", - }, { name: "Safe complex regex", filter: "/^[a-zA-Z0-9_-]+\\.[a-zA-Z]{2,}$/",