| 1 | package Langertha::Holmgang::Sim::Linux::Nft; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Evaluates the nftables ruleset of a simulated Linux device against a packet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 82 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 82 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 82 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 82 | ▶ | use Socket qw( inet_pton AF_INET AF_INET6 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 82 | our $VERSION = '0.001'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 82 | my %PRIO = ( raw => -300, mangle => -150, dstnat => -100, filter => 0, security => 50, srcnat => 100 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 82 | my %SERVICE = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ssh => 22, http => 80, https => 443, domain => 53, smtp => 25, submission => 587, submissions => 465, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | imap => 143, imaps => 993, pop3 => 110, pop3s => 995, ntp => 123, snmp => 161, ldap => 389, ldaps => 636, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 'http-alt' => 8080, mysql => 3306, postgresql => 5432, bgp => 179, telnet => 23, ftp => 21, rsync => 873, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 'openvpn' => 1194, 'sip' => 5060, 'syslog' => 514, 'bootps' => 67, 'bootpc' => 68, 'tftp' => 69, 'kerberos' => 88, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 'microsoft-ds' => 445, 'ms-wbt-server' => 3389, 'redis' => 6379, 'zabbix-agent' => 10050, ipp => 631, printer => 515, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | nfs => 2049, sunrpc => 111, 'netbios-ns' => 137, 'netbios-dgm' => 138, 'netbios-ssn' => 139, mdns => 5353, git => 9418, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 'domain-s' => 853, 'http-alt' => 8080, 'webcache' => 8080, 'xmpp-client' => 5222, 'mqtt' => 1883, 'ntp' => 123, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 82 | my %PROTO = ( tcp => 6, udp => 17, icmp => 1, icmpv6 => 58, ipv6icmp => 58, 'ipv6-icmp' => 58, gre => 47, esp => 50, ah => 51 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 82 | my %CTSTATUS = map { $_ => 1 } qw( expected seen-reply assured confirmed snat dnat dying ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 82 | my %CTSTATE = map { $_ => 1 } qw( new established related invalid untracked ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 82 | my %VERDICT = map { $_ => 1 } qw( accept drop reject continue return ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 82 | my %ICMP = map { $_ => 1 } qw( echo-request echo-reply destination-unreachable time-exceeded parameter-problem | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | source-quench redirect router-advertisement router-solicitation timestamp-request timestamp-reply | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | packet-too-big nd-router-solicit nd-router-advert nd-neighbor-solicit nd-neighbor-advert mld-listener-query | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | mld-listener-report mld-listener-done mld2-listener-report ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 82 | my %ICMPCODE = map { $_ => 1 } qw( net-unreachable host-unreachable prot-unreachable port-unreachable frag-needed | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | net-prohibited host-prohibited admin-prohibited no-route addr-unreachable reject-route policy-fail ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # --- Zerlegen -------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 141 | ▶ | sub _tokens { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tokens: called CC=9 SCAR=22.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 141 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 141 | my @t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 141 | pos($text) = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 141 | ▶ | while ( pos($text) < length $text ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1454 | ▶ | if ( $text =~ /\G\s+/gc ) { next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 41 | elsif ( $text =~ /\G"((?:[^"\\]|\\.)*)"/gc ) { push @t, { q => $1 } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 59 | elsif ( $text =~ /\G(!=|==|[{},;])/gc ) { push @t, $1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | elsif ( $text =~ /\G([^\s{},;"]+)/gc ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 717 | my $w = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # IPv6 bleibt ein Wort; "established : accept" bzw. "established:accept" (vmap) nicht | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 717 | ▶ | if ( $w eq ':' ) { push @t, ':' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | elsif ( $w =~ /\A([a-z][\w-]*):\z/ ) { push @t, $1, ':' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | elsif ( $w =~ /\A([a-z][\w-]*):([a-z][\w-]*)\z/ ) { push @t, $1, ':', $2 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 698 | else { push @t, $w } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | else { die "unerwartetes Zeichen\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 141 | return \@t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # Wert oder Menge { a, b } (mit vmap: { a : verdict, … }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 180 | ▶ | sub _value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_value: called CC=17 SCAR=28.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 180 | my ( $t, $map ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 180 | ▶ | my $x = shift @$t // die "Wert fehlt\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @$t // die("Wert fehlt\n")
MC/DC0%0/1
shift @$t // die("Wert fehlt\n")
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 180 | ▶ | if ( !ref $x && $x eq '{' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not ref $x and $x eq "{"
MC/DC100%2/2
not ref $x and $x eq "{"
not ref $x
$x eq "{"
Truth table100%3/3
not(A) and B
A= not ref $xB= $x eq "{"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 14 | my @items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 14 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 62 | ▶ | my $y = shift @$t // die "} fehlt\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @$t // die("} fehlt\n")
MC/DC0%0/1
shift @$t // die("} fehlt\n")
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 62 | ▶ | last if !ref $y && $y eq '}'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not ref $y and $y eq "}"
MC/DC100%2/2
not ref $y and $y eq "}"
not ref $y
$y eq "}"
Truth table100%3/3
not(A) and B
A= not ref $yB= $y eq "}"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 48 | ▶ | next if !ref $y && $y eq ','; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not ref $y and $y eq ","
MC/DC100%2/2
not ref $y and $y eq ","
not ref $y
$y eq ","
Truth table100%3/3
not(A) and B
A= not ref $yB= $y eq ","
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 31 | ▶ | my $v = ref $y ? $y->{q} : $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 31 | ▶ | if ($map) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 19 | my $c = shift @$t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 19 | ▶ | die "vmap ohne :\n" unless defined $c && !ref $c && $c eq ':'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $c and not ref $c and $c eq ":"
defined $c and not ref $c
MC/DC0%0/3
defined $c and not ref $c and $c eq ":"
defined $c
not ref $c
$c eq ":"
Truth table25%1/4
A and not(B) and C
A= defined $cB= not ref $cC= $c eq ":"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 19 | my $verd = _verdict_tokens($t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 19 | push @items, [ $v, $verd ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 12 | else { push @items, $v } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 14 | return { set => \@items }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 166 | ▶ | return { named => $1 } if !ref $x && $x =~ /\A@([\w-]+)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not ref $x and $x =~ /\A@([\w-]+)\z/
MC/DC100%2/2
not ref $x and $x =~ /\A@([\w-]+)\z/
not ref $x
$x =~ /\A@([\w-]+)\z/
Truth table100%3/3
not(A) and B
A= not ref $xB= $x =~ /\A@([\w-]+)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 147 | ▶ | return { one => ref $x ? $x->{q} : $x }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 143 | ▶ | sub _verdict_tokens { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_verdict_tokens: called CC=8 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 143 | my ($t) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 143 | ▶ | my $v = shift @$t // die "Urteil fehlt\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @$t // die("Urteil fehlt\n")
MC/DC0%0/1
shift @$t // die("Urteil fehlt\n")
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 143 | ▶ | die "Urteil erwartet\n" if ref $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 143 | ▶ | if ( $v eq 'jump' || $v eq 'goto' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$v eq "jump" or $v eq "goto"
MC/DC50%1/2
$v eq "jump" or $v eq "goto"
$v eq "jump"
$v eq "goto"
Truth table66%2/3
A or B
A= $v eq "jump"B= $v eq "goto"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | ▶ | my $c = shift @$t // die "Kette fehlt\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @$t // die("Kette fehlt\n")
MC/DC0%0/1
shift @$t // die("Kette fehlt\n")
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | ▶ | return { $v => ref $c ? $c->{q} : $c }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 138 | ▶ | die "unbekanntes Urteil $v\n" unless $VERDICT{$v}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 138 | return { $v => 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 82 | my %FIELD = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 'iifname' => 'iif', 'oifname' => 'oif', 'iif' => 'iif', 'oif' => 'oif', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 141 | ▶ | sub parse { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=115 SCAR=63.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 141 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 141 | ▶ | my $t = eval { _tokens($text) } or return ( undef, "nicht zerlegbar: $text" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 141 | my ( @m, $verdict ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 141 | my $res = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 141 | ▶ | while (@$t) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 316 | my $w = shift @$t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 316 | ▶ | die "unerwartet\n" if ref $w; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 316 | ▶ | next if $w eq ';'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 316 | ▶ | if ( $w eq 'counter' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ( @$t >= 4 && $t->[0] eq 'packets' ) { splice @$t, 0, 4 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$t >= 4 and $$t[0] eq "packets"
MC/DC0%0/2
@$t >= 4 and $$t[0] eq "packets"
@$t >= 4
$$t[0] eq "packets"
Truth table33%1/3
A and B
A= @$t >= 4B= $$t[0] eq "packets"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ( $w eq 'comment' ) { shift @$t; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 314 | ▶ | if ( $w eq 'log' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | ▶ | while ( @$t && !ref $t->[0] && $t->[0] =~ /\A(?:prefix|level|flags|group)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
@$t and not ref $$t[0] and $$t[0] =~ /\A(?:prefix|level|flags|group)\z/
@$t and not ref $$t[0]
MC/DC33%1/3
@$t and not ref $$t[0] and $$t[0] =~ /\A(?:prefix|level|flags|group)\z/
@$t
not ref $$t[0]
$$t[0] =~ /\A(?:prefix|level|flags|group)\z/
Truth table50%2/4
A and not(B) and C
A= @$tB= not ref $$t[0]C= $$t[0] =~ /\A(?:prefix|level|flags|group)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | my $k = shift @$t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | shift @$t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | shift @$t if $k eq 'flags' && @$t && !ref $t->[0] && $t->[0] =~ /\A(?:tcp|ip)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
$k eq "flags" and @$t and not ref $$t[0] and $$t[0] =~ /\A(?:tcp|ip)\z/
$k eq "flags" and @$t and not ref $$t[0]
$k eq "flags" and @$t
MC/DC0%0/4
$k eq "flags" and @$t and not ref $$t[0] and $$t[0] =~ /\A(?:tcp|ip)\z/
$k eq "flags"
@$t
not ref $$t[0]
$$t[0] =~ /\A(?:tcp|ip)\z/
Truth table20%1/5
A and B and not(C) and D
A= $k eq "flags"B= @$tC= not ref $$t[0]D= $$t[0] =~ /\A(?:tcp|ip)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 313 | ▶ | if ( $w eq 'limit' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | ▶ | die "limit ohne rate\n" unless ( shift(@$t) // '' ) eq 'rate'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
shift @$t // ""
MC/DC0%0/1
shift @$t // ""
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | my $over = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | ▶ | if ( @$t && $t->[0] eq 'over' ) { shift @$t; $over = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@$t and $$t[0] eq "over"
MC/DC50%1/2
@$t and $$t[0] eq "over"
@$t
$$t[0] eq "over"
Truth table66%2/3
A and B
A= @$tB= $$t[0] eq "over"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | ▶ | my $r = shift @$t // die "rate fehlt\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @$t // die("rate fehlt\n")
MC/DC0%0/1
shift @$t // die("rate fehlt\n")
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if ( @$t && $t->[0] =~ m{\A/} ) { $r .= shift @$t } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$t and $$t[0] =~ m[\A/]
MC/DC0%0/2
@$t and $$t[0] =~ m[\A/]
@$t
$$t[0] =~ m[\A/]
Truth table33%1/3
A and B
A= @$tB= $$t[0] =~ m[\A/]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 2 | ▶ | die "rate unklar\n" unless $r =~ m{\A\d+(?:/|\s*)?(?:second|minute|hour|day|\w*bytes/\w+)?}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | ▶ | shift @$t if @$t && $t->[0] =~ m{\A/(?:second|minute|hour|day)\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@$t and $$t[0] =~ m[\A/(?:second|minute|hour|day)\z]
MC/DC0%0/2
@$t and $$t[0] =~ m[\A/(?:second|minute|hour|day)\z]
@$t
$$t[0] =~ m[\A/(?:second|minute|hour|day)\z]
Truth table33%1/3
A and B
A= @$tB= $$t[0] =~ m[\A/(?:second|minute|hour|day)\z]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | ▶ | if ( @$t && $t->[0] eq 'burst' ) { shift @$t; shift @$t; shift @$t if @$t && $t->[0] =~ /\A(?:packets|bytes|kbytes|mbytes)\z/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
@$t and $$t[0] eq "burst"
@$t and $$t[0] =~ /\A(?:packets|bytes|kbytes|mbytes)\z/
MC/DC50%1/2
@$t and $$t[0] eq "burst"
@$t
$$t[0] eq "burst"
MC/DC0%0/2
@$t and $$t[0] =~ /\A(?:packets|bytes|kbytes|mbytes)\z/
@$t
$$t[0] =~ /\A(?:packets|bytes|kbytes|mbytes)\z/
Truth table66%2/3
A and B
A= @$tB= $$t[0] eq "burst"
Truth table33%1/3
A and B
A= @$tB= $$t[0] =~ /\A(?:packets|bytes|kbytes|mbytes)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | ▶ | push @m, { field => 'never' } if $over; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 311 | ▶ | if ( $VERDICT{$w} || $w eq 'jump' || $w eq 'goto' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$VERDICT{$w} or $w eq "jump" or $w eq "goto"
$VERDICT{$w} or $w eq "jump"
MC/DC33%1/3
$VERDICT{$w} or $w eq "jump" or $w eq "goto"
$VERDICT{$w}
$w eq "jump"
$w eq "goto"
Truth table50%2/4
A or B or C
A= $VERDICT{$w}B= $w eq "jump"C= $w eq "goto"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 124 | unshift @$t, $w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 124 | $verdict = _verdict_tokens($t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 124 | ▶ | if ( $w eq 'reject' && @$t && !ref $t->[0] && $t->[0] eq 'with' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$w eq "reject" and @$t and not ref $$t[0] and $$t[0] eq "with"
$w eq "reject" and @$t and not ref $$t[0]
$w eq "reject" and @$t
MC/DC25%1/4
$w eq "reject" and @$t and not ref $$t[0] and $$t[0] eq "with"
$w eq "reject"
@$t
not ref $$t[0]
$$t[0] eq "with"
Truth table40%2/5
A and B and not(C) and D
A= $w eq "reject"B= @$tC= not ref $$t[0]D= $$t[0] eq "with"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | ▶ | shift @$t while @$t && !( !ref $t->[0] && $t->[0] eq 'comment' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
@$t and not !ref($$t[0]) && $$t[0] eq "comment"
!ref($$t[0]) && $$t[0] eq 'comment'
MC/DC33%1/3
@$t and not !ref($$t[0]) && $$t[0] eq "comment"
@$t
!ref($$t[0])
$$t[0] eq 'comment'
Truth table50%2/4
A and not(not(B) && C)
A= @$tB= !ref($$t[0])C= $$t[0] eq 'comment'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # hinter dem Urteil: counter, log …, comment "…" (wirken nicht auf das Urteil) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 124 | ▶ | while ( @$t && !ref $t->[0] && $t->[0] =~ /\A(?:comment|counter|log)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@$t and not ref $$t[0] and $$t[0] =~ /\A(?:comment|counter|log)\z/
@$t and not ref $$t[0]
MC/DC66%2/3
@$t and not ref $$t[0] and $$t[0] =~ /\A(?:comment|counter|log)\z/
@$t
not ref $$t[0]
$$t[0] =~ /\A(?:comment|counter|log)\z/
Truth table75%3/4
A and not(B) and C
A= @$tB= not ref $$t[0]C= $$t[0] =~ /\A(?:comment|counter|log)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | my $k = shift @$t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | ▶ | if ( $k eq 'comment' ) { shift @$t } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | elsif ( $k eq 'log' ) { while ( @$t && !ref $t->[0] && $t->[0] =~ /\A(?:prefix|level|flags|group)\z/ ) { shift @$t; shift @$t } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
@$t and not ref $$t[0] and $$t[0] =~ /\A(?:prefix|level|flags|group)\z/
@$t and not ref $$t[0]
MC/DC0%0/3
@$t and not ref $$t[0] and $$t[0] =~ /\A(?:prefix|level|flags|group)\z/
@$t
not ref $$t[0]
$$t[0] =~ /\A(?:prefix|level|flags|group)\z/
Truth table0%0/4
A and not(B) and C
A= @$tB= not ref $$t[0]C= $$t[0] =~ /\A(?:prefix|level|flags|group)\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 124 | ▶ | die "nach dem Urteil: " . join( ' ', map { ref $_ ? qq{"$_->{q}"} : $_ } @$t ) . "\n" if @$t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 123 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 187 | my $field; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 187 | ▶ | if ( $w eq 'meta' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 7 | ▶ | my $k = shift @$t // die "meta ohne Schluessel\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @$t // die("meta ohne Schluessel\n")
MC/DC0%0/1
shift @$t // die("meta ohne Schluessel\n")
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 7 | ▶ | if ( $FIELD{$k} ) { $field = $FIELD{$k} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | elsif ( $k eq 'l4proto' ) { $field = 'l4proto' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | elsif ( $k eq 'nfproto' ) { $field = 'nfproto' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 4 | else { die "meta $k\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 41 | elsif ( $FIELD{$w} ) { $field = $FIELD{$w} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ▶ | elsif ( $w eq 'ip' || $w eq 'ip6' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$w eq "ip" or $w eq "ip6"
MC/DC100%2/2
$w eq "ip" or $w eq "ip6"
$w eq "ip"
$w eq "ip6"
Truth table100%3/3
A or B
A= $w eq "ip"B= $w eq "ip6"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 40 | ▶ | my $k = shift @$t // die "$w ohne Feld\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @$t // die("$w ohne Feld\n")
MC/DC0%0/1
shift @$t // die("$w ohne Feld\n")
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 40 | ▶ | if ( $k eq 'saddr' || $k eq 'daddr' ) { $field = "$w $k" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$k eq "saddr" or $k eq "daddr"
MC/DC100%2/2
$k eq "saddr" or $k eq "daddr"
$k eq "saddr"
$k eq "daddr"
Truth table100%3/3
A or B
A= $k eq "saddr"B= $k eq "daddr"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | elsif ( $w eq 'ip' && $k eq 'protocol' ) { $field = 'ipproto4' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$w eq "ip" and $k eq "protocol"
MC/DC0%0/2
$w eq "ip" and $k eq "protocol"
$w eq "ip"
$k eq "protocol"
Truth table33%1/3
A and B
A= $w eq "ip"B= $k eq "protocol"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | elsif ( $w eq 'ip6' && $k eq 'nexthdr' ) { $field = 'ipproto6' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$w eq "ip6" and $k eq "nexthdr"
MC/DC0%0/2
$w eq "ip6" and $k eq "nexthdr"
$w eq "ip6"
$k eq "nexthdr"
Truth table0%0/3
A and B
A= $w eq "ip6"B= $k eq "nexthdr"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | else { die "$w $k\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ▶ | elsif ( $w eq 'tcp' || $w eq 'udp' || $w eq 'th' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$w eq "tcp" or $w eq "udp" or $w eq "th"
$w eq "tcp" or $w eq "udp"
MC/DC100%3/3
$w eq "tcp" or $w eq "udp" or $w eq "th"
$w eq "tcp"
$w eq "udp"
$w eq "th"
Truth table100%4/4
A or B or C
A= $w eq "tcp"B= $w eq "udp"C= $w eq "th"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 74 | ▶ | my $k = shift @$t // die "$w ohne Feld\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @$t // die("$w ohne Feld\n")
MC/DC0%0/1
shift @$t // die("$w ohne Feld\n")
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | # MSS-Anpassung: Anweisung ohne Wirkung auf das Urteil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if ( $w eq 'tcp' && $k eq 'option' && @$t >= 4 && !( grep {ref} @$t[ 0 .. 3 ] ) && "@$t[0..3]" =~ /\Amaxseg size set (?:rt mtu|\d+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition41%5/12
$w eq "tcp" and $k eq "option" and @$t >= 4 and not grep({ref $_;} @$t[0..3]) and join($", @$t[0..3]) =~ /\Amaxseg size set (?:rt mtu|\d+)/
$w eq "tcp" and $k eq "option" and @$t >= 4 and not grep({ref $_;} @$t[0..3])
$w eq "tcp" and $k eq "option" and @$t >= 4
$w eq "tcp" and $k eq "option"
MC/DC0%0/5
$w eq "tcp" and $k eq "option" and @$t >= 4 and not grep({ref $_;} @$t[0..3]) and join($", @$t[0..3]) =~ /\Amaxseg size set (?:rt mtu|\d+)/
$w eq "tcp"
$k eq "option"
@$t >= 4
not grep({ref $_;} @$t[0..3])
join($", @$t[0..3]) =~ /\Amaxseg size set (?:rt mtu|\d+)/
Truth table33%2/6
A and B and C and not(D) and E
A= $w eq "tcp"B= $k eq "option"C= @$t >= 4D= not grep({ref $_;} @$t[0..3])E= join($", @$t[0..3]) =~ /\Amaxseg size set (?:rt mtu|\d+)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | splice @$t, 0, ( $t->[3] eq 'rt' ? 5 : 4 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 74 | ▶ | die "$w $k\n" unless $k eq 'dport' || $k eq 'sport'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$k eq "dport" or $k eq "sport"
MC/DC50%1/2
$k eq "dport" or $k eq "sport"
$k eq "dport"
$k eq "sport"
Truth table66%2/3
A or B
A= $k eq "dport"B= $k eq "sport"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 73 | $field = "$w $k"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | elsif ( $w eq 'ct' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 16 | ▶ | my $k = shift @$t // die "ct ohne Feld\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @$t // die("ct ohne Feld\n")
MC/DC0%0/1
shift @$t // die("ct ohne Feld\n")
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 16 | ▶ | die "ct $k\n" unless $k eq 'state' || $k eq 'status'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$k eq "state" or $k eq "status"
MC/DC0%0/2
$k eq "state" or $k eq "status"
$k eq "state"
$k eq "status"
Truth table33%1/3
A or B
A= $k eq "state"B= $k eq "status"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 16 | ▶ | $field = $k eq 'state' ? 'ct' : 'ct status'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | ▶ | elsif ( $w eq 'icmp' || $w eq 'icmpv6' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$w eq "icmp" or $w eq "icmpv6"
MC/DC100%2/2
$w eq "icmp" or $w eq "icmpv6"
$w eq "icmp"
$w eq "icmpv6"
Truth table100%3/3
A or B
A= $w eq "icmp"B= $w eq "icmpv6"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 7 | ▶ | my $k = shift @$t // die "$w ohne Feld\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @$t // die("$w ohne Feld\n")
MC/DC0%0/1
shift @$t // die("$w ohne Feld\n")
shift @$t
Truth table50%1/2
A
A= shift @$t
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 7 | ▶ | die "$w $k\n" unless $k eq 'type' || $k eq 'code'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$k eq "type" or $k eq "code"
MC/DC0%0/2
$k eq "type" or $k eq "code"
$k eq "type"
$k eq "code"
Truth table33%1/3
A or B
A= $k eq "type"B= $k eq "code"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 7 | $field = "$w $k"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | else { die "unbekannt: $w\n" } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 180 | my $neg = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 180 | ▶ | if ( @$t && !ref $t->[0] && $t->[0] eq '!=' ) { shift @$t; $neg = 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
@$t and not ref $$t[0] and $$t[0] eq "!="
@$t and not ref $$t[0]
MC/DC66%2/3
@$t and not ref $$t[0] and $$t[0] eq "!="
@$t
not ref $$t[0]
$$t[0] eq "!="
Truth table75%3/4
A and not(B) and C
A= @$tB= not ref $$t[0]C= $$t[0] eq "!="
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | elsif ( @$t && !ref $t->[0] && $t->[0] eq '==' ) { shift @$t } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
@$t and not ref $$t[0] and $$t[0] eq "=="
@$t and not ref $$t[0]
MC/DC0%0/3
@$t and not ref $$t[0] and $$t[0] eq "=="
@$t
not ref $$t[0]
$$t[0] eq "=="
Truth table50%2/4
A and not(B) and C
A= @$tB= not ref $$t[0]C= $$t[0] eq "=="
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 180 | ▶ | if ( @$t && !ref $t->[0] && $t->[0] eq 'vmap' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@$t and not ref $$t[0] and $$t[0] eq "vmap"
@$t and not ref $$t[0]
MC/DC66%2/3
@$t and not ref $$t[0] and $$t[0] eq "vmap"
@$t
not ref $$t[0]
$$t[0] eq "vmap"
Truth table75%3/4
A and not(B) and C
A= @$tB= not ref $$t[0]C= $$t[0] eq "vmap"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 9 | shift @$t; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 9 | my $v = _value( $t, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 9 | ▶ | die "vmap braucht { }\n" unless $v->{set}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 9 | push @m, { field => $field, vmap => $v->{set} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | while ( @$t && !ref $t->[0] && $t->[0] eq 'comment' ) { shift @$t; shift @$t } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
@$t and not ref $$t[0] and $$t[0] eq "comment"
@$t and not ref $$t[0]
MC/DC0%0/3
@$t and not ref $$t[0] and $$t[0] eq "comment"
@$t
not ref $$t[0]
$$t[0] eq "comment"
Truth table25%1/4
A and not(B) and C
A= @$tB= not ref $$t[0]C= $$t[0] eq "comment"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | die "nach vmap: " . join( ' ', map { ref $_ ? qq{"$_->{q}"} : $_ } @$t ) . "\n" if @$t; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 9 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 171 | my $v = _value($t); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # ct state established,related ohne Klammern | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ( $field =~ /\Act/ && $v->{one} && $v->{one} =~ /,/ ) { $v = { set => [ split /,/, $v->{one} ] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$field =~ /\Act/ and $$v{"one"} and $$v{"one"} =~ /,/
$field =~ /\Act/ and $$v{"one"}
MC/DC0%0/3
$field =~ /\Act/ and $$v{"one"} and $$v{"one"} =~ /,/
$field =~ /\Act/
$$v{"one"}
$$v{"one"} =~ /,/
Truth table50%2/4
A and B and C
A= $field =~ /\Act/B= $$v{"one"}C= $$v{"one"} =~ /,/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | while ( $field =~ /\Act/ && @$t && !ref $t->[0] && $t->[0] eq ',' ) { shift @$t; my $n = shift @$t; $v = { set => [ ( $v->{set} ? @{ $v->{set} } : $v->{one} ), $n ] } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition77%7/9
$field =~ /\Act/ and @$t and not ref $$t[0] and $$t[0] eq ","
$field =~ /\Act/ and @$t and not ref $$t[0]
$field =~ /\Act/ and @$t
MC/DC50%2/4
$field =~ /\Act/ and @$t and not ref $$t[0] and $$t[0] eq ","
$field =~ /\Act/
@$t
not ref $$t[0]
$$t[0] eq ","
Truth table60%3/5
A and B and not(C) and D
A= $field =~ /\Act/B= @$tC= not ref $$t[0]D= $$t[0] eq ","
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 171 | _check_val( $field, $v ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 170 | push @m, { field => $field, neg => $neg, val => $v }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 132 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 141 | ▶ | return ( undef, "nicht auswertbar: $text" . ( $@ ? " ($@)" =~ s/\n//r : '' ) ) unless $res; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 132 | return ( { matches => \@m, verdict => $verdict } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 171 | ▶ | sub _check_val { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_val: called CC=23 SCAR=37.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 171 | my ( $field, $v ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 171 | ▶ | my @vals = $v->{set} ? @{ $v->{set} } : defined $v->{one} ? ( $v->{one} ) : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 171 | for my $x (@vals) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 170 | ▶ | if ( $field =~ /addr\z/ ) { die "Adresse $x\n" unless _range($x) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 9 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 74 | ▶ | elsif ( $field =~ /port\z/ ) { die "Port $x\n" unless _port_range($x) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 23 | ▶ | elsif ( $field eq 'ct' ) { die "ct state $x\n" unless $CTSTATE{$x} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | elsif ( $field eq 'ct status' ) { die "ct status $x\n" unless $CTSTATUS{$x} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | elsif ( $field eq 'nfproto' ) { die "nfproto $x\n" unless $x =~ /\Aipv[46]\z/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | ▶ | elsif ( $field =~ /proto/ ) { die "Protokoll $x\n" unless exists $PROTO{$x} || $x =~ /\A\d+\z/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $PROTO{$x} or $x =~ /\A\d+\z/
MC/DC0%0/2
exists $PROTO{$x} or $x =~ /\A\d+\z/
exists $PROTO{$x}
$x =~ /\A\d+\z/
Truth table33%1/3
A or B
A= exists $PROTO{$x}B= $x =~ /\A\d+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 12 | ▶ | elsif ( $field =~ /type\z/ ) { die "$field $x\n" unless $ICMP{$x} || $x =~ /\A\d+\z/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ICMP{$x} or $x =~ /\A\d+\z/
MC/DC0%0/2
$ICMP{$x} or $x =~ /\A\d+\z/
$ICMP{$x}
$x =~ /\A\d+\z/
Truth table33%1/3
A or B
A= $ICMP{$x}B= $x =~ /\A\d+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | elsif ( $field =~ /code\z/ ) { die "$field $x\n" unless $ICMPCODE{$x} || $x =~ /\A\d+\z/ } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ICMPCODE{$x} or $x =~ /\A\d+\z/
MC/DC0%0/2
$ICMPCODE{$x} or $x =~ /\A\d+\z/
$ICMPCODE{$x}
$x =~ /\A\d+\z/
Truth table0%0/3
A or B
A= $ICMPCODE{$x}B= $x =~ /\A\d+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 170 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 39 | ▶ | sub parse_error { my ( undef, $e ) = parse( $_[0] ); return $e } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 82 | my %KEYWORD = map { $_ => 1 } qw( meta fib rt ether vlan arp ip ip6 tcp udp udplite sctp dccp ah esp comp icmp icmpv6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | igmp th ct mark iif oif iifname oifname iiftype oiftype skuid skgid pkttype cpu nftrace priority socket osf ipsec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | exthdr hbh frag dst mh srh numgen jhash symhash quota limit counter log reject drop accept queue continue return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | jump goto masquerade snat dnat redirect notrack dup fwd synproxy tproxy flow add update delete set map vmap comment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | xt l4proto nfproto length protocol ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 31 | ▶ | sub syntax_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
syntax_error: called CC=10 SCAR=26.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 31 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 31 | my ( undef, $e ) = parse($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 31 | ▶ | return undef unless defined $e; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ( $e =~ /\((icmpv6|icmp) (?:type|code) (\S+)\)/ ) { return "Error: Could not parse " . ( $1 eq 'icmpv6' ? 'ICMPv6' : 'ICMP' ) . " type\n$text" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 3 | ▶ | return "Error: Could not resolve service: Servname not supported for ai_socktype\n$text" if $e =~ /\(Port \S+\)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | ▶ | return "Error: Could not resolve hostname: Name or service not known\n$text" if $e =~ /\(Adresse \S+\)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | ▶ | return "Error: Could not parse conntrack state\n$text" if $e =~ /\(ct state \S+\)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | ▶ | return undef unless $e =~ /\(unbekannt: (\S+)\)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | my $w = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 1 | ▶ | return undef if $KEYWORD{$w}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | return "Error: syntax error, unexpected " . ( $w =~ /\A\d+\z/ ? 'number' : 'string' ) . "\n$text"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # --- Werte ------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 91 | ▶ | sub _addr_bin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_addr_bin: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 91 | my ($a) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 91 | ▶ | return ( 4, inet_pton( AF_INET, $a ) ) if $a =~ /\A\d+\.\d+\.\d+\.\d+\z/ && inet_pton( AF_INET, $a ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$a =~ /\A\d+\.\d+\.\d+\.\d+\z/ and inet_pton(2, $a)
MC/DC50%1/2
$a =~ /\A\d+\.\d+\.\d+\.\d+\z/ and inet_pton(2, $a)
$a =~ /\A\d+\.\d+\.\d+\.\d+\z/
inet_pton(2, $a)
Truth table66%2/3
A and B
A= $a =~ /\A\d+\.\d+\.\d+\.\d+\z/B= inet_pton(2, $a)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 7 | ▶ | return ( 6, inet_pton( AF_INET6, $a ) ) if $a =~ /:/ && inet_pton( AF_INET6, $a ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$a =~ /:/ and inet_pton(10, $a)
MC/DC50%1/2
$a =~ /:/ and inet_pton(10, $a)
$a =~ /:/
inet_pton(10, $a)
Truth table66%2/3
A and B
A= $a =~ /:/B= inet_pton(10, $a)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | # Adresse, Praefix oder Bereich -> [ familie, von, bis ] (Bitfolgen) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 55 | ▶ | sub _range { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_range: called CC=10 SCAR=23.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 55 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 55 | ▶ | if ( $x =~ m{\A([^/\-]+)/(\d+)\z} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 40 | ▶ | my ( $f, $b ) = _addr_bin($1) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 40 | ▶ | my $len = $f == 4 ? 32 : 128; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 40 | ▶ | return if $2 > $len; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 40 | my $bits = unpack( 'B*', $b ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 40 | my $p = substr( $bits, 0, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 40 | return [ $f, $p . ( '0' x ( $len - $2 ) ), $p . ( '1' x ( $len - $2 ) ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 15 | ▶ | if ( $x =~ /\A([^\-]+)-([^\-]+)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 2 | ▶ | my ( $f1, $b1 ) = _addr_bin($1) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2 | ▶ | my ( $f2, $b2 ) = _addr_bin($2) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 2 | ▶ | return unless $f1 == $f2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 2 | return [ $f1, unpack( 'B*', $b1 ), unpack( 'B*', $b2 ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 13 | ▶ | my ( $f, $b ) = _addr_bin($x) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 13 | my $bits = unpack( 'B*', $b ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 13 | return [ $f, $bits, $bits ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 110 | ▶ | sub _port { my ($p) = @_; return $p =~ /\A\d+\z/ && $p <= 65535 ? 0 + $p : $SERVICE{$p} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_port: called CC=3 SCAR=11.1
Branch: 1 branch
Condition66%2/3
$p =~ /\A\d+\z/ and $p <= 65535
MC/DC50%1/2
$p =~ /\A\d+\z/ and $p <= 65535
$p =~ /\A\d+\z/
$p <= 65535
Truth table66%2/3
A and B
A= $p =~ /\A\d+\z/B= $p <= 65535
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 108 | ▶ | sub _port_range { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_port_range: called CC=5 SCAR=16.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 108 | my ($x) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 108 | ▶ | if ( $x =~ /\A([^\-]+)-([^\-]+)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 2 | my ( $a, $b ) = ( _port($1), _port($2) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 2 | ▶ | return defined $a && defined $b ? [ $a, $b ] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $a and defined $b
MC/DC0%0/2
defined $a and defined $b
defined $a
defined $b
Truth table33%1/3
A and B
A= defined $aB= defined $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 106 | my $p = _port($x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 106 | ▶ | return defined $p ? [ $p, $p ] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 148 | ▶ | sub _family { my ($a) = @_; return defined $a && $a =~ /:/ ? 6 : 4 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_family: called CC=3 SCAR=11.1
Branch: 1 branch
Condition66%2/3
defined $a and $a =~ /:/
MC/DC50%1/2
defined $a and $a =~ /:/
defined $a
$a =~ /:/
Truth table66%2/3
A and B
A= defined $aB= $a =~ /:/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 87 | ▶ | sub _l4 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_l4: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 87 | my ($pkt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 87 | ▶ | my $p = $pkt->{proto} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$pkt{"proto"} // ""
MC/DC0%0/1
$$pkt{"proto"} // ""
$$pkt{"proto"}
Truth table50%1/2
A
A= $$pkt{"proto"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 87 | ▶ | $p = 'icmpv6' if $p eq 'icmp' && _family( $pkt->{saddr} // $pkt->{daddr} ) == 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$p eq "icmp" and _family($$pkt{"saddr"} // $$pkt{"daddr"}) == 6
$$pkt{"saddr"} // $$pkt{"daddr"}
MC/DC0%0/2
$p eq "icmp" and _family($$pkt{"saddr"} // $$pkt{"daddr"}) == 6
$p eq "icmp"
_family($$pkt{"saddr"} // $$pkt{"daddr"}) == 6
MC/DC0%0/2
$$pkt{"saddr"} // $$pkt{"daddr"}
$$pkt{"saddr"}
$$pkt{"daddr"}
Truth table66%2/3
A and B
A= $p eq "icmp"B= _family($$pkt{"saddr"} // $$pkt{"daddr"}) == 6
Truth table33%1/3
A // B
A= $$pkt{"saddr"}B= $$pkt{"daddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 87 | return $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 4 | ▶ | sub _proto_num { my ($p) = @_; return $p =~ /\A\d+\z/ ? 0 + $p : $PROTO{$p} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_proto_num: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # Passt ein einzelner Wert des Pakets auf einen Ausdruckswert? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 108 | ▶ | sub _one { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_one: called CC=21 SCAR=31.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 108 | my ( $field, $have, $want ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 108 | ▶ | return 0 unless defined $have; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 108 | ▶ | if ( $field =~ /addr\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 23 | ▶ | my $r = _range($want) or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 23 | ▶ | my ( $f, $b ) = _addr_bin($have) or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 23 | ▶ | return 0 unless $f == $r->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 23 | my $bits = unpack( 'B*', $b ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 23 | ▶ | return $bits ge $r->[1] && $bits le $r->[2] ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$bits ge $$r[1] and $bits le $$r[2]
MC/DC100%2/2
$bits ge $$r[1] and $bits le $$r[2]
$bits ge $$r[1]
$bits le $$r[2]
Truth table100%3/3
A and B
A= $bits ge $$r[1]B= $bits le $$r[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 85 | ▶ | if ( $field =~ /port\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 34 | ▶ | my $r = _port_range($want) or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 34 | ▶ | return $have >= $r->[0] && $have <= $r->[1] ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$have >= $$r[0] and $have <= $$r[1]
MC/DC100%2/2
$have >= $$r[0] and $have <= $$r[1]
$have >= $$r[0]
$have <= $$r[1]
Truth table100%3/3
A and B
A= $have >= $$r[0]B= $have <= $$r[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 51 | ▶ | if ( $field eq 'iif' || $field eq 'oif' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$field eq "iif" or $field eq "oif"
MC/DC50%1/2
$field eq "iif" or $field eq "oif"
$field eq "iif"
$field eq "oif"
Truth table66%2/3
A or B
A= $field eq "iif"B= $field eq "oif"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 20 | my $re = quotemeta $want; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 20 | $re =~ s/\\\*/.*/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 20 | ▶ | return $have =~ /\A$re\z/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 31 | ▶ | if ( $field =~ /proto/ && $field ne 'nfproto' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$field =~ /proto/ and $field ne "nfproto"
MC/DC50%1/2
$field =~ /proto/ and $field ne "nfproto"
$field =~ /proto/
$field ne "nfproto"
Truth table66%2/3
A and B
A= $field =~ /proto/B= $field ne "nfproto"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | my ( $a, $b ) = ( _proto_num($have), _proto_num($want) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | ▶ | return defined $a && defined $b && $a == $b ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $a and defined $b and $a == $b
defined $a and defined $b
MC/DC0%0/3
defined $a and defined $b and $a == $b
defined $a
defined $b
$a == $b
Truth table25%1/4
A and B and C
A= defined $aB= defined $bC= $a == $b
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 29 | ▶ | return $have eq $want ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # Wert des Pakets fuer ein Feld; undef = das Feld gibt es an diesem Paket nicht | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | # (dann passt der Ausdruck nicht — auch nicht mit !=, wie in nft). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 87 | ▶ | sub _have { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_have: called CC=37 SCAR=44.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 87 | my ( $field, $pkt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 87 | my $l4 = _l4($pkt); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 87 | ▶ | my $fam = _family( $pkt->{saddr} // $pkt->{daddr} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$$pkt{"saddr"} // $$pkt{"daddr"}
MC/DC0%0/2
$$pkt{"saddr"} // $$pkt{"daddr"}
$$pkt{"saddr"}
$$pkt{"daddr"}
Truth table33%1/3
A // B
A= $$pkt{"saddr"}B= $$pkt{"daddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 87 | ▶ | return $pkt->{iif} if $field eq 'iif'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 69 | ▶ | return $pkt->{oif} if $field eq 'oif'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 69 | ▶ | return $fam == 4 ? $pkt->{saddr} : undef if $field eq 'ip saddr'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 52 | ▶ | return $fam == 4 ? $pkt->{daddr} : undef if $field eq 'ip daddr'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 51 | ▶ | return $fam == 6 ? $pkt->{saddr} : undef if $field eq 'ip6 saddr'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 49 | ▶ | return $fam == 6 ? $pkt->{daddr} : undef if $field eq 'ip6 daddr'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 49 | ▶ | return $fam == 4 ? $l4 : undef if $field eq 'ipproto4'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 48 | ▶ | return $fam == 6 ? $l4 : undef if $field eq 'ipproto6'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 48 | ▶ | return $l4 if $field eq 'l4proto'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 47 | ▶ | return "ipv$fam" if $field eq 'nfproto'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 47 | ▶ | if ( $field =~ /\A(tcp|udp|th) (dport|sport)\z/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 34 | my ( $p, $k ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 34 | ▶ | return undef if $p ne 'th' && $p ne $l4; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$p ne "th" and $p ne $l4
MC/DC100%2/2
$p ne "th" and $p ne $l4
$p ne "th"
$p ne $l4
Truth table100%3/3
A and B
A= $p ne "th"B= $p ne $l4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 33 | ▶ | return undef if $p eq 'th' && $l4 ne 'tcp' && $l4 ne 'udp'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$p eq "th" and $l4 ne "tcp" and $l4 ne "udp"
$p eq "th" and $l4 ne "tcp"
MC/DC0%0/3
$p eq "th" and $l4 ne "tcp" and $l4 ne "udp"
$p eq "th"
$l4 ne "tcp"
$l4 ne "udp"
Truth table50%2/4
A and B and C
A= $p eq "th"B= $l4 ne "tcp"C= $l4 ne "udp"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 33 | return $pkt->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 13 | ▶ | return $pkt->{ct} // 'new' if $field eq 'ct'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$$pkt{"ct"} // "new"
MC/DC100%1/1
$$pkt{"ct"} // "new"
$$pkt{"ct"}
Truth table100%2/2
A
A= $$pkt{"ct"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | ▶ | return [ split /\s*,\s*/, $pkt->{ct_status} // '' ] if $field eq 'ct status'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$$pkt{"ct_status"} // ""
MC/DC0%0/1
$$pkt{"ct_status"} // ""
$$pkt{"ct_status"}
Truth table0%0/2
A
A= $$pkt{"ct_status"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 2 | ▶ | return $l4 eq 'icmp' ? ( $pkt->{icmp_type} // 'echo-request' ) : undef if $field eq 'icmp type'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%1/2
$$pkt{"icmp_type"} // "echo-request"
MC/DC0%0/1
$$pkt{"icmp_type"} // "echo-request"
$$pkt{"icmp_type"}
Truth table50%1/2
A
A= $$pkt{"icmp_type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 1 | ▶ | return $l4 eq 'icmpv6' ? ( $pkt->{icmp_type} // 'echo-request' ) : undef if $field eq 'icmpv6 type'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%1/2
$$pkt{"icmp_type"} // "echo-request"
MC/DC0%0/1
$$pkt{"icmp_type"} // "echo-request"
$$pkt{"icmp_type"}
Truth table50%1/2
A
A= $$pkt{"icmp_type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | return $l4 eq ( $field =~ /\Aicmpv6/ ? 'icmpv6' : 'icmp' ) ? $pkt->{icmp_code} : undef if $field =~ /code\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 78 | ▶ | sub _elements { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_elements: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 78 | my ( $table, $v, $why ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 78 | ▶ | return @{ $v->{set} } if $v->{set}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 68 | ▶ | return ( $v->{one} ) if defined $v->{one}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 9 | ▶ | my $s = ( $table->{sets} || {} )->{ $v->{named} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$$table{'sets'} || {}
MC/DC100%1/1
$$table{'sets'} || {}
$$table{'sets'}
Truth table100%2/2
A
A= $$table{'sets'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 9 | ▶ | die "Set \@$v->{named} gibt es nicht\n" unless ref $s eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 8 | ▶ | return @{ $s->{elements} || [] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$s{'elements'} || []
MC/DC0%0/1
$$s{'elements'} || []
$$s{'elements'}
Truth table50%1/2
A
A= $$s{'elements'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 81 | ▶ | sub _match { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_match: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 81 | my ( $m, $pkt, $table ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 81 | ▶ | return 0 if $m->{field} eq 'never'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 80 | my $have = _have( $m->{field}, $pkt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 80 | ▶ | return 0 unless defined $have; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 78 | ▶ | my @have = ref $have eq 'ARRAY' ? @$have : ($have); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 78 | my @want = _elements( $table, $m->{val} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 77 | my $hit = grep { my $h = $_; grep { _one( $m->{field}, $h, $_ ) } @want } @have; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 77 | ▶ | return $m->{neg} ? !$hit : $hit ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # --- Auswerten -------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 59 | ▶ | sub _prio { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prio: called CC=7 SCAR=20.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 59 | my ($p) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 59 | ▶ | $p //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$p //= 0
MC/DC0%0/1
$p //= 0
$p
Truth table50%1/2
A
A= $p
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 59 | ▶ | return 0 + $p if $p =~ /\A-?\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 3 | ▶ | if ( $p =~ /\A(\w+)\s*([+-])\s*(\d+)\z/ && exists $PRIO{$1} ) { return $PRIO{$1} + ( $2 eq '+' ? $3 : -$3 ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$p =~ /\A(\w+)\s*([+-])\s*(\d+)\z/ and exists $PRIO{$1}
MC/DC50%1/2
$p =~ /\A(\w+)\s*([+-])\s*(\d+)\z/ and exists $PRIO{$1}
$p =~ /\A(\w+)\s*([+-])\s*(\d+)\z/
exists $PRIO{$1}
Truth table66%2/3
A and B
A= $p =~ /\A(\w+)\s*([+-])\s*(\d+)\z/B= exists $PRIO{$1}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 2 | ▶ | return $PRIO{$p} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$PRIO{$p} // 0
MC/DC0%0/1
$PRIO{$p} // 0
$PRIO{$p}
Truth table50%1/2
A
A= $PRIO{$p}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # Eine Kette durchlaufen -> ( 'accept'|'drop'|'return'|undef (Ende), Spur ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 61 | ▶ | sub _chain { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_chain: called CC=21 SCAR=30.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 61 | my ( $tname, $table, $cname, $pkt, $depth ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 61 | ▶ | die "Ketten zu tief verschachtelt\n" if $depth > 16; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 61 | ▶ | my $ch = $table->{chains}{$cname} or die "Kette $cname gibt es nicht\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 61 | ▶ | for my $text ( @{ $ch->{rules} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$ch{'rules'} || []
MC/DC0%0/1
$$ch{'rules'} || []
$$ch{'rules'}
Truth table50%1/2
A
A= $$ch{'rules'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 71 | my ( $r, $err ) = parse($text); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 71 | ▶ | die "$err\n" unless $r; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 70 | my $all = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 70 | my $verdict = $r->{verdict}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 70 | for my $m ( @{ $r->{matches} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 88 | ▶ | if ( $m->{vmap} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 7 | my $have = _have( $m->{field}, $pkt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 7 | ▶ | my ($hit) = defined $have ? grep { _one( $m->{field}, $have, $_->[0] ) } @{ $m->{vmap} } : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 7 | ▶ | if ($hit) { $verdict = $hit->[1] } else { $all = 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 7 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 81 | ▶ | next if _match( $m, $pkt, $table ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 23 | $all = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 23 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 69 | ▶ | next unless $all && $verdict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$all and $verdict
MC/DC50%1/2
$all and $verdict
$all
$verdict
Truth table66%2/3
A and B
A= $allB= $verdict
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 44 | my $where = "$tname $cname: $text"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 44 | ▶ | return ( 'accept', $where ) if $verdict->{accept}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 12 | ▶ | return ( 'drop', $where ) if $verdict->{drop} || $verdict->{reject}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$verdict{"drop"} or $$verdict{"reject"}
MC/DC50%1/2
$$verdict{"drop"} or $$verdict{"reject"}
$$verdict{"drop"}
$$verdict{"reject"}
Truth table66%2/3
A or B
A= $$verdict{"drop"}B= $$verdict{"reject"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 4 | ▶ | return ( 'return', $where ) if $verdict->{return}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 3 | ▶ | next if $verdict->{continue}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 3 | my ($to) = grep {defined} @{$verdict}{qw( jump goto )}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 3 | my ( $v, $w ) = _chain( $tname, $table, $to, $pkt, $depth + 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | ▶ | return ( $v, $w ) if defined $v && $v ne 'return'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $v and $v ne "return"
MC/DC100%2/2
defined $v and $v ne "return"
defined $v
$v ne "return"
Truth table100%3/3
A and B
A= defined $vB= $v ne "return"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 2 | ▶ | return ( undef, "$tname $to: Ende (goto)" ) if $verdict->{goto}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 17 | return ( undef, "$tname $cname: Ende" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 60 | ▶ | sub verdict { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verdict: called CC=24 SCAR=33.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 60 | my ( $dev, $pkt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 60 | ▶ | my $fam = _family( $pkt->{saddr} // $pkt->{daddr} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$$pkt{"saddr"} // $$pkt{"daddr"}
MC/DC0%0/2
$$pkt{"saddr"} // $$pkt{"daddr"}
$$pkt{"saddr"}
$$pkt{"daddr"}
Truth table33%1/3
A // B
A= $$pkt{"saddr"}B= $$pkt{"daddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 60 | ▶ | my $T = ref $dev->{nft} eq 'HASH' ? $dev->{nft} : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 60 | my @base; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 60 | for my $tn ( sort keys %$T ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 64 | my ($f) = split / /, $tn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 64 | ▶ | next unless $f eq 'inet' || ( $f eq 'ip' && $fam == 4 ) || ( $f eq 'ip6' && $fam == 6 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%8/12
$f eq "inet" or $f eq "ip" and $fam == 4 or $f eq "ip6" and $fam == 6
$f eq "inet" or $f eq "ip" and $fam == 4
$f eq "ip" and $fam == 4
$f eq "ip6" and $fam == 6
MC/DC40%2/5
$f eq "inet" or $f eq "ip" and $fam == 4 or $f eq "ip6" and $fam == 6
$f eq "inet"
$f eq "ip"
$fam == 4
$f eq "ip6"
$fam == 6
Truth table37%3/8
A or B and C or D and E
A= $f eq "inet"B= $f eq "ip"C= $fam == 4D= $f eq "ip6"E= $fam == 6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 63 | ▶ | my $chains = $T->{$tn}{chains} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$T{$tn}{'chains'} || {}
MC/DC0%0/1
$$T{$tn}{'chains'} || {}
$$T{$tn}{'chains'}
Truth table50%1/2
A
A= $$T{$tn}{'chains'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 63 | for my $cn ( sort keys %$chains ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 72 | my $c = $chains->{$cn}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 72 | ▶ | next unless ( $c->{hook} // '' ) eq $pkt->{hook} && ( $c->{type} // '' ) eq 'filter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition85%6/7
($$c{"hook"} // "") eq $$pkt{"hook"} and ($$c{"type"} // "") eq "filter"
$$c{"hook"} // ""
$$c{"type"} // ""
MC/DC50%1/2
($$c{"hook"} // "") eq $$pkt{"hook"} and ($$c{"type"} // "") eq "filter"
$$c{"hook"}
$$c{"type"}
Truth table66%2/3
A and B
A= $$c{"hook"}B= $$c{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 59 | push @base, [ _prio( $c->{priority} ), $tn, $cn ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 60 | my @why; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 60 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 60 | ▶ | for my $b ( sort { $a->[0] <=> $b->[0] || $a->[1] cmp $b->[1] || $a->[2] cmp $b->[2] } @base ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$$a[0] <=> $$b[0] || $$a[1] cmp $$b[1] || $$a[2] cmp $$b[2]
$$a[0] <=> $$b[0] or $$a[1] cmp $$b[1]
MC/DC0%0/3
$$a[0] <=> $$b[0] || $$a[1] cmp $$b[1] || $$a[2] cmp $$b[2]
$$a[0] <=> $$b[0]
$$a[1] cmp $$b[1]
$$a[2] cmp $$b[2]
Truth table25%1/4
A or B || C
A= $$a[0] <=> $$b[0]B= $$a[1] cmp $$b[1]C= $$a[2] cmp $$b[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 58 | my ( undef, $tn, $cn ) = @$b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 58 | my ( $v, $w ) = _chain( $tn, $T->{$tn}, $cn, $pkt, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 56 | ▶ | if ( !defined $v || $v eq 'return' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $v or $v eq "return"
MC/DC50%1/2
not defined $v or $v eq "return"
not defined $v
$v eq "return"
Truth table66%2/3
not(A) or B
A= not defined $vB= $v eq "return"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 16 | ▶ | my $pol = $T->{$tn}{chains}{$cn}{policy} // 'accept'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$$T{$tn}{"chains"}{$cn}{"policy"} // "accept"
MC/DC0%0/1
$$T{$tn}{"chains"}{$cn}{"policy"} // "accept"
$$T{$tn}{"chains"}{$cn}{"policy"}
Truth table50%1/2
A
A= $$T{$tn}{"chains"}{$cn}{"policy"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 16 | $v = $pol; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 16 | $w = "$tn $cn: policy $pol"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 56 | push @why, $w; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 56 | ▶ | return ( 'drop' ) if $v eq 'drop'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 35 | 'accept'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 60 | ▶ | return ( undef, ( $@ =~ s/\n\z//r ) ) unless defined $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 58 | ▶ | return ( $ok, @why ? join( '; ', @why ) : 'keine Basiskette' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 6 | ▶ | sub boot_verdict { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
boot_verdict: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 6 | my ( $dev, $pkt, $file ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 6 | ▶ | $file //= '/etc/nftables.conf'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$file //= "/etc/nftables.conf"
MC/DC100%1/1
$file //= "/etc/nftables.conf"
$file
Truth table100%2/2
A
A= $file
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 6 | require Langertha::Holmgang::Sim::Linux; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 6 | my $text = Langertha::Holmgang::Sim::Linux::_file_text( $dev, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 6 | my $boot = Langertha::Holmgang::Sim::Linux::clone_state($dev); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 6 | $boot->{nft} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 6 | ▶ | return ( undef, "$file fehlt" ) unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 4 | local @Langertha::Holmgang::Sim::Linux::GAPS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 4 | my ( $out, $ok ) = Langertha::Holmgang::Sim::Linux::_nft_load( $boot, $text, $file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 4 | ▶ | return ( undef, "$file lädt nicht: $out" ) unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 4 | return verdict( $boot, $pkt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 82 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||