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

firewall 7.0.0 compat #40

Merged
merged 8 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ jobs:
strategy:
matrix:
include:
- ruby: "2.4.4"
puppet: "~> 5.0"
- ruby: "2.4.4"
puppet: "~> 6.0"
- ruby: "2.7"
puppet: "~> 7.0"

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/firewall_multi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def firewall_multi(hash)
hash = explode(hash, "proto", "protocol")
hash = explode(hash, "icmp", "icmp type")
hash = explode(hash, "icmp", "icmp type")
hash = explode(hash, "provider", "using provider")
hash = explode(hash, "protocol", "using protocol")
hash
end
end
10 changes: 3 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
# @param [Array] destination An array of destination IPs or CIDRs.
# @param [Array] proto An array of protocols.
# @param [Array] icmp An array of ICMP types.
# @param [Array] provider An array of providers.
# @param [Array] protocol An array of protocols.
#
define firewall_multi (
$ensure = undef,
$provider = undef,
$action = undef,
$protocol = undef,
$burst = undef,
$bytecode = undef,
$cgroup = undef,
Expand Down Expand Up @@ -103,7 +102,6 @@
$physdev_is_out = undef,
$physdev_out = undef,
$pkttype = undef,
$port = undef,
$proto = undef,
$queue_bypass = undef,
$queue_num = undef,
Expand Down Expand Up @@ -158,8 +156,7 @@
{
$name => {
ensure => $ensure,
provider => $provider,
action => $action,
protocol => $protocol,
burst => $burst,
bytecode => $bytecode,
cgroup => $cgroup,
Expand Down Expand Up @@ -251,7 +248,6 @@
physdev_is_out => $physdev_is_out,
physdev_out => $physdev_out,
pkttype => $pkttype,
port => $port,
proto => $proto,
queue_bypass => $queue_bypass,
queue_num => $queue_num,
Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 3.0.0"
"version_requirement": ">= 7.0.0 < 9.0.0"
}
],
"dependencies": [
{
"name": "puppetlabs/firewall",
"version_requirement": ">= 2.8.0 <= 6.0.0"
"version_requirement": ">= 7.0.0 < 8.0.0"
}
]
}
2 changes: 1 addition & 1 deletion spec/acceptance/firewall_multi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
dport => [80, 443],
proto => tcp,
action => accept,
jump => accept,
}
CODE

Expand Down
64 changes: 32 additions & 32 deletions spec/defines/firewall_multi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
let(:title) { "00100 accept on port 80" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => sources,
Expand All @@ -39,7 +39,7 @@
is_expected.to contain_firewall(
"00100 accept on port 80 from #{source} to #{dest} icmp type #{icmp}"
).with(
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => source,
Expand All @@ -62,7 +62,7 @@
let(:title) { "00100 accept on port 80" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => sources,
Expand All @@ -75,7 +75,7 @@
is_expected.to contain_firewall(
"00100 accept on port 80 from #{source}"
).with(
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => source,
Expand All @@ -95,7 +95,7 @@
let(:title) { "00100 accept on port 80" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => sources
Expand All @@ -104,7 +104,7 @@

it {
is_expected.to contain_firewall("00100 accept on port 80 from #{source}").with(
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => source
Expand All @@ -121,7 +121,7 @@
let(:title) { "00100 accept on port 80" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"destination" => destinations
Expand All @@ -132,7 +132,7 @@
is_expected.to contain_firewall(
"00100 accept on port 80 to 4.4.4.4/24"
).with(
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"destination" => "4.4.4.4/24"
Expand All @@ -152,7 +152,7 @@
let(:title) { "00100 accept on port 80" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => source,
Expand All @@ -164,7 +164,7 @@
is_expected.to contain_firewall(
"00100 accept on port 80 to #{destination}"
).with(
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => source,
Expand All @@ -179,7 +179,7 @@
let(:title) { "00100 accept on port 53" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => "53",
"proto" => protocols
}
Expand All @@ -190,7 +190,7 @@
is_expected.to contain_firewall(
"00100 accept on port 53 protocol #{protocol}"
).with(
"action" => "accept",
"jump" => "accept",
"dport" => "53",
"proto" => protocol
)
Expand All @@ -206,7 +206,7 @@
{
"chain" => "OUTPUT",
"proto" => "icmp",
"action" => "accept",
"jump" => "accept",
"icmp" => icmps
}
end
Expand All @@ -218,7 +218,7 @@
).with(
"chain" => "OUTPUT",
"proto" => "icmp",
"action" => "accept",
"jump" => "accept",
"icmp" => icmp
)
}
Expand All @@ -233,7 +233,7 @@
{
"chain" => "OUTPUT",
"proto" => "icmp",
"action" => "accept",
"jump" => "accept",
"icmp" => icmps
}
end
Expand All @@ -242,7 +242,7 @@
is_expected.to contain_firewall("00100 accept output icmp type 8").with(
"chain" => "OUTPUT",
"proto" => "icmp",
"action" => "accept",
"jump" => "accept",
"icmp" => "8"
)
}
Expand All @@ -255,15 +255,15 @@
let(:title) { "00100 accept on port 80" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp"
}
end

it {
is_expected.to contain_firewall("00100 accept on port 80").with(
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp"
)
Expand All @@ -274,7 +274,7 @@
let(:title) { "00100 accept on port 80" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => nil
Expand All @@ -283,7 +283,7 @@

it {
is_expected.to contain_firewall("00100 accept on port 80").with(
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => "nil"
Expand All @@ -301,7 +301,7 @@
let(:title) { "00100 accept on port 80" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => sources,
Expand All @@ -313,7 +313,7 @@
is_expected.to contain_firewall(
"00100 accept on port 80 from 1.1.1.1/24"
).with(
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => "1.1.1.1/24",
Expand All @@ -322,31 +322,31 @@
}
end

context "when using two providers" do
providers = %w[
context "when using two protocols" do
protocols = %w[
iptables
ip6tables
]

let(:title) { "00100 accept on ports 80 and 443" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => %w[80 443],
"proto" => "tcp",
"provider" => providers
"protocol" => protocols
}
end

it {
providers.each do |provider|
protocols.each do |protocol|
is_expected.to contain_firewall(
"00100 accept on ports 80 and 443 using provider #{provider}"
"00100 accept on ports 80 and 443 using protocol #{protocol}"
).with(
"action" => "accept",
"jump" => "accept",
"dport" => %w[80 443],
"proto" => "tcp",
"provider" => provider
"protocol" => protocol
)
end
}
Expand All @@ -356,7 +356,7 @@
let(:title) { "00100 accept on port 80" }
let(:params) do
{
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => "1.1.1.1/24",
Expand All @@ -367,7 +367,7 @@

it {
is_expected.to contain_firewall("00100 accept on port 80").with(
"action" => "accept",
"jump" => "accept",
"dport" => "80",
"proto" => "tcp",
"source" => "1.1.1.1/24",
Expand Down
6 changes: 3 additions & 3 deletions spec/functions/firewall_multi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
context "when passed a hash" do
input = {
"00100 accept inbound ssh" => {
"action" => "accept",
"jump" => "accept",
"source" => ["1.1.1.1/24", "2.2.2.2/24"],
"dport" => 22
}
}

output = {
"00100 accept inbound ssh from 1.1.1.1/24" => {
"action" => "accept",
"jump" => "accept",
"source" => "1.1.1.1/24",
"dport" => 22
},
"00100 accept inbound ssh from 2.2.2.2/24" => {
"action" => "accept",
"jump" => "accept",
"source" => "2.2.2.2/24",
"dport" => 22
}
Expand Down
Loading