Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TLSA to the list of record types for which leading underscores are allowed #403

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/using_netbox_dns.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ The names of Name Servers, Zones and Records are all used as RR names in DNS, so
There are some special cases that need to be taken care of:

* Some non-free operating systems accept underscores in host names, which are not permitted according to RFC1035 and rejected by default e.g. by BIND.
* Record types such as SRV and TXT can contain underscores as the first character of a label even in more standard-conforming implementations
* Record types such as SRV, TLSA and TXT can contain underscores as the first character of a label even in more standard-conforming implementations
* Given the large number of defined RR types, there might be other exceptions to the rules given in the RFCs

To take care of these cases, there are three configuration variables for NetBox DNS that adjust the validation of record names:
Expand All @@ -636,7 +636,7 @@ Variable | Factory Default
-------- | ---------------
`tolerate_underscores_in_labels` | `False`
`tolerate_characters_in_zone_labels`| `''`
`tolerate_leading_underscore_types` | `["TXT", "SRV"]`
`tolerate_leading_underscore_types` | `["TXT", "SRV", "TLSA"]`
`tolerate_non_rfc1035_types` | `[]`

The settings can be set or overridden in the file `/opt/netbox/netbox/netbox/configuration.py` by defining new values in `PLUGINS_CONFIG` as follows:
Expand All @@ -647,7 +647,7 @@ PLUGINS_CONFIG = {
...
'tolerate_underscores_in_labels': True,
'tolerate_characters_in_zone_labels': "/",
'tolerate_leading_underscore_types': ["TXT", "SRV", "CNAME"]
'tolerate_leading_underscore_types': ["TXT", "SRV", "TLSA", "CNAME"]
'tolerate_non_rfc1035_types': ["X25"]
},
}
Expand Down
3 changes: 2 additions & 1 deletion netbox_dns/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ class DNSConfig(PluginConfig):
"tolerate_underscores_in_labels": False,
"tolerate_underscores_in_hostnames": False, # Deprecated, will be removed in 1.2.0
"tolerate_leading_underscore_types": [
RecordTypeChoices.TXT,
RecordTypeChoices.SRV,
RecordTypeChoices.TLSA,
RecordTypeChoices.TXT,
],
"tolerate_non_rfc1035_types": [],
"enable_root_zones": False,
Expand Down
9 changes: 9 additions & 0 deletions netbox_dns/tests/record/test_name_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ def test_name_validation_ok(self):
name=record.get("name"), zone=record.get("zone"), **self.record_data
)

def test_tlsa_validation_ok(self):
record = Record.objects.create(
name="_25._tcp.mx1",
zone=self.zones[0],
type=RecordTypeChoices.TLSA,
value="3 1 1 4048c63a12234d9edf4d28113929cab21f8307a6c26732c2f5d103a322b612e1",
)
self.assertEqual(record.name, "_25._tcp.mx1")

def test_srv_validation_ok(self):
record = Record.objects.create(
name="_ldaps._tcp",
Expand Down