mirror of
https://github.com/coredns/coredns.git
synced 2026-01-13 20:31:18 -05:00
fix(plugins): add regex length limit (#7802)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package template
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/coredns/caddy"
|
||||
@@ -198,3 +200,19 @@ func TestSetupParse(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetupParseLargeRegex(t *testing.T) {
|
||||
largeRegex := strings.Repeat("a", maxRegexpLen+1)
|
||||
config := fmt.Sprintf(`template ANY A example.com {
|
||||
match %s
|
||||
}`, largeRegex)
|
||||
|
||||
c := caddy.NewTestController("dns", config)
|
||||
_, err := templateParse(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