aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkBite <kilian.engelhardt@godaddy.com>2021-02-16 16:38:38 +0100
committerGitHub <noreply@github.com>2021-02-16 16:38:38 +0100
commit7ae636c87145c4fc8a23c1face61720dd394403b (patch)
treefd3d59f4e260a3907c02f74400c87a1593e091ba
parente22b12852d840869edb75ba1fbf767af75ba1b6d (diff)
parent78f059837a97186bf6843b44fdc74abff48f7ad4 (diff)
downloadpuppet-ferm-7ae636c87145c4fc8a23c1face61720dd394403b.tar.gz
puppet-ferm-7ae636c87145c4fc8a23c1face61720dd394403b.tar.bz2
Merge pull request #121 from kBite/allow-integer-protocols
Allow numeric values as protocol references
-rw-r--r--manifests/rule.pp5
-rw-r--r--spec/type_aliases/protocols_spec.rb4
-rw-r--r--types/protocols.pp2
3 files changed, 9 insertions, 2 deletions
diff --git a/manifests/rule.pp b/manifests/rule.pp
index 611e604..49d5292 100644
--- a/manifests/rule.pp
+++ b/manifests/rule.pp
@@ -89,8 +89,9 @@ define ferm::rule (
}
$proto_real = $proto ? {
- Array => "proto (${join($proto, ' ')})",
- String => "proto ${proto}",
+ Array => "proto (${join($proto, ' ')})",
+ String => "proto ${proto}",
+ Integer => "proto ${proto}",
}
if $dport =~ Array {
diff --git a/spec/type_aliases/protocols_spec.rb b/spec/type_aliases/protocols_spec.rb
index a067b69..b13b7b2 100644
--- a/spec/type_aliases/protocols_spec.rb
+++ b/spec/type_aliases/protocols_spec.rb
@@ -15,6 +15,8 @@ describe 'Ferm::Protocols' do
'mh',
'all',
['icmp', 'tcp', 'udp'],
+ 0,
+ [0, 4],
].each do |value|
describe value.inspect do
it { is_expected.to allow_value(value) }
@@ -36,6 +38,8 @@ describe 'Ferm::Protocols' do
[95_000, 67_000],
{},
{ 'foo' => 'bar' },
+ 256,
+ ['icmp', 256],
].each do |value|
describe value.inspect do
it { is_expected.not_to allow_value(value) }
diff --git a/types/protocols.pp b/types/protocols.pp
index cdd76b2..1c11159 100644
--- a/types/protocols.pp
+++ b/types/protocols.pp
@@ -1,5 +1,7 @@
# @summary a list of allowed protocolls to match
type Ferm::Protocols = Variant[
+ Integer[0, 255],
+ Array[Integer[0, 255]],
Enum['icmp', 'tcp', 'udp', 'udplite', 'icmpv6', 'esp', 'ah', 'sctp', 'mh', 'all'],
Array[Enum['icmp', 'tcp', 'udp', 'udplite', 'icmpv6', 'esp', 'ah', 'sctp', 'mh', 'all']],
]