mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
ROUTE53: Report R53_ALIAS loops as an error (#2111)
This commit is contained in:
@ -1256,6 +1256,16 @@ func makeTests(t *testing.T) []*TestGroup {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
testgroup("R53_ALIAS_Loop",
|
||||||
|
// This will always be skipped because rejectifTargetEqualsLabel
|
||||||
|
// will always flag it as not permitted.
|
||||||
|
// See https://github.com/StackExchange/dnscontrol/issues/2107
|
||||||
|
requires(providers.CanUseRoute53Alias),
|
||||||
|
tc("loop should fail",
|
||||||
|
r53alias("test-islandora", "CNAME", "test-islandora.**current-domain**"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
// CLOUDFLAREAPI features
|
// CLOUDFLAREAPI features
|
||||||
|
|
||||||
testgroup("CF_REDIRECT",
|
testgroup("CF_REDIRECT",
|
||||||
|
@ -1,10 +1,31 @@
|
|||||||
package route53
|
package route53
|
||||||
|
|
||||||
import "github.com/StackExchange/dnscontrol/v3/models"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/StackExchange/dnscontrol/v3/models"
|
||||||
|
"github.com/StackExchange/dnscontrol/v3/pkg/rejectif"
|
||||||
|
)
|
||||||
|
|
||||||
// AuditRecords returns a list of errors corresponding to the records
|
// AuditRecords returns a list of errors corresponding to the records
|
||||||
// that aren't supported by this provider. If all records are
|
// that aren't supported by this provider. If all records are
|
||||||
// supported, an empty list is returned.
|
// supported, an empty list is returned.
|
||||||
func AuditRecords(records []*models.RecordConfig) []error {
|
func AuditRecords(records []*models.RecordConfig) []error {
|
||||||
|
a := rejectif.Auditor{}
|
||||||
|
|
||||||
|
a.Add("R53_ALIAS", rejectifTargetEqualsLabel) // Last verified 2023-03-01
|
||||||
|
|
||||||
|
return a.Audit(records)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normally this kind of function would be put in `pkg/rejectif` but
|
||||||
|
// since this is ROUTE53-specific, we'll include it here.
|
||||||
|
|
||||||
|
// rejectifTargetEqualsLabel rejects an ALIAS that would create a loop.
|
||||||
|
|
||||||
|
func rejectifTargetEqualsLabel(rc *models.RecordConfig) error {
|
||||||
|
if (rc.GetLabelFQDN() + ".") == rc.GetTargetField() {
|
||||||
|
return fmt.Errorf("alias target loop")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user