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

Implemented profile selection #96

Open
wants to merge 2 commits into
base: master
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
11 changes: 10 additions & 1 deletion manifests/exception.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]',
# }
Expand Down Expand Up @@ -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
Expand All @@ -104,6 +109,10 @@
}
}

if $profile {
$profile_list = join($profile,',')
}

if $protocol =~ /^ICMPv(4|6)/ {
$allow_context = "protocol=${protocol}"
} else {
Expand Down Expand Up @@ -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}":
Expand Down