mirror of
https://github.com/coredns/coredns.git
synced 2026-01-18 23:01:19 -05:00
fix(plugins): add regex length limit (#7802)
This commit is contained in:
@@ -3,6 +3,7 @@ package rewrite
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/coredns/coredns/plugin"
|
||||
@@ -156,3 +157,14 @@ func doTTLTests(t *testing.T, rules []Rule) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewTTLRuleLargeRegex(t *testing.T) {
|
||||
largeRegex := strings.Repeat("a", maxRegexpLen+1)
|
||||
_, err := newTTLRule("stop", "regex", largeRegex, "300")
|
||||
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