mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-11-10 09:12:47 +08:00
Fix: Validate CNAME targets (check for "/") #37
This commit is contained in:
parent
adf2f5e165
commit
46707722f6
2 changed files with 8 additions and 0 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/StackExchange/dnscontrol/providers"
|
||||
"github.com/miekg/dns"
|
||||
"github.com/miekg/dns/dnsutil"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Returns false if target does not validate.
|
||||
|
@ -36,6 +37,9 @@ func checkTarget(target string) error {
|
|||
if len(target) < 1 {
|
||||
return fmt.Errorf("empty target")
|
||||
}
|
||||
if strings.ContainsAny(target, `'" +,|!£$%&/()=?^*ç°§;:_<>[]()@`) {
|
||||
return errors.Errorf("target (%v) includes invalid char", target)
|
||||
}
|
||||
// If it containts a ".", it must end in a ".".
|
||||
if strings.ContainsRune(target, '.') && target[len(target)-1] != '.' {
|
||||
return fmt.Errorf("target (%v) must end with a (.) [Required if target is not single label]", target)
|
||||
|
|
|
@ -64,6 +64,10 @@ func Test_assert_valid_target(t *testing.T) {
|
|||
{"foo.bar.", false},
|
||||
{"foo.", false},
|
||||
{"foo.bar", true},
|
||||
{"foo&bar", true},
|
||||
{"foo bar", true},
|
||||
{"elb21.freshdesk.com/", true},
|
||||
{"elb21.freshdesk.com/.", true},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
Loading…
Reference in a new issue