From 24bd86bf5ce702e961c7795579f682ecfd2879c4 Mon Sep 17 00:00:00 2001 From: gmiranda Date: Tue, 10 Dec 2019 08:43:37 +0100 Subject: [PATCH 1/2] Implemented profile selection --- manifests/exception.pp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/manifests/exception.pp b/manifests/exception.pp index 966a70c..be2fe41 100644 --- a/manifests/exception.pp +++ b/manifests/exception.pp @@ -46,6 +46,9 @@ # [*allow_edge_traversal*] # Specifies that the traffic for this exception traverses an edge device # +# [*profile*] +# Specifies that this exception applies only to the selected network profile(s) +# # === Examples # # Exception for protocol/port: @@ -60,6 +63,7 @@ # remote_port => 'any', # remote_ip => '10.0.0.1,10.0.0.2' # program => undef, +# profile => 'public' # display_name => 'Windows Remote Management HTTP-In', # description => 'Inbound rule for Windows Remote Management via WS-Management. [TCP 5985]', # } @@ -89,6 +93,7 @@ String[0, 255] $display_name = '', String $description = '', Boolean $allow_edge_traversal = false, + Optional[Variant[Enum['public', 'private', 'domain'], Array[Enum['public', 'private', 'domain']]]] $profile = ['private', 'public', 'domain'], ) { # Check if we're allowing a program or port/protocol and validate accordingly @@ -104,6 +109,10 @@ } } + if $profile { + $profile_list = join($profile,",") + } + if $protocol =~ /^ICMPv(4|6)/ { $allow_context = "protocol=${protocol}" } else { @@ -160,7 +169,7 @@ if $fw_action == 'delete' and $program == undef { $netsh_command = "${netsh_exe} advfirewall firewall ${fw_action} rule name=\"${display_name}\" ${fw_description} dir=${direction} ${allow_context} remoteip=\"${remote_ip}\"" } else { - $netsh_command = "${netsh_exe} advfirewall firewall ${fw_action} rule name=\"${display_name}\" ${fw_description} dir=${direction} action=${action} enable=${mode} edge=${edge} ${allow_context} remoteip=\"${remote_ip}\"" + $netsh_command = "${netsh_exe} advfirewall firewall ${fw_action} rule name=\"${display_name}\" ${fw_description} dir=${direction} action=${action} enable=${mode} edge=${edge} ${allow_context} remoteip=\"${remote_ip}\" profile=\"${profile_list}\"" } # exec { "set rule ${display_name}": From 891264b2fc3302f1d9fee63b9846ab56b4cac9c8 Mon Sep 17 00:00:00 2001 From: gmiranda Date: Thu, 30 Jul 2020 22:54:44 +0200 Subject: [PATCH 2/2] Replaced double quote by single quote Should fix Travis CI checks --- manifests/exception.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/exception.pp b/manifests/exception.pp index be2fe41..632a4de 100644 --- a/manifests/exception.pp +++ b/manifests/exception.pp @@ -110,7 +110,7 @@ } if $profile { - $profile_list = join($profile,",") + $profile_list = join($profile,',') } if $protocol =~ /^ICMPv(4|6)/ {