Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check TXT/SPF records for RFC1035 sec. 5.1
If record data has empty spaces it should be surrounded by double quotes. This patch will raise an error during validation if record has whitespaces, empty spaces, tabs, etc., but not wrapped in " " (double quotes). Corresponding RFC part: <character-string> is expressed in one or two ways: as a contiguous set of characters without interior spaces, or as a string beginning with a " and ending with a ". Inside a " delimited string any character can occur, except for a " itself, which must be quoted using \ (back slash). Closes-Bug: 1755788 Depends-On: https://review.openstack.org/#/c/617809/ Change-Id: I159d0732688ddf1337ab3602a84a43fd043dcaa2
- Loading branch information
1 parent
59d8cab
commit 02ef035
Showing
6 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
from oslo_log import log as logging | ||
import oslotest.base | ||
import testtools | ||
|
||
from designate import exceptions | ||
|
||
from designate import objects | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
class RRDataSPFTest(oslotest.base.BaseTestCase): | ||
|
||
def test_reject_non_quoted_spaces(self): | ||
record = objects.SPF(data='foo bar') | ||
with testtools.ExpectedException(exceptions.InvalidObject): | ||
record.validate() | ||
|
||
def test_reject_non_escaped_quotes(self): | ||
record = objects.SPF(data='foo"bar') | ||
with testtools.ExpectedException(exceptions.InvalidObject): | ||
record.validate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
from oslo_log import log as logging | ||
import oslotest.base | ||
import testtools | ||
|
||
from designate import exceptions | ||
|
||
from designate import objects | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
class RRDataTXTTest(oslotest.base.BaseTestCase): | ||
|
||
def test_reject_non_quoted_spaces(self): | ||
record = objects.TXT(data='foo bar') | ||
with testtools.ExpectedException(exceptions.InvalidObject): | ||
record.validate() | ||
|
||
def test_reject_non_escaped_quotes(self): | ||
record = objects.TXT(data='foo"bar') | ||
with testtools.ExpectedException(exceptions.InvalidObject): | ||
record.validate() |
7 changes: 7 additions & 0 deletions
7
releasenotes/notes/bug-1755788-txt-spf-validation-d18e43c12691132a.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
fixes: | ||
- | | ||
TXT and SPF records are now validated for empty spaces in the values. | ||
If record value has empty space it should use "" quotation according to | ||
RFC-1035 section 5.1. Use of single quotation mark within record value | ||
requires quote symbol to be escaped with backslash. Bug-1755788 |