fix(plugins): add regex length limit (#7802)

This commit is contained in:
Ville Vesilehto
2026-01-05 19:48:48 +02:00
committed by GitHub
parent adba778626
commit b723bd94d4
15 changed files with 117 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package errors
import (
"bytes"
"fmt"
golog "log"
"strings"
"testing"
@@ -250,3 +251,19 @@ func TestShowFirstOption(t *testing.T) {
})
}
}
func TestErrorsParseLargeRegex(t *testing.T) {
largeRegex := strings.Repeat("a", maxRegexpLen+1)
config := fmt.Sprintf(`errors {
consolidate 1m %s
}`, largeRegex)
c := caddy.NewTestController("dns", config)
_, err := errorsParse(c)
if err == nil {
t.Fatal("Expected error for large regex, got nil")
}
if !strings.Contains(err.Error(), "too long") {
t.Errorf("Expected 'too long' error, got: %v", err)
}
}