From 6dad21e292436ac5b7d8113e81e572a0efc66782 Mon Sep 17 00:00:00 2001 From: Garrett Honeycutt Date: Thu, 4 Jan 2018 16:46:22 -0500 Subject: [PATCH] (MODULES-6366) Add data types for IP validation The types are from https://github.com/thrnio/puppet-ip which was released under the Apache-2.0 license by Ryan Whitehurst. Spec tests added and code modified to work with puppetlabs/stdlib by Garrett Honeycutt. Co-authored-by: Ryan Whitehurst Co-authored-by: Garrett Honeycutt --- README.md | 123 ++++++++++++++++++ spec/type_aliases/ip_address_nosubnet_spec.rb | 44 +++++++ spec/type_aliases/ip_address_spec.rb | 44 +++++++ .../ip_address_v4_nosubnet_spec.rb | 30 +++++ spec/type_aliases/ip_address_v4_spec.rb | 30 +++++ .../ip_address_v6_alternative_spec.rb | 28 ++++ .../ip_address_v6_compressed_spec.rb | 31 +++++ spec/type_aliases/ip_address_v6_full_spec.rb | 28 ++++ ...ip_address_v6_nosubnet_alternative_spec.rb | 28 ++++ .../ip_address_v6_nosubnet_compressed_spec.rb | 31 +++++ .../ip_address_v6_nosubnet_full_spec.rb | 28 ++++ spec/type_aliases/ip_address_v6_spec.rb | 32 +++++ types/ip/address.pp | 4 + types/ip/address/nosubnet.pp | 4 + types/ip/address/v4.pp | 4 + types/ip/address/v4/cidr.pp | 1 + types/ip/address/v4/nosubnet.pp | 1 + types/ip/address/v6.pp | 6 + types/ip/address/v6/alternative.pp | 9 ++ types/ip/address/v6/compressed.pp | 10 ++ types/ip/address/v6/full.pp | 1 + types/ip/address/v6/nosubnet.pp | 5 + types/ip/address/v6/nosubnet/alternative.pp | 9 ++ types/ip/address/v6/nosubnet/compressed.pp | 10 ++ types/ip/address/v6/nosubnet/full.pp | 1 + 25 files changed, 542 insertions(+) create mode 100644 spec/type_aliases/ip_address_nosubnet_spec.rb create mode 100644 spec/type_aliases/ip_address_spec.rb create mode 100644 spec/type_aliases/ip_address_v4_nosubnet_spec.rb create mode 100644 spec/type_aliases/ip_address_v4_spec.rb create mode 100644 spec/type_aliases/ip_address_v6_alternative_spec.rb create mode 100644 spec/type_aliases/ip_address_v6_compressed_spec.rb create mode 100644 spec/type_aliases/ip_address_v6_full_spec.rb create mode 100644 spec/type_aliases/ip_address_v6_nosubnet_alternative_spec.rb create mode 100644 spec/type_aliases/ip_address_v6_nosubnet_compressed_spec.rb create mode 100644 spec/type_aliases/ip_address_v6_nosubnet_full_spec.rb create mode 100644 spec/type_aliases/ip_address_v6_spec.rb create mode 100644 types/ip/address.pp create mode 100644 types/ip/address/nosubnet.pp create mode 100644 types/ip/address/v4.pp create mode 100644 types/ip/address/v4/cidr.pp create mode 100644 types/ip/address/v4/nosubnet.pp create mode 100644 types/ip/address/v6.pp create mode 100644 types/ip/address/v6/alternative.pp create mode 100644 types/ip/address/v6/compressed.pp create mode 100644 types/ip/address/v6/full.pp create mode 100644 types/ip/address/v6/nosubnet.pp create mode 100644 types/ip/address/v6/nosubnet/alternative.pp create mode 100644 types/ip/address/v6/nosubnet/compressed.pp create mode 100644 types/ip/address/v6/nosubnet/full.pp diff --git a/README.md b/README.md index bef58210f..d292b3000 100644 --- a/README.md +++ b/README.md @@ -705,6 +705,129 @@ Unacceptable input example: foobar2001:db8::1 ``` +#### `Stdlib::IP::Address` + +Matches any IP address, including both IPv4 and IPv6 addresses. It will +match them either with or without an address prefix as used in CIDR +format IPv4 addresses. + +Examples: + +``` +'127.0.0.1' =~ Stdlib::IP::Address # true +'8.8.4.4' =~ Stdlib::IP::Address # true +'10.1.240.4/24' =~ Stdlib::IP::Address # true +'52.10.10.141' =~ Stdlib::IP::Address # true +'192.168.1' =~ Stdlib::IP::Address # false +'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' =~ Stdlib::IP::Address # true +'FF01:0:0:0:0:0:0:101' =~ Stdlib::IP::Address # true +'FF01::101' =~ Stdlib::IP::Address # true +'FF01:0:0:0:0:0:0:101/32' =~ Stdlib::IP::Address # true +'FF01::101/60' =~ Stdlib::IP::Address # true +'::' =~ Stdlib::IP::Address # true +'12AB::CD30:192.168.0.1' =~ Stdlib::IP::Address # true +``` + +#### `Stdlib::IP::Address::V4` + +Match any string consisting of an IPv4 address in the quad-dotted +decimal format, with or without a CIDR prefix. It will not match any +abbreviated form (e.g., 192.168.1) because these are poorly documented +and inconsistently supported. + +Examples: + +``` +'127.0.0.1' =~ Stdlib::IP::Address::V4 # true +'8.8.4.4' =~ Stdlib::IP::Address::V4 # true +'10.1.240.4/24' =~ Stdlib::IP::Address::V4 # true +'52.10.10.141' =~ Stdlib::IP::Address::V4 # true +'192.168.1' =~ Stdlib::IP::Address::V4 # false +'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' =~ Stdlib::IP::Address::V4 # false +'12AB::CD30:192.168.0.1' =~ Stdlib::IP::Address::V4 # false +``` + +#### `Stdlib::IP::Address::V6` + +Match any string consistenting of an IPv6 address in any of the +documented formats in RFC 2373, with or without an address prefix. + +Examples: + +``` +'127.0.0.1' =~ Stdlib::IP::Address::V6 # false +'10.1.240.4/24' =~ Stdlib::IP::Address::V6 # false +'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210' =~ Stdlib::IP::Address::V6 # true +'FF01:0:0:0:0:0:0:101' =~ Stdlib::IP::Address::V6 # true +'FF01::101' =~ Stdlib::IP::Address::V6 # true +'FF01:0:0:0:0:0:0:101/32' =~ Stdlib::IP::Address::V6 # true +'FF01::101/60' =~ Stdlib::IP::Address::V6 # true +'::' =~ Stdlib::IP::Address::V6 # true +'12AB::CD30:192.168.0.1' =~ Stdlib::IP::Address::V6 # true +``` + +#### `Stdlib::IP::Address::Nosubnet` + +Match the same things as the `Stdlib::IP::Address` alias, except it will not +match an address that includes an address prefix (e.g., it will match +`192.168.0.6` but not `192.168.0.6/24`). + +#### `Stdlib::IP::Address::V4::CIDR` + +Match an IPv4 address in the CIDR format. It will only match if the +address contains an address prefix (e.g., it will match `192.168.0.6/24` +but not `192.168.0.6`). + +#### `Stdlib::IP::Address::V4::Nosubnet` + +Match an IPv4 address only if the address does not contain an address +prefix (e.g., it will match `192.168.0.6` but not `192.168.0.6/24`). + +#### `Stdlib::IP::Address::V6::Full` + +Match an IPv6 address formatted in the "preferred form" as documented in +section 2.2.1 of RFC 2373, with or without an address prefix as +documented in section 2.3 of RFC 2373. + +#### `Stdlib::IP::Address::V6::Alternate` + +Match an IPv6 address formatted in the "alternative form" allowing for +representing the last two 16-bit pieces of the address with a +quad-dotted decimal, as documented in section 2.2.1 of RFC 2373. It will +match addresses with or without an address prefix as documented in +section 2.3 of RFC 2373. + +#### `Stdlib::IP::Address::V6::Compressed` + +Match an IPv6 address which may contain `::` used to compress zeros as +documented in section 2.2.2 of RFC 2373. It will match addresses with +or without an address prefix as documented in section 2.3 of RFC 2373. + +#### `Stdlib::IP::Address::V6::Nosubnet` + +Alias to allow `Stdlib::IP::Address::V6::Nosubnet::Full`, +`Stdlib::IP::Address::V6::Nosubnet::Alternate` and +`Stdlib::IP::Address::V6::Nosubnet::Compressed`. + +#### `Stdlib::IP::Address::V6::Nosubnet::Full` + +Match an IPv6 address formatted in the "preferred form" as documented in +section 2.2.1 of RFC 2373. It will not match addresses with address +prefix as documented in section 2.3 of RFC 2373. + +#### `Stdlib::IP::Address::V6::Nosubnet::Alternate` + +Match an IPv6 address formatted in the "alternative form" allowing for +representing the last two 16-bit pieces of the address with a +quad-dotted decimal, as documented in section 2.2.1 of RFC 2373. It will +only match addresses without an address prefix as documented in section +2.3 of RFC 2373. + +#### `Stdlib::IP::Address::V6::Nosubnet::Compressed` + +Match an IPv6 address which may contain `::` used to compress zeros as +documented in section 2.2.2 of RFC 2373. It will only match addresses +without an address prefix as documented in section 2.3 of RFC 2373. ### Facts diff --git a/spec/type_aliases/ip_address_nosubnet_spec.rb b/spec/type_aliases/ip_address_nosubnet_spec.rb new file mode 100644 index 000000000..921d95704 --- /dev/null +++ b/spec/type_aliases/ip_address_nosubnet_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address::Nosubnet' do + describe 'accepts ipv4 and ipv6 addresses without subnets' do + [ + '224.0.0.0', + '255.255.255.255', + '0.0.0.0', + '192.88.99.0', + '2001:0db8:85a3:0000:0000:8a2e:0370:7334', + 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', + '127.0.0.1', + '8.8.4.4', + '52.10.10.141', + 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', + 'FF01:0:0:0:0:0:0:101', + 'FF01::101', + '::', + '12AB::CD30:192.168.0.1', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + '10.1.240.4/24', + 'FF01:0:0:0:0:0:0:101/32', + 'FF01::101/60', + 'nope', + '77', + '4.4.4', + '2001:0db8:85a3:000000:0000:8a2e:0370:7334', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/ip_address_spec.rb b/spec/type_aliases/ip_address_spec.rb new file mode 100644 index 000000000..e60335068 --- /dev/null +++ b/spec/type_aliases/ip_address_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address' do + describe 'accepts ipv4 and ipv6 addresses' do + [ + '224.0.0.0', + '255.255.255.255', + '0.0.0.0', + '192.88.99.0', + '2001:0db8:85a3:0000:0000:8a2e:0370:7334', + 'fa76:8765:34ac:0823:ab76:eee9:0987:1111', + '127.0.0.1', + '8.8.4.4', + '10.1.240.4/24', + '52.10.10.141', + 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', + 'FF01:0:0:0:0:0:0:101', + 'FF01::101', + 'FF01:0:0:0:0:0:0:101/32', + 'FF01::101/60', + '::', + '12AB::CD30:192.168.0.1', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + 'nope', + '77', + '4.4.4', + '2001:0db8:85a3:000000:0000:8a2e:0370:7334', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/ip_address_v4_nosubnet_spec.rb b/spec/type_aliases/ip_address_v4_nosubnet_spec.rb new file mode 100644 index 000000000..ab74f8ce8 --- /dev/null +++ b/spec/type_aliases/ip_address_v4_nosubnet_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address::V4::Nosubnet' do + describe 'accepts ipv4 addresses without subnets' do + [ + '127.0.0.1', + '8.8.4.4', + '52.10.10.141', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + '10.1.240.4/24', + '192.168.1', + 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', + '12AB::CD30:192.168.0.1', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/ip_address_v4_spec.rb b/spec/type_aliases/ip_address_v4_spec.rb new file mode 100644 index 000000000..10854c8fa --- /dev/null +++ b/spec/type_aliases/ip_address_v4_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address::V4' do + describe 'accepts ipv4 addresses' do + [ + '127.0.0.1', + '8.8.4.4', + '10.1.240.4/24', + '52.10.10.141', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + '192.168.1', + 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', + '12AB::CD30:192.168.0.1', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/ip_address_v6_alternative_spec.rb b/spec/type_aliases/ip_address_v6_alternative_spec.rb new file mode 100644 index 000000000..9fbf7ca72 --- /dev/null +++ b/spec/type_aliases/ip_address_v6_alternative_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address::V6::Alternative' do + describe 'accepts ipv6 addresses in alternative format' do + [ + '0:0:0:0:0:0:13.1.68.3', + '0:0:0:0:0:FFFF:129.144.52.38', + '0:0:0:0:0:FFFF:129.144.52.38/60', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + 'nope', + '127.0.0.1', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/ip_address_v6_compressed_spec.rb b/spec/type_aliases/ip_address_v6_compressed_spec.rb new file mode 100644 index 000000000..e2b7dd533 --- /dev/null +++ b/spec/type_aliases/ip_address_v6_compressed_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address::V6::Compressed' do + describe 'accepts ipv6 addresses in compressed format' do + [ + '1080::8:800:200C:417A', + '1080::8:800:200C:417A/60', + 'FF01::101', + '::1', + '::', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + 'nope', + '127.0.0.1', + 'FEDC::BA98:7654:3210::3210', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/ip_address_v6_full_spec.rb b/spec/type_aliases/ip_address_v6_full_spec.rb new file mode 100644 index 000000000..cc8013d87 --- /dev/null +++ b/spec/type_aliases/ip_address_v6_full_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address::V6::Full' do + describe 'accepts ipv6 addresses in full format' do + [ + 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', + 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/60', + '1080:0:0:0:8:800:200C:417A', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + 'nope', + '127.0.0.1', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/ip_address_v6_nosubnet_alternative_spec.rb b/spec/type_aliases/ip_address_v6_nosubnet_alternative_spec.rb new file mode 100644 index 000000000..0b36cb9ca --- /dev/null +++ b/spec/type_aliases/ip_address_v6_nosubnet_alternative_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address::V6::Nosubnet::Alternative' do + describe 'accepts ipv6 addresses in alternative format without subnets' do + [ + '0:0:0:0:0:0:13.1.68.3', + '0:0:0:0:0:FFFF:129.144.52.38', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + '0:0:0:0:0:FFFF:129.144.52.38/60', + 'nope', + '127.0.0.1', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/ip_address_v6_nosubnet_compressed_spec.rb b/spec/type_aliases/ip_address_v6_nosubnet_compressed_spec.rb new file mode 100644 index 000000000..96af0354c --- /dev/null +++ b/spec/type_aliases/ip_address_v6_nosubnet_compressed_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address::V6::Nosubnet::Compressed' do + describe 'accepts ipv6 addresses in compressed format without subnets' do + [ + '1080::8:800:200C:417A', + 'FF01::101', + '::1', + '::', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + '1080::8:800:200C:417A/60', + 'nope', + '127.0.0.1', + 'FEDC::BA98:7654:3210::3210', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/ip_address_v6_nosubnet_full_spec.rb b/spec/type_aliases/ip_address_v6_nosubnet_full_spec.rb new file mode 100644 index 000000000..9135e002d --- /dev/null +++ b/spec/type_aliases/ip_address_v6_nosubnet_full_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address::V6::Nosubnet::Full' do + describe 'accepts ipv6 addresses in full format without subnets' do + [ + 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', + '1080:0:0:0:8:800:200C:417A', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210/60', + 'nope', + '127.0.0.1', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/spec/type_aliases/ip_address_v6_spec.rb b/spec/type_aliases/ip_address_v6_spec.rb new file mode 100644 index 000000000..864c56538 --- /dev/null +++ b/spec/type_aliases/ip_address_v6_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 + describe 'Stdlib::IP::Address::V6' do + describe 'accepts ipv6 addresses' do + [ + 'FEDC:BA98:7654:3210:FEDC:BA98:7654:3210', + 'FF01:0:0:0:0:0:0:101', + 'FF01::101', + 'FF01:0:0:0:0:0:0:101/32', + 'FF01::101/60', + '::', + '12AB::CD30:192.168.0.1', + ].each do |value| + describe value.inspect do + it { is_expected.to allow_value(value) } + end + end + end + + describe 'rejects other values' do + [ + '127.0.0.1', + '10.1.240.4/24', + ].each do |value| + describe value.inspect do + it { is_expected.not_to allow_value(value) } + end + end + end + end +end diff --git a/types/ip/address.pp b/types/ip/address.pp new file mode 100644 index 000000000..4c5c05ca8 --- /dev/null +++ b/types/ip/address.pp @@ -0,0 +1,4 @@ +type Stdlib::IP::Address = Variant[ + Stdlib::IP::Address::V4, + Stdlib::IP::Address::V6, +] diff --git a/types/ip/address/nosubnet.pp b/types/ip/address/nosubnet.pp new file mode 100644 index 000000000..4b7d16dc3 --- /dev/null +++ b/types/ip/address/nosubnet.pp @@ -0,0 +1,4 @@ +type Stdlib::IP::Address::Nosubnet = Variant[ + Stdlib::IP::Address::V4::Nosubnet, + Stdlib::IP::Address::V6::Nosubnet, +] diff --git a/types/ip/address/v4.pp b/types/ip/address/v4.pp new file mode 100644 index 000000000..5670dfed6 --- /dev/null +++ b/types/ip/address/v4.pp @@ -0,0 +1,4 @@ +type Stdlib::IP::Address::V4 = Variant[ + Stdlib::IP::Address::V4::CIDR, + Stdlib::IP::Address::V4::Nosubnet, +] diff --git a/types/ip/address/v4/cidr.pp b/types/ip/address/v4/cidr.pp new file mode 100644 index 000000000..49aded6dc --- /dev/null +++ b/types/ip/address/v4/cidr.pp @@ -0,0 +1 @@ +type Stdlib::IP::Address::V4::CIDR = Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\/([1-9]|[12][0-9]|3[0-2])?\z/] diff --git a/types/ip/address/v4/nosubnet.pp b/types/ip/address/v4/nosubnet.pp new file mode 100644 index 000000000..ba0cf3183 --- /dev/null +++ b/types/ip/address/v4/nosubnet.pp @@ -0,0 +1 @@ +type Stdlib::IP::Address::V4::Nosubnet = Pattern[/\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/] diff --git a/types/ip/address/v6.pp b/types/ip/address/v6.pp new file mode 100644 index 000000000..96c100f12 --- /dev/null +++ b/types/ip/address/v6.pp @@ -0,0 +1,6 @@ +type Stdlib::IP::Address::V6 = Variant[ + Stdlib::IP::Address::V6::Full, + Stdlib::IP::Address::V6::Compressed, + Stdlib::IP::Address::V6::Alternative, + Stdlib::IP::Address::V6::Nosubnet, +] diff --git a/types/ip/address/v6/alternative.pp b/types/ip/address/v6/alternative.pp new file mode 100644 index 000000000..f07c826fd --- /dev/null +++ b/types/ip/address/v6/alternative.pp @@ -0,0 +1,9 @@ +type Stdlib::IP::Address::V6::Alternative = Pattern[ + /\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, +] diff --git a/types/ip/address/v6/compressed.pp b/types/ip/address/v6/compressed.pp new file mode 100644 index 000000000..ebaed5848 --- /dev/null +++ b/types/ip/address/v6/compressed.pp @@ -0,0 +1,10 @@ +type Stdlib::IP::Address::V6::Compressed = Pattern[ + /\A:(:|(:[[:xdigit:]]{1,4}){1,7})(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, + /\A([[:xdigit:]]{1,4}:){7}:(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/, +] diff --git a/types/ip/address/v6/full.pp b/types/ip/address/v6/full.pp new file mode 100644 index 000000000..7cbb9810a --- /dev/null +++ b/types/ip/address/v6/full.pp @@ -0,0 +1 @@ +type Stdlib::IP::Address::V6::Full = Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}(\/(1([01][0-9]|[2][0-8])|[1-9][0-9]|[1-9]))?\z/] diff --git a/types/ip/address/v6/nosubnet.pp b/types/ip/address/v6/nosubnet.pp new file mode 100644 index 000000000..94b8c50f5 --- /dev/null +++ b/types/ip/address/v6/nosubnet.pp @@ -0,0 +1,5 @@ +type Stdlib::IP::Address::V6::Nosubnet = Variant[ + Stdlib::IP::Address::V6::Nosubnet::Full, + Stdlib::IP::Address::V6::Nosubnet::Compressed, + Stdlib::IP::Address::V6::Nosubnet::Alternative, +] diff --git a/types/ip/address/v6/nosubnet/alternative.pp b/types/ip/address/v6/nosubnet/alternative.pp new file mode 100644 index 000000000..48b0ef957 --- /dev/null +++ b/types/ip/address/v6/nosubnet/alternative.pp @@ -0,0 +1,9 @@ +type Stdlib::IP::Address::V6::Nosubnet::Alternative = Pattern[ + /\A([[:xdigit:]]{1,4}:){6}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, + /\A([[:xdigit:]]{1,4}:){5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, + /\A([[:xdigit:]]{1,4}:){4}(:[[:xdigit:]]{1,4}){0,1}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, + /\A([[:xdigit:]]{1,4}:){3}(:[[:xdigit:]]{1,4}){0,2}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, + /\A([[:xdigit:]]{1,4}:){2}(:[[:xdigit:]]{1,4}){0,3}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, + /\A([[:xdigit:]]{1,4}:){1}(:[[:xdigit:]]{1,4}){0,4}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, + /\A:(:[[:xdigit:]]{1,4}){0,5}:([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z/, +] diff --git a/types/ip/address/v6/nosubnet/compressed.pp b/types/ip/address/v6/nosubnet/compressed.pp new file mode 100644 index 000000000..c06a2746e --- /dev/null +++ b/types/ip/address/v6/nosubnet/compressed.pp @@ -0,0 +1,10 @@ +type Stdlib::IP::Address::V6::Nosubnet::Compressed = Pattern[ + /\A:(:|(:[[:xdigit:]]{1,4}){1,7})\z/, + /\A([[:xdigit:]]{1,4}:){1}(:|(:[[:xdigit:]]{1,4}){1,6})\z/, + /\A([[:xdigit:]]{1,4}:){2}(:|(:[[:xdigit:]]{1,4}){1,5})\z/, + /\A([[:xdigit:]]{1,4}:){3}(:|(:[[:xdigit:]]{1,4}){1,4})\z/, + /\A([[:xdigit:]]{1,4}:){4}(:|(:[[:xdigit:]]{1,4}){1,3})\z/, + /\A([[:xdigit:]]{1,4}:){5}(:|(:[[:xdigit:]]{1,4}){1,2})\z/, + /\A([[:xdigit:]]{1,4}:){6}(:|(:[[:xdigit:]]{1,4}){1,1})\z/, + /\A([[:xdigit:]]{1,4}:){7}:\z/, +] diff --git a/types/ip/address/v6/nosubnet/full.pp b/types/ip/address/v6/nosubnet/full.pp new file mode 100644 index 000000000..22ba1bed3 --- /dev/null +++ b/types/ip/address/v6/nosubnet/full.pp @@ -0,0 +1 @@ +type Stdlib::IP::Address::V6::Nosubnet::Full = Pattern[/\A[[:xdigit:]]{1,4}(:[[:xdigit:]]{1,4}){7}\z/]