Skip to content

Commit

Permalink
Fix firewalld_custom_service port validation
Browse files Browse the repository at this point in the history
Fixes #283
  • Loading branch information
alexjfisher committed Apr 23, 2020
1 parent 5df4c2e commit f32947c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/puppet/type/firewalld_custom_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
port_regexp = Regexp.new('^\d+(-\d+)?$')
raise Puppet::ParseError, "Ports must match #{port_regexp}" unless port_regexp.match?(test_value)

invalid_ports = test_value.split('-').select { |x| (x == '0') || (x > '65535') }
invalid_ports = test_value.split('-').select { |x| (x.to_i < 1) || (x.to_i > 65535) }
raise Puppet::ParseError, %(Ports must be between 1-65535 instead of '#{invalid_ports.join("' ,'")}') unless invalid_ports.empty?
end

Expand Down
3 changes: 3 additions & 0 deletions spec/unit/puppet/type/firewalld_custom_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
'1234/udp',
'1234/sctp',
'1234/dccp',
'9169/tcp',
'1/tcp',
'65535/tcp',
'tcp',
{ 'protocol' => 'tcp' },
{ 'port' => 1234, 'protocol' => 'tcp' },
Expand Down

0 comments on commit f32947c

Please sign in to comment.