mirror of
https://github.com/coredns/coredns.git
synced 2026-01-18 06:41:18 -05:00
fix(plugins): add regex length limit (#7802)
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/coredns/coredns/plugin"
|
||||
@@ -263,3 +264,14 @@ func TestCNAMETargetRewrite_upstreamFailurePaths(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewCNAMERuleLargeRegex(t *testing.T) {
|
||||
largeRegex := strings.Repeat("a", maxRegexpLen+1)
|
||||
_, err := newCNAMERule("stop", "regex", largeRegex, "replacement")
|
||||
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