From 9bab17305fbd94c4289a9dca972b13b2f6e2d829 Mon Sep 17 00:00:00 2001 From: Nate Potter Date: Mon, 17 Oct 2016 14:32:04 -0700 Subject: [PATCH 1/2] (MODULES-3980) Fix ipv4 regex validator The current pattern for stdlib::compat::ipv4 is incorrect, and will return true for any four numbers separated with periods. This commit improves the regex to validate that the IP octets are between 1 and 255. --- spec/aliases/ipv4_spec.rb | 2 ++ types/compat/ipv4.pp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/aliases/ipv4_spec.rb b/spec/aliases/ipv4_spec.rb index e767b45b8..f9022a411 100644 --- a/spec/aliases/ipv4_spec.rb +++ b/spec/aliases/ipv4_spec.rb @@ -20,6 +20,8 @@ 'nope', '77', '4.4.4', + '9999.9999.9999.9999', + '192.168.256.1', '2001:0db8:85a3:0000:0000:8a2e:0370:73342001:0db8:85a3:0000:0000:8a2e:0370:7334' ].each do |value| describe value.inspect do diff --git a/types/compat/ipv4.pp b/types/compat/ipv4.pp index 1d72ebd09..c0ddbfed9 100644 --- a/types/compat/ipv4.pp +++ b/types/compat/ipv4.pp @@ -1,2 +1,2 @@ # Emulate the validate_ipv4_address and is_ipv4_address functions -type Stdlib::Compat::Ipv4 = Pattern[/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/] +type Stdlib::Compat::Ipv4 = Pattern[/^(([0-9](?!\d)|[1-9][0-9](?!\d)|1[0-9]{2}(?!\d)|2[0-4][0-9](?!\d)|25[0-5](?!\d))[.]?){4}$/] From 8ef45bfc33eae887daea98b44b477854ece08468 Mon Sep 17 00:00:00 2001 From: Nate Potter Date: Tue, 18 Oct 2016 10:16:40 -0700 Subject: [PATCH 2/2] Use parallel_tests 2.9.0 for ruby < 2.0.0 Parallel_tests 2.10.0 requires ruby >= 2.0.0, so for jobs with ruby < 2.0.0 parallel_tests 2.9.0 should be used. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 0a7542d09..e4ed0cd65 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ group :development, :unit_tests do gem 'mocha', '< 1.2.0' gem 'rspec-puppet-facts' gem 'simplecov' - gem 'parallel_tests' + gem 'parallel_tests', '2.9.0' if RUBY_VERSION < '2.0.0' gem 'rubocop', '0.41.2' if RUBY_VERSION < '2.0.0' gem 'rubocop' if RUBY_VERSION >= '2.0.0' gem 'rubocop-rspec', '~> 1.6' if RUBY_VERSION >= '2.3.0'