Skip to content

Commit

Permalink
types - dns: add a new dns type with more specific fqdn definitions
Browse files Browse the repository at this point in the history
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 puppetlabs#1282 (not sure it fixes but want it tagged)
  • Loading branch information
b4ldr committed May 3, 2023
1 parent a241039 commit 5a02c3e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions types/dns/fqdn.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Stdlib::DNS::Fqdn = Stdlib::DNS::Fqdn::IANA::ASCII
1 change: 1 addition & 0 deletions types/dns/fqdn/iana/ascii.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Stdlib::DNS::Fqdn::IANA::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/]
1 change: 1 addition & 0 deletions types/dns/fqdn/iana/unicode.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Stdlib::DNS::Fqdn::IANA::Unicode = Pattern[/\A((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)*[[:alpha:]]+)\z/]
2 changes: 2 additions & 0 deletions types/dns/fqdn/rfc.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
type Stdlib::DNS::Fqdn::Rfc = 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/]

1 change: 1 addition & 0 deletions types/dns/punycode.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type Stdlib::DNS::Punycpde = Pattern[/xn--[a-z0-9]+/]
2 changes: 1 addition & 1 deletion types/fqdn.pp
Original file line number Diff line number Diff line change
@@ -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::Rfc::Fqdn

0 comments on commit 5a02c3e

Please sign in to comment.