@@ -687,6 +687,20 @@ def self.validate_input(is, should)
687
687
end
688
688
# Log prefix size is limited
689
689
raise 'Parameter `nflog_prefix`` must be less than 64 characters' if should [ :nflog_prefix ] && should [ :nflog_prefix ] . length > 64
690
+
691
+ [ :dst_range , :src_range ] . each do |key |
692
+ next unless should [ key ]
693
+ matches = %r{^([^\- \/ ]+)-([^\- \/ ]+)$} . match ( should [ key ] )
694
+ raise ( ArgumentError , "The IP range must be in 'IP1-IP2' format." ) unless matches
695
+
696
+ [ matches [ 1 ] , matches [ 2 ] ] . each do |addr |
697
+ begin # rubocop:disable Style/RedundantBegin
698
+ PuppetX ::Firewall ::Utility . host_to_ip ( addr )
699
+ rescue StandardError
700
+ raise ( "Invalid IP address \" #{ addr } \" in range \" #{ should [ key ] } \" " )
701
+ end
702
+ end
703
+ end
690
704
end
691
705
692
706
# Certain attributes need processed in ways that can vary between IPv4 and IPv6
@@ -917,7 +931,7 @@ def insync?(context, _name, property_name, is_hash, should_hash)
917
931
is = is_hash [ property_name ]
918
932
should = should_hash [ property_name ]
919
933
920
- should = 'IPv4' if should == 'iptables'
934
+ is = 'IPv4' if is == 'iptables'
921
935
should = 'IPv6' if should == 'ip6tables'
922
936
923
937
is == should
@@ -1015,6 +1029,12 @@ def insync?(context, _name, property_name, is_hash, should_hash)
1015
1029
# Range can be passed as `-` but will always be set/returned as `:`
1016
1030
is_hash [ property_name ] == should_hash [ property_name ] . gsub ( %r{-} , ':' ) if should_hash [ property_name ] . is_a? ( String )
1017
1031
is_hash [ property_name ] == should_hash [ property_name ] . map { |port | port . to_s . gsub ( %r{-} , ':' ) } if should_hash [ property_name ] . is_a? ( Array )
1032
+ when :string_hex
1033
+ # Compare the values with any whitespace removed
1034
+ is = is_hash [ property_name ] . to_s . gsub ( %r{\s +} , '' )
1035
+ should = should_hash [ property_name ] . to_s . gsub ( %r{\s +} , '' )
1036
+
1037
+ is == should
1018
1038
else
1019
1039
# Ensure that if both values are arrays, that they are sorted prior to comparison
1020
1040
return nil unless is_hash [ property_name ] . is_a? ( Array ) && should_hash [ property_name ] . is_a? ( Array )
0 commit comments