Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing ICMP types. #1218

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puppet_x/puppetlabs/firewall/utility.rb
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ def self.host_to_mask(value, proto)

# Translate the symbolic names for icmp packet types to integers
def self.icmp_name_to_number(value_icmp, protocol)
if value_icmp.to_s.match?(%r{^\d+$})
if value_icmp.to_s.match?(%r{^(\d+|\d+\/\d+)$})
value_icmp.to_s
elsif ['IPv4', 'iptables'].include?(protocol)
# https://www.iana.org/assignments/icmp-parameters/icmp-parameters.xhtml
7 changes: 7 additions & 0 deletions spec/acceptance/rules_spec.rb
Original file line number Diff line number Diff line change
@@ -194,6 +194,12 @@ class { 'firewall': }
icmp => 'time-exceeded',
jump => 'ACCEPT',
}
firewall { '014 icmp destination-unreachable/fragmentation-needed':
proto => 'icmp',
icmp => '3/4',
jump => 'ACCEPT',
}
firewall { '443 ssl on aliased interface':
proto => 'tcp',
dport => '443',
@@ -260,6 +266,7 @@ class { 'firewall': }
%r{-A INPUT -p (icmp|1) -m icmp --icmp-type 3 -m comment --comment "013 icmp destination-unreachable" -j ACCEPT},
%r{-A INPUT -s 10.0.0.0/(8|255\.0\.0\.0) -p (icmp|1) -m icmp --icmp-type 8 -m comment --comment "013 icmp echo-request" -j ACCEPT},
%r{-A INPUT -p (icmp|1) -m icmp --icmp-type 11 -m comment --comment "013 icmp time-exceeded" -j ACCEPT},
%r{-A INPUT -p (icmp|1) -m icmp --icmp-type 3/4 -m comment --comment "014 icmp destination-unreachable/fragmentation-needed" -j ACCEPT},
%r{-A INPUT -p (tcp|6) -m tcp --dport 22 -m conntrack --ctstate NEW -m comment --comment "020 ssh" -j ACCEPT},
%r{-A INPUT -i eth0:3 -p (tcp|6) -m tcp --dport 443 -m conntrack --ctstate NEW -m comment --comment "443 ssl on aliased interface" -j ACCEPT},
%r{-A INPUT -m comment --comment "900 LOCAL_INPUT" -j LOCAL_INPUT},
1 change: 1 addition & 0 deletions spec/unit/puppet_x/puppetlabs/firewall/utility_spec.rb
Original file line number Diff line number Diff line change
@@ -143,6 +143,7 @@
it { expect(utility.icmp_name_to_number('timestamp-reply', proto)).to eql '14' }
it { expect(utility.icmp_name_to_number('address-mask-request', proto)).to eql '17' }
it { expect(utility.icmp_name_to_number('address-mask-reply', proto)).to eql '18' }
it { expect(utility.icmp_name_to_number('3/4', proto)).to eql '3/4' }
end

context 'with proto IPv6' do