mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
AZUREDNS: Do not warn about underscore for acm-validations.aws (#661)
* Check for acm-validations.aws.
This commit is contained in:
@ -100,7 +100,7 @@ var labelUnderscores = []string{
|
||||
// these record types may contain underscores
|
||||
var rTypeUnderscores = []string{"SRV", "TLSA", "TXT"}
|
||||
|
||||
func checkLabel(label string, rType string, domain string, meta map[string]string) error {
|
||||
func checkLabel(label string, rType string, target, domain string, meta map[string]string) error {
|
||||
if label == "@" {
|
||||
return nil
|
||||
}
|
||||
@ -125,6 +125,11 @@ func checkLabel(label string, rType string, domain string, meta map[string]strin
|
||||
return nil
|
||||
}
|
||||
}
|
||||
// Don't warn for CNAMEs if the target ends with acm-validations.aws
|
||||
// See https://github.com/StackExchange/dnscontrol/issues/519
|
||||
if strings.HasPrefix(label, "_") && rType == "CNAME" && strings.HasSuffix(target, ".acm-validations.aws.") {
|
||||
return nil
|
||||
}
|
||||
// Don't warn for certain label substrings
|
||||
for _, ex := range labelUnderscores {
|
||||
if strings.Contains(label, ex) {
|
||||
@ -296,7 +301,7 @@ func NormalizeAndValidateConfig(config *models.DNSConfig) (errs []error) {
|
||||
if err := validateRecordTypes(rec, domain.Name, pTypes); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if err := checkLabel(rec.GetLabel(), rec.Type, domain.Name, rec.Metadata); err != nil {
|
||||
if err := checkLabel(rec.GetLabel(), rec.Type, rec.GetTargetField(), domain.Name, rec.Metadata); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if errs2 := checkTargets(rec, domain.Name); errs2 != nil {
|
||||
|
@ -12,17 +12,20 @@ func TestCheckLabel(t *testing.T) {
|
||||
var tests = []struct {
|
||||
label string
|
||||
rType string
|
||||
target string
|
||||
isError bool
|
||||
hasSkipMeta bool
|
||||
}{
|
||||
{"@", "A", false, false},
|
||||
{"foo.bar", "A", false, false},
|
||||
{"_foo", "A", true, false},
|
||||
{"_foo", "SRV", false, false},
|
||||
{"_foo", "TLSA", false, false},
|
||||
{"_foo", "TXT", false, false},
|
||||
{"test.foo.tld", "A", true, false},
|
||||
{"test.foo.tld", "A", false, true},
|
||||
{"@", "A", "zap", false, false},
|
||||
{"foo.bar", "A", "zap", false, false},
|
||||
{"_foo", "A", "zap", true, false},
|
||||
{"_foo", "SRV", "zap", false, false},
|
||||
{"_foo", "TLSA", "zap", false, false},
|
||||
{"_foo", "TXT", "zap", false, false},
|
||||
{"_y2", "CNAME", "foo", true, false},
|
||||
{"_y3", "CNAME", "asfljds.acm-validations.aws", false, false},
|
||||
{"test.foo.tld", "A", "zap", true, false},
|
||||
{"test.foo.tld", "A", "zap", false, true},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
@ -31,7 +34,7 @@ func TestCheckLabel(t *testing.T) {
|
||||
if test.hasSkipMeta {
|
||||
meta["skip_fqdn_check"] = "true"
|
||||
}
|
||||
err := checkLabel(test.label, test.rType, "foo.tld", meta)
|
||||
err := checkLabel(test.label, test.rType, test.target, "foo.tld", meta)
|
||||
if err != nil && !test.isError {
|
||||
t.Errorf(" Expected no error but got %s", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user