Skip to content

Commit 5db3545

Browse files
authored
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
1 parent e559459 commit 5db3545

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

.changeset/soft-kids-watch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'grafana-zabbix': patch
3+
---
4+
5+
Fix: Remove regex pattern length restriction

pkg/zabbix/utils.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,6 @@ func parseFilter(filter string) (*regexp2.Regexp, error) {
155155
return nil, backend.DownstreamErrorf("error parsing regexp: potentially dangerous regex pattern detected")
156156
}
157157

158-
// Security: Limit regex pattern length
159-
if len(regexPattern) > 1000 {
160-
return nil, backend.DownstreamErrorf("error parsing regexp: pattern too long (max 1000 characters)")
161-
}
162-
163158
pattern := ""
164159
if matches[2] != "" {
165160
if flagRE.MatchString(matches[2]) {

pkg/zabbix/utils_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package zabbix
22

33
import (
44
"reflect"
5-
"strings"
65
"testing"
76

87
"github.com/dlclark/regexp2"
@@ -124,13 +123,6 @@ func TestParseFilter(t *testing.T) {
124123
expectNoError: false,
125124
expectedError: "error parsing regexp: potentially dangerous regex pattern detected",
126125
},
127-
{
128-
name: "Pattern too long",
129-
filter: "/" + strings.Repeat("a", 1001) + "/",
130-
want: nil,
131-
expectNoError: false,
132-
expectedError: "error parsing regexp: pattern too long (max 1000 characters)",
133-
},
134126
{
135127
name: "Safe complex regex",
136128
filter: "/^[a-zA-Z0-9_-]+\\.[a-zA-Z]{2,}$/",

0 commit comments

Comments
 (0)