Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This file is used to list changes made in each version of the firewall cookbook.

## Unreleased

fix port sorting in generated firewall rules file
Added support for firewalld zone attribute

## 6.3.4 - *2023-12-21*
Expand Down
2 changes: 1 addition & 1 deletion libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def port_to_s(p)
p.to_s
elsif p && p.is_a?(Array)
p_strings = p.map { |o| port_to_s(o) }
p_strings.sort.join(',')
p_strings.sort_by { |s| s.scan(/\d+/).first.to_i }.join(',')
elsif p && p.is_a?(Range)
if platform_family?('windows')
"#{p.first}-#{p.last}"
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/cookbooks/firewall-test/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,9 @@
command :allow
end

firewall_rule 'FreeIPA ports' do
port %w(80 88 389 443 464 636)
source '10.10.10.10'
end

include_recipe 'firewall-test::windows' if windows?
10 changes: 10 additions & 0 deletions test/integration/ufw/inspec/ufw_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
%r{ 1000:1100/tcp + ALLOW IN +Anywhere},
%r{ 1234,5000:5100,5678/tcp + ALLOW IN +Anywhere},
%r{ 23/tcp + LIMIT IN +Anywhere},
%r{ 80,88,389,443,464,636/tcp + ALLOW IN +10\.10\.10\.10},
/# ssh22/,
]

Expand All @@ -28,3 +29,12 @@
its(:stdout) { should match(/Status: active/) }
end
end

describe file('/etc/default/ufw-chef.rules') do
it { should exist }
its(:size) { should > 0 }
its(:mode) { should cmp '0644' }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
its(:content) { should match /ufw allow in proto tcp to any port 80,88,389,443,464,636 from 10.10.10.10 comment "FreeIPA ports"/ }
end