From b98442e5b0ad07d706b6ce9e2b3dd847c5453592 Mon Sep 17 00:00:00 2001 From: jbond Date: Fri, 28 Apr 2023 23:06:14 +0200 Subject: [PATCH] types - dns: add a new dns type with more specific fqdn definitions This PR introduces a new set of types for validating FQDN's. it creates a type for the more loose rfc definitions of domain names and a stricter and likely more useful iana type. This allows us to create a new type that more does to what most users expect i.e. that a dns name is one that works on the internt, without breaking current uses for users that may be using the Stdlib::Fqdn to validate validate DNS names that don't work with the IANA roots. The intention of this patch would be to deprecate the currnet Stdlib::Fqdn type and encourage users to move to the appropriate Stdlib::DNS::* type which for most users will likely be the stricter Stdlib::DNS::Fqdn type Note: this PR is intentionally a bit rough to first garner thoughts as to if this is the correct direction Fixes #1282 (not sure it fixes but want it tagged) --- types/dns/fqdn.pp | 1 + types/dns/iana/fqdn.pp | 1 + types/dns/iana/fqdn/ascii.pp | 1 + types/dns/punycode.pp | 1 + types/dns/rfc/fqdn.pp | 2 ++ types/fqdn.pp | 2 +- 6 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 types/dns/fqdn.pp create mode 100644 types/dns/iana/fqdn.pp create mode 100644 types/dns/iana/fqdn/ascii.pp create mode 100644 types/dns/punycode.pp create mode 100644 types/dns/rfc/fqdn.pp diff --git a/types/dns/fqdn.pp b/types/dns/fqdn.pp new file mode 100644 index 000000000..16d6a5c3c --- /dev/null +++ b/types/dns/fqdn.pp @@ -0,0 +1 @@ +type Stdlib::DNS::Fqdn = Stdlib::DNS::IANA::Fqdn::ASCII diff --git a/types/dns/iana/fqdn.pp b/types/dns/iana/fqdn.pp new file mode 100644 index 000000000..c610b714e --- /dev/null +++ b/types/dns/iana/fqdn.pp @@ -0,0 +1 @@ +type Stdlib::DNS::IANA::Fqdn = Pattern[/\A((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)*[[:alpha:]]+)\z/] diff --git a/types/dns/iana/fqdn/ascii.pp b/types/dns/iana/fqdn/ascii.pp new file mode 100644 index 000000000..bb5c64537 --- /dev/null +++ b/types/dns/iana/fqdn/ascii.pp @@ -0,0 +1 @@ +type Stdlib::DNS::IANA::Fqdn::ASCII = Pattern[/\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[a-z0-9]*[a-z]+[a-z0-9]*)\z/] diff --git a/types/dns/punycode.pp b/types/dns/punycode.pp new file mode 100644 index 000000000..1668e874d --- /dev/null +++ b/types/dns/punycode.pp @@ -0,0 +1 @@ +type Stdlib::DNS::Punycpde = Pattern[/xn--[a-z0-9]+/] diff --git a/types/dns/rfc/fqdn.pp b/types/dns/rfc/fqdn.pp new file mode 100644 index 000000000..6a925bbfc --- /dev/null +++ b/types/dns/rfc/fqdn.pp @@ -0,0 +1,2 @@ +type Stdlib::DNS::Rfc::Fqdn = Pattern[/\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/] + diff --git a/types/fqdn.pp b/types/fqdn.pp index c2fbe09ae..0002dee7c 100644 --- a/types/fqdn.pp +++ b/types/fqdn.pp @@ -1,2 +1,2 @@ # @summary Validate a Fully Qualified Domain Name -type Stdlib::Fqdn = Pattern[/\A(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])\z/] +type Stdlib::Fqdn = Stdlib::DNS::Fqdn