mirror of
https://github.com/coredns/coredns.git
synced 2026-01-13 12:21:18 -05:00
fix(plugins): add regex length limit (#7802)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user