Skip to content

Commit

Permalink
Merge pull request #181 from vinzent/119_validate_port_params
Browse files Browse the repository at this point in the history
(GH-119) Don't accept udp6 and tcp6 as protocol name with selinux::port
  • Loading branch information
bastelfreak authored Jan 17, 2017
2 parents 691cc28 + a25d44d commit 75dfc59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion manifests/port.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
Selinux::Port[$title] ->
Anchor['selinux::end']

validate_re("${port}", '^[0-9]+(-[0-9]+)?$') # lint:ignore:only_variable_string

if $protocol {
validate_re($protocol, ['^tcp6?$', '^udp6?$'])
validate_re($protocol, ['^tcp$', '^udp$'])
$protocol_switch = ['-p', $protocol]
$protocol_check = "${protocol} "
$port_exec_command = "add_${context}_${port}_${protocol}"
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/selinux_port_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
it { is_expected.to contain_selinux__port('myapp').that_comes_before('Anchor[selinux::end]') }
end

%w(tcp udp tcp6 udp6).each do |protocol|
%w(tcp udp).each do |protocol|
context "valid protocol #{protocol}" do
let(:params) do
{
Expand Down

0 comments on commit 75dfc59

Please sign in to comment.