mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2025-02-25 16:13:04 +08:00
INWX: Guard against single-quote TXT targets (#971)
* INWX: split out and disable TXT with single-quote test * INWX: add check for single-quotes in TXT records
This commit is contained in:
parent
d6b191bae4
commit
e29f7440f5
2 changed files with 21 additions and 1 deletions
|
@ -683,7 +683,10 @@ func makeTests(t *testing.T) []*TestGroup {
|
|||
tc("Create 1 TXT as array", txtmulti("foo", []string{"simple"})), // Same as non-TXTMulti
|
||||
clear(),
|
||||
tc("Create a 255-byte TXT", txt("foo", strings.Repeat("A", 255))),
|
||||
clear(),
|
||||
),
|
||||
|
||||
testgroup("single TXT with single-quote",
|
||||
not("INWX"),
|
||||
tc("Create TXT with single-quote", txt("foo", "blah`blah")),
|
||||
),
|
||||
|
||||
|
|
|
@ -207,6 +207,18 @@ func (api *inwxAPI) deleteRecord(RecordID int) error {
|
|||
return api.client.Nameservers.DeleteRecord(RecordID)
|
||||
}
|
||||
|
||||
// checkRecords ensures that there is no single-quote inside TXT records which would be ignored by INWX.
|
||||
func checkRecords(records models.Records) error {
|
||||
for _, r := range records {
|
||||
if r.Type == "TXT" {
|
||||
if strings.ContainsAny(r.Target, "`") {
|
||||
return fmt.Errorf("INWX TXT records do not support single-quotes in their target")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDomainCorrections finds the currently existing records and returns the corrections required to update them.
|
||||
func (api *inwxAPI) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) {
|
||||
dc.Punycode()
|
||||
|
@ -218,6 +230,11 @@ func (api *inwxAPI) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Cor
|
|||
|
||||
models.PostProcessRecords(foundRecords)
|
||||
|
||||
err = checkRecords(dc.Records)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
differ := diff.New(dc)
|
||||
_, create, del, mod, err := differ.IncrementalDiff(foundRecords)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue