| 1 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # (c) Jan Gehring <jan.gehring@gmail.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package Rex::Resource::firewall::Provider::iptables; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use v5.14.4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | our $VERSION = '1.16.1'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Rex::Commands::Iptables; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Rex::Helper::Run; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use base qw(Rex::Resource::firewall::Provider::base); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $that = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | my $proto = ref($that) || $that; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table0%0/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my $self = $proto->SUPER::new(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | bless( $self, $proto ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub present { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
present: not called CC=26 SCAR=65.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ( $self, $rule_config ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my @iptables_rule = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | $rule_config->{dport} ||= $rule_config->{port}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$rule_config->{"dport"} ||= $rule_config->{"port"}
MC/DC0%0/2
$rule_config->{"dport"} ||= $rule_config->{"port"}
$rule_config->{"dport"}
$rule_config->{"port"}
Truth table0%0/3
A ||= B
A= $rule_config->{"dport"}B= $rule_config->{"port"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | $rule_config->{proto} ||= 'tcp'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rule_config->{"proto"} ||= "tcp"
MC/DC0%0/1
$rule_config->{"proto"} ||= "tcp"
$rule_config->{"proto"}
Truth table0%0/2
A
A= $rule_config->{"proto"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $rule_config->{chain} ||= 'INPUT'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rule_config->{"chain"} ||= "INPUT"
MC/DC0%0/1
$rule_config->{"chain"} ||= "INPUT"
$rule_config->{"chain"}
Truth table0%0/2
A
A= $rule_config->{"chain"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $rule_config->{ip_version} ||= -4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rule_config->{"ip_version"} ||= -4
MC/DC0%0/1
$rule_config->{"ip_version"} ||= -4
$rule_config->{"ip_version"}
Truth table0%0/2
A
A= $rule_config->{"ip_version"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ( $rule_config->{source} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$rule_config->{"source"} and not $rule_config->{"source"} =~ m[/(\d+)$]u and $self->_version->[0] >= 1 and $self->_version->[1] >= 4
$rule_config->{"source"} and not $rule_config->{"source"} =~ m[/(\d+)$]u and $self->_version->[0] >= 1
$rule_config->{"source"} and not $rule_config->{"source"} =~ m[/(\d+)$]u
MC/DC0%0/4
$rule_config->{"source"} and not $rule_config->{"source"} =~ m[/(\d+)$]u and $self->_version->[0] >= 1 and $self->_version->[1] >= 4
$rule_config->{"source"}
not $rule_config->{"source"} =~ m[/(\d+)$]u
$self->_version->[0] >= 1
$self->_version->[1] >= 4
Truth table0%0/5
A and not(B) and C and D
A= $rule_config->{"source"}B= not $rule_config->{"source"} =~ m[/(\d+)$]uC= $self->_version->[0] >= 1D= $self->_version->[1] >= 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | && $rule_config->{source} !~ m/\/(\d+)$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | && $self->_version()->[0] >= 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | && $self->_version()->[1] >= 4 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $rule_config->{source} .= "/32"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | push( @iptables_rule, t => $rule_config->{table} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | if ( defined $rule_config->{table} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | push( @iptables_rule, A => uc( $rule_config->{chain} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if ( defined $rule_config->{chain} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | push( @iptables_rule, p => $rule_config->{proto} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ( defined $rule_config->{proto} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | push( @iptables_rule, m => $rule_config->{proto} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if ( defined $rule_config->{proto} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | push( @iptables_rule, s => $rule_config->{source} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ( defined $rule_config->{source} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | push( @iptables_rule, d => $rule_config->{destination} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if ( defined $rule_config->{destination} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | push( @iptables_rule, sport => $rule_config->{sport} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if ( defined $rule_config->{sport} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | push( @iptables_rule, dport => $rule_config->{dport} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ( defined $rule_config->{dport} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | push( @iptables_rule, "tcp-flags" => $rule_config->{tcp_flags} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if ( defined $rule_config->{tcp_flags} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | push( @iptables_rule, "i" => $rule_config->{iniface} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ( defined $rule_config->{iniface} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | push( @iptables_rule, "o" => $rule_config->{outiface} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ( defined $rule_config->{outiface} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | push( @iptables_rule, "reject-with" => $rule_config->{reject_with} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ( defined $rule_config->{reject_with} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | push( @iptables_rule, "log-level" => $rule_config->{log_level} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ( defined $rule_config->{log_level} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | push( @iptables_rule, "log-prefix" => $rule_config->{log_prefix} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ( defined $rule_config->{log_prefix} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | push( @iptables_rule, "state" => $rule_config->{state} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ( defined $rule_config->{state} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | push( @iptables_rule, j => uc( $rule_config->{action} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if ( defined $rule_config->{action} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | !Rex::Commands::Iptables::_rule_exists( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | $rule_config->{ip_version}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | @iptables_rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | iptables( $rule_config->{ip_version}, @iptables_rule ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub absent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
absent: not called CC=26 SCAR=65.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my ( $self, $rule_config ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my @iptables_rule = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $rule_config->{dport} ||= $rule_config->{port}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$rule_config->{"dport"} ||= $rule_config->{"port"}
MC/DC0%0/2
$rule_config->{"dport"} ||= $rule_config->{"port"}
$rule_config->{"dport"}
$rule_config->{"port"}
Truth table0%0/3
A ||= B
A= $rule_config->{"dport"}B= $rule_config->{"port"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $rule_config->{proto} ||= 'tcp'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rule_config->{"proto"} ||= "tcp"
MC/DC0%0/1
$rule_config->{"proto"} ||= "tcp"
$rule_config->{"proto"}
Truth table0%0/2
A
A= $rule_config->{"proto"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $rule_config->{chain} ||= 'INPUT'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rule_config->{"chain"} ||= "INPUT"
MC/DC0%0/1
$rule_config->{"chain"} ||= "INPUT"
$rule_config->{"chain"}
Truth table0%0/2
A
A= $rule_config->{"chain"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | $rule_config->{ip_version} ||= -4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$rule_config->{"ip_version"} ||= -4
MC/DC0%0/1
$rule_config->{"ip_version"} ||= -4
$rule_config->{"ip_version"}
Truth table0%0/2
A
A= $rule_config->{"ip_version"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | if ( $rule_config->{source} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$rule_config->{"source"} and not $rule_config->{"source"} =~ m[/(\d+)$]u and $self->_version->[0] >= 1 and $self->_version->[1] >= 4
$rule_config->{"source"} and not $rule_config->{"source"} =~ m[/(\d+)$]u and $self->_version->[0] >= 1
$rule_config->{"source"} and not $rule_config->{"source"} =~ m[/(\d+)$]u
MC/DC0%0/4
$rule_config->{"source"} and not $rule_config->{"source"} =~ m[/(\d+)$]u and $self->_version->[0] >= 1 and $self->_version->[1] >= 4
$rule_config->{"source"}
not $rule_config->{"source"} =~ m[/(\d+)$]u
$self->_version->[0] >= 1
$self->_version->[1] >= 4
Truth table0%0/5
A and not(B) and C and D
A= $rule_config->{"source"}B= not $rule_config->{"source"} =~ m[/(\d+)$]uC= $self->_version->[0] >= 1D= $self->_version->[1] >= 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | && $rule_config->{source} !~ m/\/(\d+)$/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | && $self->_version()->[0] >= 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | && $self->_version()->[1] >= 4 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $rule_config->{source} .= "/32"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | push( @iptables_rule, t => $rule_config->{table} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ( defined $rule_config->{table} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | push( @iptables_rule, D => uc( $rule_config->{chain} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( defined $rule_config->{chain} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | push( @iptables_rule, s => $rule_config->{source} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | if ( defined $rule_config->{source} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | push( @iptables_rule, p => $rule_config->{proto} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | if ( defined $rule_config->{proto} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | push( @iptables_rule, m => $rule_config->{proto} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if ( defined $rule_config->{proto} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | push( @iptables_rule, d => $rule_config->{destination} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if ( defined $rule_config->{destination} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | push( @iptables_rule, sport => $rule_config->{sport} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ( defined $rule_config->{sport} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | push( @iptables_rule, dport => $rule_config->{dport} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if ( defined $rule_config->{dport} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | push( @iptables_rule, "tcp-flags" => $rule_config->{tcp_flags} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if ( defined $rule_config->{tcp_flags} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | push( @iptables_rule, "i" => $rule_config->{iniface} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ( defined $rule_config->{iniface} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | push( @iptables_rule, "o" => $rule_config->{outiface} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ( defined $rule_config->{outiface} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | push( @iptables_rule, "reject-with" => $rule_config->{reject_with} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ( defined $rule_config->{reject_with} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | push( @iptables_rule, "log-level" => $rule_config->{log_level} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ( defined $rule_config->{log_level} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | push( @iptables_rule, "log-prefix" => $rule_config->{log_prefix} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if ( defined $rule_config->{log_prefix} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | push( @iptables_rule, "state" => $rule_config->{state} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if ( defined $rule_config->{state} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | push( @iptables_rule, j => uc( $rule_config->{action} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ( defined $rule_config->{action} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | Rex::Commands::Iptables::_rule_exists( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | $rule_config->{ip_version}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | @iptables_rule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | iptables( $rule_config->{ip_version}, @iptables_rule ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub _version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_version: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | if ( exists $self->{__version__} ) { return $self->{__version__} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $version = i_run "iptables --version", fail_ok => 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $version =~ s/^.*\sv(\d+\.\d+\.\d+)/$1/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->{__version__} = [ split( /\./, $version ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | Rex::Logger::debug( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | "Got iptables version: " . join( ", ", @{ $self->{__version__} } ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | return $self->{__version__}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||