blib/lib/Langertha/Holmgang/Sim/Linux/Nginx.pm

filter: Statementstmt 80.2% 808 / 1007 Branchbran 56.4% 403 / 714 Conditioncond 51.1% 304 / 594 MC/DCmcdc 22.4% 73 / 325 Subroutinesub 97.0% 65 / 67 Podpod 100% 5 / 5 totaltotal 61.1% 1658 / 2712 CC 628 SCAR 47.8
CC
628
Cov
65%
_rewrite_phase
475.9
_var
468.7
serve
324.1
CRAP 119.6
« blib/lib/Langertha/Holmgang/Grader.pm ↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/RedisService.pm »
1 package Langertha::Holmgang::Sim::Linux::Nginx;
2 # ABSTRACT: nginx on a simulated Linux server: checking and loading the configuration, answering requests
3  
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 our $VERSION = '0.001';
12  
13  
14 4 my $JSON = JSON::MaybeXS->new( utf8 => 1, canonical => 1 );
15  
16 181 ▶sub _L { require Langertha::Holmgang::Sim::Linux; return 'Langertha::Holmgang::Sim::Linux' }
Subroutine _L: called CC=1 SCAR=0.0
17 174 ▶sub _ftext { _L(); return Langertha::Holmgang::Sim::Linux::_file_text(@_) }
Subroutine _ftext: called CC=1 SCAR=0.0
18 324 ▶sub _pki { require Langertha::Holmgang::Sim::Linux::Pki; return 'Langertha::Holmgang::Sim::Linux::Pki' }
Subroutine _pki: called CC=1 SCAR=0.0
19  
20 4 our $VERSION_TEXT = 'nginx/1.22.1';
21  
22 4 my %BUILTIN = (
23 '/etc/nginx/mime.types' => "types {\n text/html html htm shtml;\n text/css css;\n application/javascript js;\n application/json json;\n image/png png;\n image/jpeg jpeg jpg;\n image/svg+xml svg;\n text/plain txt;\n}\n",
24 '/etc/nginx/proxy_params' => "proxy_set_header Host \$http_host;\nproxy_set_header X-Real-IP \$remote_addr;\nproxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;\nproxy_set_header X-Forwarded-Proto \$scheme;\n",
25 '/etc/nginx/fastcgi_params' => "fastcgi_param QUERY_STRING \$query_string;\nfastcgi_param REQUEST_METHOD \$request_method;\n",
26 );
27  
28 # --- Direktiven -------------------------------------------------------------------
29  
30 # Kontexte: M main, E events, H http, S server, L location, I if, U upstream
31 my %CTX = (
32 68 ( map { $_ => 'M' } qw( user worker_processes pid load_module worker_rlimit_nofile daemon master_process env pcre_jit
33 timer_resolution worker_cpu_affinity worker_priority working_directory lock_file thread_pool events http ) ),
34 20 ( map { $_ => 'E' } qw( worker_connections multi_accept use accept_mutex accept_mutex_delay ) ),
35 24 ( map { $_ => 'U' } qw( keepalive least_conn ip_hash hash zone random ) ),
36 4 ( map { $_ => 'H' } qw( upstream map types log_format limit_req_zone limit_conn_zone proxy_cache_path geo split_clients
37 server_names_hash_bucket_size server_names_hash_max_size types_hash_max_size types_hash_bucket_size
38 variables_hash_max_size variables_hash_bucket_size map_hash_bucket_size map_hash_max_size ) ),
39 server => 'HU',
40 listen => 'S', server_name => 'S',
41 location => 'SL', if => 'SL',
42 alias => 'L', internal => 'L', limit_except => 'L',
43 proxy_pass => 'LI',
44 return => 'SLI', rewrite => 'SLI', set => 'SLI', break => 'SLI',
45 try_files => 'SL',
46 include => 'MEHSLIU',
47 error_log => 'MHSL',
48 keepalive_timeout => 'HSLU', keepalive_requests => 'HSLU',
49 );
50 4 my %HSL = map { $_ => 1 } qw( root index add_header add_trailer expires charset access_log error_page default_type
51 server_tokens autoindex autoindex_exact_size autoindex_localtime satisfy etag if_modified_since sendfile
52 tcp_nopush tcp_nodelay aio directio merge_slashes msie_padding underscores_in_headers ignore_invalid_headers
53 server_name_in_redirect port_in_redirect absolute_redirect recursive_error_pages chunked_transfer_encoding
54 reset_timedout_connection allow deny resolver resolver_timeout sub_filter sub_filter_once sub_filter_types
55 set_real_ip_from real_ip_header real_ip_recursive log_not_found log_subrequest gunzip ssi more_set_headers gzip ssl
56 error_log open_file_cache sendfile_max_chunk read_ahead disable_symlinks types_hash_max_size limit_rate auth_basic
57 auth_basic_user_file auth_request postpone_output send_timeout output_buffers lingering_close userid );
58 4 my $FAMILY = qr/\A(?:proxy|ssl|gzip|fastcgi|uwsgi|scgi|grpc|limit|open_file_cache|client|keepalive|http2|lingering|auth|
59 sub_filter|real_ip|send|output|postpone|resolver|large_client|server_names|types_hash|variables_hash|map_hash|
60 open_log_file_cache|access_log|error_page|sendfile|read_ahead|tcp|ssi|userid|secure_link|slice|mp4|flv|
61 image_filter|xslt|dav|charset|source_charset|override_charset|add_|expires)_\w+\z/x;
62 4 my %NARGS = ( listen => [ 1, 9 ], server_name => [ 1, 99 ], proxy_pass => [ 1, 1 ], root => [ 1, 1 ], alias => [ 1, 1 ],
63 return => [ 1, 2 ], rewrite => [ 2, 3 ], proxy_set_header => [ 2, 2 ], add_header => [ 2, 3 ],
64 client_max_body_size => [ 1, 1 ], try_files => [ 2, 99 ], include => [ 1, 1 ], location => [ 1, 2 ],
65 upstream => [ 1, 1 ], allow => [ 1, 1 ], deny => [ 1, 1 ], ssl_certificate => [ 1, 1 ], ssl_certificate_key => [ 1, 1 ],
66 proxy_read_timeout => [ 1, 1 ], proxy_connect_timeout => [ 1, 1 ], proxy_send_timeout => [ 1, 1 ],
67 proxy_http_version => [ 1, 1 ], index => [ 1, 99 ], set => [ 2, 2 ], map => [ 2, 2 ], ssl_protocols => [ 1, 9 ],
68 ssl_client_certificate => [ 1, 1 ], ssl_verify_client => [ 1, 1 ], ssl_password_file => [ 1, 1 ],
69 worker_processes => [ 1, 1 ], user => [ 1, 2 ], events => [ 0, 0 ], http => [ 0, 0 ], server => [ 0, 9 ],
70 types => [ 0, 0 ], internal => [ 0, 0 ], break => [ 0, 0 ], http2 => [ 0, 0 ] );
71 4 my %ONCE = map { $_ => 1 } qw( root alias proxy_pass client_max_body_size try_files ssl_certificate_key proxy_http_version
72 proxy_read_timeout ssl_verify_client ssl_client_certificate index default_type autoindex );
73 4 my %BLOCK = map { $_ => 1 } qw( events http server location upstream map types if limit_except geo split_clients );
74  
75 3103 ▶sub _known {
Subroutine _known: called CC=6 SCAR=17.9
76 3103 my ( $n, $ctx ) = @_;
77 3103 ▶ if ( my $c = $CTX{$n} ) { return index( $c, $ctx ) >= 0 ? 1 : -1 }
Branch: 2 branches
BranchTrueFalseTotal
if (my $c = $CTX{$n}) 2066 1037 3103
index($c, $ctx) != -1 ? : 2065 1 2066
78 1037 ▶ return $ctx =~ /[HSLI]/ ? 1 : -1 if $HSL{$n} || $n =~ $FAMILY;
Branch: 2 branches
BranchTrueFalseTotal
if $HSL{$n} or $n =~ /$FAMILY/ 1034 3 1037
$ctx =~ /[HSLI]/ ? : 1034 0 1034
Condition100%3/3
$HSL{$n} or $n =~ /$FAMILY/
l!l&&r!l&&!r
7642703
MC/DC100%2/2
$HSL{$n} or $n =~ /$FAMILY/
$HSL{$n} $n =~ /$FAMILY/
Truth table100%3/3
A or B
A= $HSL{$n}B= $n =~ /$FAMILY/
ABresult
1X1
011
000
79 3 return 0;
80 }
81  
82 # --- Zerlegen -------------------------------------------------------------------
83  
84 177 ▶sub _tokens {
Subroutine _tokens: called CC=11 SCAR=25.2
85 177 my ( $text, $file ) = @_;
86 177 my @t;
87 177 my $line = 1;
88 177 pos($text) = 0;
89 177 ▶ while ( pos($text) < length $text ) {
Branch: 1 branch
BranchTrueFalseTotal
if (pos $text < length $text) 15073 177 15250
90 15073 ▶ if ( $text =~ /\G\n/gc ) { $line++ }
Branch: 7 branches
BranchTrueFalseTotal
if ($text =~ /\G\n/cg) { } 2829 12244 15073
elsif ($text =~ /\G[ \t\r]+/cg) { } 4911 7333 12244
elsif ($text =~ /\G#[^\n]*/cg) { } 0 7333 7333
elsif ($text =~ /\G([{};])/cg) { } 2743 4590 7333
elsif ($text =~ /\G"((?:[^"\\]|\\.)*)"/cgs or $text =~ /\G'((?:[^'\\]|\\.)*)'/cgs) { } 20 4570 4590
elsif ($text =~ /\G((?:[^\s{};"'\\]|\\.)+)/cg) { } 4570 0 4570
elsif ($text =~ /\G["']/cg) { } 0 0 0
91 elsif ( $text =~ /\G[ \t\r]+/gc ) { }
92 elsif ( $text =~ /\G#[^\n]*/gc ) { }
93 2743 elsif ( $text =~ /\G([{};])/gc ) { push @t, { op => $1, line => $line } }
94 ▶ elsif ( $text =~ /\G"((?:[^"\\]|\\.)*)"/gcs || $text =~ /\G'((?:[^'\\]|\\.)*)'/gcs ) {
Condition66%2/3
$text =~ /\G"((?:[^"\\]|\\.)*)"/cgs or $text =~ /\G'((?:[^'\\]|\\.)*)'/cgs
l!l&&r!l&&!r
2004570
MC/DC50%1/2
$text =~ /\G"((?:[^"\\]|\\.)*)"/cgs or $text =~ /\G'((?:[^'\\]|\\.)*)'/cgs
$text =~ /\G"((?:[^"\\]|\\.)*)"/cgs $text =~ /\G'((?:[^'\\]|\\.)*)'/cgs
Truth table66%2/3
A or B
A= $text =~ /\G"((?:[^"\\]|\\.)*)"/cgsB= $text =~ /\G'((?:[^'\\]|\\.)*)'/cgs
ABresult
1X1
011
000
95 20 my $v = $1;
96 20 $line += () = $v =~ /\n/g;
97 20 ▶ $v =~ s/\\(["'\\nrt])/{ n => "\n", r => "\r", t => "\t" }->{$1} \/\/ $1/ge;
Condition33%1/3
{"n", "\n", "r", "\r", "t", "\t"}->{$1} // $1
l!l&&r!l&&!r
1800
MC/DC0%0/2
{"n", "\n", "r", "\r", "t", "\t"}->{$1} // $1
{"n", "\n", "r", "\r", "t", "\t"}->{$1} $1
Truth table33%1/3
A // B
A= {"n", "\n", "r", "\r", "t", "\t"}->{$1}B= $1
ABresult
1X1
011
000
98 20 push @t, { w => $v, line => $line, q => 1 };
99 }
100 4570 elsif ( $text =~ /\G((?:[^\s{};"'\\]|\\.)+)/gc ) { push @t, { w => $1, line => $line } }
101 0 elsif ( $text =~ /\G["']/gc ) { die { msg => 'unexpected end of file, expecting ";" or "}"', file => $file, line => $line } }
102 0 else { pos($text)++ }
103 }
104 177 return ( \@t, $line );
105 }
106  
107 # Datei -> Liste von Direktiven { name, args, file, line, block }
108 # Wie nginx: jede Direktive wird beim Lesen geprueft (bekannt, Kontext,
109 # Anzahl der Argumente) — der erste Fehler in Dateireihenfolge zaehlt.
110 471 ▶sub _block_ctx {
Subroutine _block_ctx: called CC=3 SCAR=11.4
111 471 my ( $n, $ctx ) = @_;
112 471 ▶ return 'T' if $n =~ /\A(?:types|map|geo|split_clients)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $n =~ /\A(?:types|map|geo|split_clients)\z/ 46 425 471
113 425 ▶ return { events => 'E', http => 'H', server => 'S', location => 'L', limit_except => 'L', if => 'I', upstream => 'U' }->{$n} // $ctx;
Condition33%1/3
{"events", "E", "http", "H", "server", "S", "location", "L", "limit_except", "L", "if", "I", "upstream", "U"}->{$n} // $ctx
l!l&&r!l&&!r
42500
MC/DC0%0/2
{"events", "E", "http", "H", "server", "S", "location", "L", "limit_except", "L", "if", "I", "upstream", "U"}->{$n} // $ctx
{"events", "E", "http", "H", "server", "S", "location", "L", "limit_except", "L", "if", "I", "upstream", "U"}->{$n} $ctx
Truth table33%1/3
A // B
A= {"events", "E", "http", "H", "server", "S", "location", "L", "limit_except", "L", "if", "I", "upstream", "U"}->{$n}B= $ctx
ABresult
1X1
011
000
114 }
115  
116 2187 ▶sub _stream_check {
Subroutine _stream_check: called CC=13 SCAR=26.1
117 2187 my ( $d, $ctx, $block ) = @_;
118 2187 ▶ return if $ctx eq 'T' || $d->{name} eq 'include';
Branch: 1 branch
BranchTrueFalseTotal
if $ctx eq "T" or $$d{"name"} eq "include" 570 1617 2187
Condition100%3/3
$ctx eq "T" or $$d{"name"} eq "include"
l!l&&r!l&&!r
3682021617
MC/DC100%2/2
$ctx eq "T" or $$d{"name"} eq "include"
$ctx eq "T" $$d{"name"} eq "include"
Truth table100%3/3
A or B
A= $ctx eq "T"B= $$d{"name"} eq "include"
ABresult
1X1
011
000
119 1617 my $n = $d->{name};
120 1617 my $k = _known( $n, $ctx );
121 1617 ▶ _err( $d, "unknown directive \"$n\"" ) unless $k;
Branch: 1 branch
BranchTrueFalseTotal
unless $k 3 1614 1617
122 1614 ▶ _err( $d, "\"$n\" directive is not allowed here" ) if $k < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $k < 0 1 1613 1614
123 1613 ▶ _err( $d, "directive \"$n\" has no opening \"{\"" ) if $BLOCK{$n} && !$block && !( $n eq 'server' && $ctx eq 'U' );
Branch: 1 branch
BranchTrueFalseTotal
if $BLOCK{$n} and not $block and not $n eq "server" && $ctx eq "U" 0 1613 1613
Condition66%6/9
$BLOCK{$n} and not $block and not $n eq "server" && $ctx eq "U"
!ll&&!rl&&r
160940
$BLOCK{$n} and not $block
!ll&&!rl&&r
11384714
$n eq 'server' && $ctx eq 'U'
!ll&&!rl&&r
004
MC/DC0%0/4
$BLOCK{$n} and not $block and not $n eq "server" && $ctx eq "U"
$BLOCK{$n} not $block $n eq 'server' $ctx eq 'U'
Truth table60%3/5
A and not(B) and not(C && D)
A= $BLOCK{$n}B= not $blockC= $n eq 'server'D= $ctx eq 'U'
ABCDresult
0XXX0
10XX0
11110
110X1
11101
124 1613 ▶ _err( $d, "\"$n\" directive is not allowed here" ) if $block && !$BLOCK{$n};
Branch: 1 branch
BranchTrueFalseTotal
if $block and not $BLOCK{$n} 0 1613 1613
Condition66%2/3
$block and not $BLOCK{$n}
!ll&&!rl&&r
11424710
MC/DC0%0/2
$block and not $BLOCK{$n}
$block not $BLOCK{$n}
Truth table66%2/3
A and not(B)
A= $blockB= not $BLOCK{$n}
ABresult
0X0
100
111
125 1613 ▶ _nargs($d) unless $n eq 'server' && $ctx eq 'U';
Branch: 1 branch
BranchTrueFalseTotal
unless $n eq "server" and $ctx eq "U" 1609 4 1613
Condition100%3/3
$n eq "server" and $ctx eq "U"
!ll&&!rl&&r
1541684
MC/DC100%2/2
$n eq "server" and $ctx eq "U"
$n eq "server" $ctx eq "U"
Truth table100%3/3
A and B
A= $n eq "server"B= $ctx eq "U"
ABresult
0X0
100
111
126 }
127  
128 177 ▶sub _parse_file {
Subroutine _parse_file: called CC=14 SCAR=26.6
129 177 my ( $p, $file, $ctx0 ) = @_;
130 177 ▶ $ctx0 //= 'M';
Condition100%2/2
$ctx0 //= "M"
l!l
11364
MC/DC100%1/1
$ctx0 //= "M"
$ctx0
Truth table100%2/2
A
A= $ctx0
Aresult
11
00
131 177 my @ctx = ($ctx0);
132 177 my $text = $p->{read}->($file);
133 0 ▶ die { msg => "open() \"$file\" failed (2: No such file or directory)", %{ $p->{at} || {} } } unless defined $text;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $text 0 177 177
Condition0%0/2
$$p{'at'} || {}
l!l
00
MC/DC0%0/1
$$p{'at'} || {}
$$p{'at'}
Truth table0%0/2
A
A= $$p{'at'}
Aresult
11
00
134 177 $p->{conf_files}{$file} = $text;
135 177 my ( $t, $last ) = _tokens( $text, $file );
136 177 my @stack = ( [] );
137 177 my @open;
138 my @cur;
139 177 for my $tok (@$t) {
140 7115 ▶ if ( defined $tok->{w} ) { push @cur, $tok; next }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$tok{"w"}) 4464 2651 7115
141 2651 ▶ if ( $tok->{op} eq ';' || $tok->{op} eq '{' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$tok{"op"} eq ";" or $$tok{"op"} eq "{") 2187 464 2651
Condition100%3/3
$$tok{"op"} eq ";" or $$tok{"op"} eq "{"
l!l&&r!l&&!r
1713474464
MC/DC100%2/2
$$tok{"op"} eq ";" or $$tok{"op"} eq "{"
$$tok{"op"} eq ";" $$tok{"op"} eq "{"
Truth table100%3/3
A or B
A= $$tok{"op"} eq ";"B= $$tok{"op"} eq "{"
ABresult
1X1
011
000
142 2187 ▶ die { msg => "unexpected \"$tok->{op}\"", file => $file, line => $tok->{line} } unless @cur;
Branch: 1 branch
BranchTrueFalseTotal
unless @cur 0 2187 2187
143 2187 my ( $n, @a ) = @cur;
144 2187 my $d = { name => $n->{w}, args => [ map { $_->{w} } @a ], file => $file, line => $n->{line} };
145 2187 @cur = ();
146 2187 _stream_check( $d, $ctx[-1], $tok->{op} eq '{' );
147 2183 ▶ if ( $tok->{op} eq '{' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$tok{'op'} eq '{') { } 471 1712 2183
148 471 $d->{block} = [];
149 471 push @{ $stack[-1] }, $d;
150 471 push @stack, $d->{block};
151 471 push @open, $d;
152 471 push @ctx, _block_ctx( $d->{name}, $ctx[-1] );
153 }
154 1712 else { push @{ $stack[-1] }, $d }
155 2183 next;
156 }
157 # }
158 464 ▶ if (@cur) { die { msg => 'unexpected "}"', file => $file, line => $tok->{line} } }
Branch: 1 branch
BranchTrueFalseTotal
if (@cur) 2 462 464
159 462 ▶ die { msg => 'unexpected "}"', file => $file, line => $tok->{line} } unless @open;
Branch: 1 branch
BranchTrueFalseTotal
unless @open 0 462 462
160 462 pop @stack;
161 462 pop @open;
162 462 pop @ctx;
163 }
164 171 ▶ die { msg => 'unexpected end of file, expecting ";" or "}"', file => $file, line => $last } if @cur;
Branch: 1 branch
BranchTrueFalseTotal
if @cur 0 171 171
165 171 ▶ die { msg => 'unexpected end of file, expecting "}"', file => $file, line => $last } if @open;
Branch: 1 branch
BranchTrueFalseTotal
if @open 0 171 171
166 171 return $stack[0];
167 }
168  
169 156 ▶sub _glob_re { my ($g) = @_; ( my $r = quotemeta $g ) =~ s/\\\*/[^\/]*/g; $r =~ s/\\\?/[^\/]/g; return qr/\A$r\z/ }
Subroutine _glob_re: called CC=1 SCAR=0.0
170  
171 # include aufloesen (rekursiv), Kontext pruefen
172 585 ▶sub _expand {
Subroutine _expand: called CC=23 SCAR=33.1
173 585 my ( $p, $list, $ctx ) = @_;
174 585 my @out;
175 585 for my $d (@$list) {
176 1778 ▶ if ( $d->{name} eq 'include' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$d{"name"} eq "include") 202 1576 1778
177 202 _nargs($d);
178 202 my $pat = $d->{args}[0];
179 202 ▶ $pat = "/etc/nginx/$pat" unless $pat =~ m{\A/};
Branch: 1 branch
BranchTrueFalseTotal
unless $pat =~ m[\A/] 0 202 202
180 202 my @files;
181 202 ▶ if ( $pat =~ /[*?\[]/ ) { @files = $p->{glob}->($pat) }
Branch: 1 branch
BranchTrueFalseTotal
if ($pat =~ /[*?\[]/) { } 156 46 202
182 46 else { @files = ($pat) }
183 202 for my $f (@files) {
184 113 local $p->{at} = { file => $d->{file}, line => $d->{line} };
185 113 ▶ die { msg => 'include depth', file => $d->{file}, line => $d->{line} } if ++$p->{depth} > 50;
Branch: 1 branch
BranchTrueFalseTotal
if ++$$p{"depth"} > 50 0 113 113
186 113 push @out, @{ _expand( $p, _parse_file( $p, $f, $ctx ), $ctx ) };
187 }
188 196 next;
189 }
190 1576 push @out, $d;
191 1576 ▶ if ( $d->{block} && $d->{name} ne 'types' && $d->{name} ne 'map' && $d->{name} ne 'geo' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($$d{'block'} and $$d{'name'} ne 'types' and $$d{'name'} ne 'map' and $$d{'name'} ne 'geo') { } 414 1162 1576
elsif ($$d{'block'}) { } 46 1116 1162
Condition77%7/9
$$d{"block"} and $$d{"name"} ne "types" and $$d{"name"} ne "map" and $$d{"name"} ne "geo"
!ll&&!rl&&r
11620414
$$d{"block"} and $$d{"name"} ne "types" and $$d{"name"} ne "map"
!ll&&!rl&&r
11620414
$$d{"block"} and $$d{"name"} ne "types"
!ll&&!rl&&r
111646414
MC/DC50%2/4
$$d{"block"} and $$d{"name"} ne "types" and $$d{"name"} ne "map" and $$d{"name"} ne "geo"
$$d{"block"} $$d{"name"} ne "types" $$d{"name"} ne "map" $$d{"name"} ne "geo"
Truth table60%3/5
A and B and C and D
A= $$d{"block"}B= $$d{"name"} ne "types"C= $$d{"name"} ne "map"D= $$d{"name"} ne "geo"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
192 my $inner = $d->{name} eq 'events' ? 'E' : $d->{name} eq 'http' ? 'H' : $d->{name} eq 'server' ? ( $ctx eq 'U' ? 'X' : 'S' )
193 414 ▶ : $d->{name} eq 'location' || $d->{name} eq 'limit_except' ? 'L' : $d->{name} eq 'if' ? 'I' : $d->{name} eq 'upstream' ? 'U' : $ctx;
Branch: 7 branches
BranchTrueFalseTotal
$$d{'name'} eq 'events' ? : 64 350 414
$$d{'name'} eq 'http' ? : 64 286 350
$$d{'name'} eq 'server' ? : 62 224 286
$ctx eq 'U' ? : 0 62 62
$$d{'name'} eq 'location' || $$d{'name'} eq 'limit_except' ? : 222 2 224
$$d{'name'} eq 'if' ? : 0 2 2
$$d{'name'} eq 'upstream' ? : 2 0 2
Condition66%2/3
$$d{"name"} eq "location" or $$d{"name"} eq "limit_except"
l!l&&r!l&&!r
22202
MC/DC50%1/2
$$d{"name"} eq "location" or $$d{"name"} eq "limit_except"
$$d{"name"} eq "location" $$d{"name"} eq "limit_except"
Truth table66%2/3
A or B
A= $$d{"name"} eq "location"B= $$d{"name"} eq "limit_except"
ABresult
1X1
011
000
194 414 $d->{block} = _expand( $p, $d->{block}, $inner );
195 }
196 elsif ( $d->{block} ) {
197 46 my @x;
198 46 for my $e ( @{ $d->{block} } ) {
199 368 ▶ if ( $e->{name} eq 'include' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$e{'name'} eq 'include') { } 0 368 368
200 0 my $f = $e->{args}[0];
201 0 ▶ $f = "/etc/nginx/$f" unless $f =~ m{\A/};
Branch: 1 branch
BranchTrueFalseTotal
unless $f =~ m[\A/] 0 0 0
202 0 push @x, @{ _parse_file( $p, $f, 'T' ) };
203 }
204 368 else { push @x, $e }
205 }
206 46 $d->{block} = \@x;
207 }
208 }
209 573 return \@out;
210 }
211  
212 8 ▶sub _err { my ( $d, $msg ) = @_; die { msg => $msg, file => $d->{file}, line => $d->{line} } }
Subroutine _err: called CC=1 SCAR=0.0
213  
214 3293 ▶sub _nargs {
Subroutine _nargs: called CC=4 SCAR=14.5
215 3293 my ($d) = @_;
216 3293 ▶ my $r = $NARGS{ $d->{name} } or return;
Branch: 1 branch
BranchTrueFalseTotal
my $r = $NARGS{$$d{"name"}} or return 2519 774 3293
217 2519 my $n = @{ $d->{args} };
218 2519 ▶ _err( $d, "invalid number of arguments in \"$d->{name}\" directive" ) if $n < $r->[0] || $n > $r->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $n < $$r[0] or $n > $$r[1] 0 2519 2519
Condition33%1/3
$n < $$r[0] or $n > $$r[1]
l!l&&r!l&&!r
002519
MC/DC0%0/2
$n < $$r[0] or $n > $$r[1]
$n < $$r[0] $n > $$r[1]
Truth table33%1/3
A or B
A= $n < $$r[0]B= $n > $$r[1]
ABresult
1X1
011
000
219 }
220  
221 # Pruefen: Kontext, Argumente, Werte, Doppelte
222 460 ▶sub _check {
Subroutine _check: called CC=27 SCAR=35.1
223 460 my ( $p, $list, $ctx ) = @_;
224 460 my %seen;
225 460 for my $d (@$list) {
226 1486 my $n = $d->{name};
227 1486 ▶ my $k = $ctx eq 'X' ? 1 : _known( $n, $ctx );
Branch: 1 branch
BranchTrueFalseTotal
$ctx eq 'X' ? : 0 1486 1486
228 1486 ▶ $k = 1 if $ctx eq 'U' && $n eq 'server';
Branch: 1 branch
BranchTrueFalseTotal
if $ctx eq "U" and $n eq "server" 4 1482 1486
Condition66%2/3
$ctx eq "U" and $n eq "server"
!ll&&!rl&&r
148204
MC/DC50%1/2
$ctx eq "U" and $n eq "server"
$ctx eq "U" $n eq "server"
Truth table66%2/3
A and B
A= $ctx eq "U"B= $n eq "server"
ABresult
0X0
100
111
229 1486 ▶ _err( $d, "unknown directive \"$n\"" ) unless $k;
Branch: 1 branch
BranchTrueFalseTotal
unless $k 0 1486 1486
230 1486 ▶ _err( $d, "\"$n\" directive is not allowed here" ) if $k < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $k < 0 0 1486 1486
231 1486 ▶ _err( $d, "directive \"$n\" has no opening \"{\"" ) if $BLOCK{$n} && !$d->{block} && !( $n eq 'server' && $ctx eq 'U' );
Branch: 1 branch
BranchTrueFalseTotal
if $BLOCK{$n} and not $$d{"block"} and not $n eq "server" && $ctx eq "U" 0 1486 1486
Condition66%6/9
$BLOCK{$n} and not $$d{"block"} and not $n eq "server" && $ctx eq "U"
!ll&&!rl&&r
148240
$BLOCK{$n} and not $$d{"block"}
!ll&&!rl&&r
10404424
$n eq 'server' && $ctx eq 'U'
!ll&&!rl&&r
004
MC/DC0%0/4
$BLOCK{$n} and not $$d{"block"} and not $n eq "server" && $ctx eq "U"
$BLOCK{$n} not $$d{"block"} $n eq 'server' $ctx eq 'U'
Truth table60%3/5
A and not(B) and not(C && D)
A= $BLOCK{$n}B= not $$d{"block"}C= $n eq 'server'D= $ctx eq 'U'
ABCDresult
0XXX0
10XX0
11110
110X1
11101
232 1486 ▶ _err( $d, "\"$n\" directive is not allowed here" ) if $d->{block} && !$BLOCK{$n};
Branch: 1 branch
BranchTrueFalseTotal
if $$d{"block"} and not $BLOCK{$n} 0 1486 1486
Condition66%2/3
$$d{"block"} and not $BLOCK{$n}
!ll&&!rl&&r
10444420
MC/DC0%0/2
$$d{"block"} and not $BLOCK{$n}
$$d{"block"} not $BLOCK{$n}
Truth table66%2/3
A and not(B)
A= $$d{"block"}B= not $BLOCK{$n}
ABresult
0X0
100
111
233 1486 ▶ _nargs($d) unless $n eq 'server' && $ctx eq 'U';
Branch: 1 branch
BranchTrueFalseTotal
unless $n eq "server" and $ctx eq "U" 1482 4 1486
Condition100%3/3
$n eq "server" and $ctx eq "U"
!ll&&!rl&&r
1420624
MC/DC100%2/2
$n eq "server" and $ctx eq "U"
$n eq "server" $ctx eq "U"
Truth table100%3/3
A and B
A= $n eq "server"B= $ctx eq "U"
ABresult
0X0
100
111
234 1486 ▶ _err( $d, "\"$n\" directive is duplicate" ) if $ONCE{$n} && $seen{$n}++;
Branch: 1 branch
BranchTrueFalseTotal
if $ONCE{$n} and $seen{$n}++ 0 1486 1486
Condition66%2/3
$ONCE{$n} and $seen{$n}++
!ll&&!rl&&r
11773090
MC/DC0%0/2
$ONCE{$n} and $seen{$n}++
$ONCE{$n} $seen{$n}++
Truth table66%2/3
A and B
A= $ONCE{$n}B= $seen{$n}++
ABresult
0X0
100
111
235 1486 _check_value( $p, $d, $ctx );
236 1486 ▶ next unless $d->{block};
Branch: 1 branch
BranchTrueFalseTotal
unless $$d{"block"} 1044 442 1486
237 442 ▶ next if $n eq 'types' || $n eq 'map' || $n eq 'geo' || $n eq 'split_clients';
Branch: 1 branch
BranchTrueFalseTotal
if $n eq "types" or $n eq "map" or $n eq "geo" or $n eq "split_clients" 40 402 442
Condition66%6/9
$n eq "types" or $n eq "map" or $n eq "geo" or $n eq "split_clients"
l!l&&r!l&&!r
400402
$n eq "types" or $n eq "map" or $n eq "geo"
l!l&&r!l&&!r
400402
$n eq "types" or $n eq "map"
l!l&&r!l&&!r
400402
MC/DC25%1/4
$n eq "types" or $n eq "map" or $n eq "geo" or $n eq "split_clients"
$n eq "types" $n eq "map" $n eq "geo" $n eq "split_clients"
Truth table40%2/5
A or B or C or D
A= $n eq "types"B= $n eq "map"C= $n eq "geo"D= $n eq "split_clients"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
238 402 ▶ my $inner = $n eq 'events' ? 'E' : $n eq 'http' ? 'H' : $n eq 'server' ? 'S' : $n eq 'upstream' ? 'U'
Branch: 5 branches
BranchTrueFalseTotal
$n eq 'events' ? : 58 344 402
$n eq 'http' ? : 58 286 344
$n eq 'server' ? : 62 224 286
$n eq 'upstream' ? : 2 222 224
$n eq 'if' ? : 0 222 222
239 : $n eq 'if' ? 'I' : 'L';
240 402 _check( $p, $d->{block}, $inner );
241 }
242 }
243  
244 120 ▶sub _size {
Subroutine _size: called CC=3 SCAR=11.7
245 120 my ($v) = @_;
246 120 ▶ my ( $n, $u ) = ( $v // '' ) =~ /\A(\d+)([kKmMgG]?)\z/ or return undef;
Branch: 1 branch
BranchTrueFalseTotal
() = ($v // "") =~ /\A(\d+)([kKmMgG]?)\z/ or return undef 120 0 120
Condition50%1/2
$v // ""
l!l
1200
MC/DC0%0/1
$v // ""
$v
Truth table50%1/2
A
A= $v
Aresult
11
00
247 120 return $n * { '' => 1, k => 1024, m => 1024**2, g => 1024**3 }->{ lc $u };
248 }
249  
250 3 ▶sub _secs {
Subroutine _secs: called CC=4 SCAR=15.2
251 3 my ($v) = @_;
252 3 ▶ my ( $n, $u ) = ( $v // '' ) =~ /\A(\d+)(ms|s|m|h|d)?\z/ or return undef;
Branch: 1 branch
BranchTrueFalseTotal
() = ($v // "") =~ /\A(\d+)(ms|s|m|h|d)?\z/ or return undef 3 0 3
Condition50%1/2
$v // ""
l!l
30
MC/DC0%0/1
$v // ""
$v
Truth table50%1/2
A
A= $v
Aresult
11
00
253 3 ▶ return $n * { '' => 1, s => 1, ms => 0.001, m => 60, h => 3600, d => 86400 }->{ $u // '' };
Condition50%1/2
$u // ""
l!l
30
MC/DC0%0/1
$u // ""
$u
Truth table50%1/2
A
A= $u
Aresult
11
00
254 }
255  
256 4 my %LISTEN_PARAM = map { $_ => 1 } qw( ssl default_server default http2 proxy_protocol reuseport deferred bind spdy quic );
257  
258 1486 ▶sub _check_value {
Subroutine _check_value: called CC=37 SCAR=46.0
259 1486 my ( $p, $d, $ctx ) = @_;
260 1486 my ( $n, @a ) = ( $d->{name}, @{ $d->{args} } );
261 1486 ▶ if ( $n eq 'listen' ) {
Branch: 11 branches
BranchTrueFalseTotal
if ($n eq 'listen') { } 62 1424 1486
elsif ($n eq 'client_max_body_size') { } 40 1384 1424
elsif ($n =~ /_timeout\z/ and $n ne 'keepalive_timeout') { } 2 1382 1384
elsif ($n eq 'proxy_http_version') { } 2 1380 1382
elsif ($n eq 'ssl_protocols') { } 40 1340 1380
elsif ($n eq 'ssl_verify_client') { } 0 1340 1340
elsif ($n eq 'add_header') { } 42 1298 1340
elsif ($n eq 'return') { } 20 1278 1298
elsif ($n eq 'rewrite') { } 0 1278 1278
elsif ($n eq 'location') { } 222 1056 1278
elsif ($n eq 'allow' or $n eq 'deny') { } 80 976 1056
262 62 for my $x ( @a[ 1 .. $#a ] ) {
263 22 ▶ next if $LISTEN_PARAM{$x} || $x =~ /\A(?:backlog|rcvbuf|sndbuf|ipv6only|so_keepalive|fastopen|accept_filter|setfib)=/;
Branch: 1 branch
BranchTrueFalseTotal
if $LISTEN_PARAM{$x} or $x =~ /\A(?:backlog|rcvbuf|sndbuf|ipv6only|so_keepalive|fastopen|accept_filter|setfib)=/ 22 0 22
Condition33%1/3
$LISTEN_PARAM{$x} or $x =~ /\A(?:backlog|rcvbuf|sndbuf|ipv6only|so_keepalive|fastopen|accept_filter|setfib)=/
l!l&&r!l&&!r
2200
MC/DC0%0/2
$LISTEN_PARAM{$x} or $x =~ /\A(?:backlog|rcvbuf|sndbuf|ipv6only|so_keepalive|fastopen|accept_filter|setfib)=/
$LISTEN_PARAM{$x} $x =~ /\A(?:backlog|rcvbuf|sndbuf|ipv6only|so_keepalive|fastopen|accept_filter|setfib)=/
Truth table33%1/3
A or B
A= $LISTEN_PARAM{$x}B= $x =~ /\A(?:backlog|rcvbuf|sndbuf|ipv6only|so_keepalive|fastopen|accept_filter|setfib)=/
ABresult
1X1
011
000
264 0 _err( $d, "invalid parameter \"$x\"" );
265 }
266 62 ▶ _err( $d, "invalid port in \"$a[0]\" of the \"listen\" directive" )
Branch: 1 branch
BranchTrueFalseTotal
unless $a[0] =~ /\A\d{1,5}\z|\A(?:\[[^\]]+\]|[\w.*-]+):\d{1,5}\z|\A[A-Za-z][\w.-]*\z|\Aunix:/ 0 62 62
267 unless $a[0] =~ /\A\d{1,5}\z|\A(?:\[[^\]]+\]|[\w.*-]+):\d{1,5}\z|\A[A-Za-z][\w.-]*\z|\Aunix:/;
268 }
269 40 ▶ elsif ( $n eq 'client_max_body_size' ) { _err( $d, '"client_max_body_size" directive invalid value' ) unless defined _size( $a[0] ) }
Branch: 1 branch
BranchTrueFalseTotal
unless defined _size($a[0]) 0 40 40
270 2 ▶ elsif ( $n =~ /_timeout\z/ && $n ne 'keepalive_timeout' ) { _err( $d, "\"$n\" directive invalid value" ) unless defined _secs( $a[0] ) }
Branch: 1 branch
BranchTrueFalseTotal
unless defined _secs($a[0]) 0 2 2
Condition66%2/3
$n =~ /_timeout\z/ and $n ne "keepalive_timeout"
!ll&&!rl&&r
138202
MC/DC50%1/2
$n =~ /_timeout\z/ and $n ne "keepalive_timeout"
$n =~ /_timeout\z/ $n ne "keepalive_timeout"
Truth table66%2/3
A and B
A= $n =~ /_timeout\z/B= $n ne "keepalive_timeout"
ABresult
0X0
100
111
271 2 ▶ elsif ( $n eq 'proxy_http_version' ) { _err( $d, "invalid value \"$a[0]\" in \"$n\" directive, it must be \"1.0\" or \"1.1\"" ) unless $a[0] =~ /\A1\.[01]\z/ }
Branch: 1 branch
BranchTrueFalseTotal
unless $a[0] =~ /\A1\.[01]\z/ 0 2 2
272 elsif ( $n eq 'ssl_protocols' ) {
273 40 ▶ for (@a) { _err( $d, "invalid value \"$_\" in \"ssl_protocols\" directive" ) unless /\A(?:SSLv2|SSLv3|TLSv1|TLSv1\.1|TLSv1\.2|TLSv1\.3)\z/ }
Branch: 1 branch
BranchTrueFalseTotal
unless /\A(?:SSLv2|SSLv3|TLSv1|TLSv1\.1|TLSv1\.2|TLSv1\.3)\z/ 0 80 80
274 }
275 0 ▶ elsif ( $n eq 'ssl_verify_client' ) { _err( $d, "invalid value \"$a[0]\" in \"ssl_verify_client\" directive, it must be \"on\", \"off\", \"optional\" or \"optional_no_ca\"" ) unless $a[0] =~ /\A(?:on|off|optional|optional_no_ca)\z/ }
Branch: 1 branch
BranchTrueFalseTotal
unless $a[0] =~ /\A(?:on|off|optional|optional_no_ca)\z/ 0 0 0
276 42 ▶ elsif ( $n eq 'add_header' ) { _err( $d, "invalid parameter \"$a[2]\"" ) if @a == 3 && $a[2] ne 'always' }
Branch: 1 branch
BranchTrueFalseTotal
if @a == 3 and $a[2] ne "always" 0 42 42
Condition33%1/3
@a == 3 and $a[2] ne "always"
!ll&&!rl&&r
4200
MC/DC0%0/2
@a == 3 and $a[2] ne "always"
@a == 3 $a[2] ne "always"
Truth table33%1/3
A and B
A= @a == 3B= $a[2] ne "always"
ABresult
0X0
100
111
277 elsif ( $n eq 'return' ) {
278 20 ▶ _err( $d, "invalid return code \"$a[0]\"" ) unless $a[0] =~ /\A\d{3}\z/ || ( @a == 1 && $a[0] =~ m{\A(?:https?://|\$scheme)} );
Branch: 1 branch
BranchTrueFalseTotal
unless $a[0] =~ /\A\d{3}\z/ or @a == 1 and $a[0] =~ m[\A(?:https?://|\$scheme)] 0 20 20
Condition16%1/6
$a[0] =~ /\A\d{3}\z/ or @a == 1 and $a[0] =~ m[\A(?:https?://|\$scheme)]
l!l&&r!l&&!r
2000
@a == 1 and $a[0] =~ m[\A(?:https?://|\$scheme)]
!ll&&!rl&&r
000
MC/DC0%0/3
$a[0] =~ /\A\d{3}\z/ or @a == 1 and $a[0] =~ m[\A(?:https?://|\$scheme)]
$a[0] =~ /\A\d{3}\z/ @a == 1 $a[0] =~ m[\A(?:https?://|\$scheme)]
Truth table25%1/4
A or B and C
A= $a[0] =~ /\A\d{3}\z/B= @a == 1C= $a[0] =~ m[\A(?:https?://|\$scheme)]
ABCresult
1XX1
0111
00X0
0100
279 }
280 elsif ( $n eq 'rewrite' ) {
281 0 ▶ _err( $d, "invalid parameter \"$a[2]\"" ) if @a == 3 && $a[2] !~ /\A(?:last|break|redirect|permanent)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if @a == 3 and not $a[2] =~ /\A(?:last|break|redirect|permanent)\z/ 0 0 0
Condition0%0/3
@a == 3 and not $a[2] =~ /\A(?:last|break|redirect|permanent)\z/
!ll&&!rl&&r
000
MC/DC0%0/2
@a == 3 and not $a[2] =~ /\A(?:last|break|redirect|permanent)\z/
@a == 3 not $a[2] =~ /\A(?:last|break|redirect|permanent)\z/
Truth table0%0/3
A and not(B)
A= @a == 3B= not $a[2] =~ /\A(?:last|break|redirect|permanent)\z/
ABresult
0X0
100
111
282 0 _regex( $d, $a[0], 0 );
283 }
284 elsif ( $n eq 'location' ) {
285 222 my ( $mod, $uri ) = _loc_args($d);
286 222 ▶ _err( $d, "invalid location modifier \"$a[0]\"" ) unless defined $mod;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $mod 0 222 222
287 222 ▶ _regex( $d, $uri, $mod eq '~*' ) if $mod =~ /~/ && $mod ne '^~';
Branch: 1 branch
BranchTrueFalseTotal
if $mod =~ /~/ and $mod ne "^~" 40 182 222
Condition100%3/3
$mod =~ /~/ and $mod ne "^~"
!ll&&!rl&&r
180240
MC/DC100%2/2
$mod =~ /~/ and $mod ne "^~"
$mod =~ /~/ $mod ne "^~"
Truth table100%3/3
A and B
A= $mod =~ /~/B= $mod ne "^~"
ABresult
0X0
100
111
288 }
289 ▶ elsif ( $n eq 'allow' || $n eq 'deny' ) {
Condition100%3/3
$n eq "allow" or $n eq "deny"
l!l&&r!l&&!r
4040976
MC/DC100%2/2
$n eq "allow" or $n eq "deny"
$n eq "allow" $n eq "deny"
Truth table100%3/3
A or B
A= $n eq "allow"B= $n eq "deny"
ABresult
1X1
011
000
290 80 ▶ _err( $d, "invalid parameter \"$a[0]\"" ) unless $a[0] eq 'all' || $a[0] =~ m{\A\d+\.\d+\.\d+\.\d+(?:/\d{1,2})?\z} || $a[0] =~ /:/;
Branch: 1 branch
BranchTrueFalseTotal
unless $a[0] eq "all" or $a[0] =~ m[\A\d+\.\d+\.\d+\.\d+(?:/\d{1,2})?\z] or $a[0] =~ /:/ 0 80 80
Condition50%3/6
$a[0] eq "all" or $a[0] =~ m[\A\d+\.\d+\.\d+\.\d+(?:/\d{1,2})?\z] or $a[0] =~ /:/
l!l&&r!l&&!r
8000
$a[0] eq "all" or $a[0] =~ m[\A\d+\.\d+\.\d+\.\d+(?:/\d{1,2})?\z]
l!l&&r!l&&!r
40400
MC/DC0%0/3
$a[0] eq "all" or $a[0] =~ m[\A\d+\.\d+\.\d+\.\d+(?:/\d{1,2})?\z] or $a[0] =~ /:/
$a[0] eq "all" $a[0] =~ m[\A\d+\.\d+\.\d+\.\d+(?:/\d{1,2})?\z] $a[0] =~ /:/
Truth table50%2/4
A or B or C
A= $a[0] eq "all"B= $a[0] =~ m[\A\d+\.\d+\.\d+\.\d+(?:/\d{1,2})?\z]C= $a[0] =~ /:/
ABCresult
1XX1
01X1
0011
0000
291 }
292 1486 return;
293 }
294  
295 40 ▶sub _regex {
Subroutine _regex: called CC=3 SCAR=11.3
296 40 my ( $d, $re, $ci ) = @_;
297 40 ▶ my $q = eval { $ci ? qr/$re/i : qr/$re/ };
Branch: 1 branch
BranchTrueFalseTotal
$ci ? : 40 0 40
298 40 ▶ _err( $d, "pcre2_compile() failed: missing closing parenthesis in \"$re\"" ) unless $q;
Branch: 1 branch
BranchTrueFalseTotal
unless $q 0 40 40
299 40 return $q;
300 }
301  
302 478 ▶sub _loc_args {
Subroutine _loc_args: called CC=6 SCAR=18.6
303 478 my ($d) = @_;
304 478 my @a = @{ $d->{args} };
305 478 ▶ return ( @a == 2 ? ( $a[0] =~ /\A(?:=|~|~\*|\^~)\z/ ? @a : ( undef, $a[1] ) ) : () ) if @a == 2;
Branch: 3 branches
BranchTrueFalseTotal
if @a == 2 86 392 478
@a == 2 ? : 86 0 86
$a[0] =~ /\A(?:=|~|~\*|\^~)\z/ ? : 86 0 86
306 392 my $x = $a[0];
307 392 ▶ return ( '@', $x ) if $x =~ /\A\@/;
Branch: 1 branch
BranchTrueFalseTotal
if $x =~ /\A\@/ 0 392 392
308 392 ▶ return ( $1, $2 ) if $x =~ /\A(~\*|\^~|~|=)(.+)\z/s;
Branch: 1 branch
BranchTrueFalseTotal
if $x =~ /\A(~\*|\^~|~|=)(.+)\z/s 0 392 392
309 392 return ( '', $x );
310 }
311  
312 # --- Modell -------------------------------------------------------------------------
313  
314  
315 64 ▶sub parse {
Subroutine parse: called CC=7 SCAR=19.5
Pod documented
316 64 my (%o) = @_;
317 64 ▶ my $conf = $o{conf} // '/etc/nginx/nginx.conf';
Condition100%2/2
$o{"conf"} // "/etc/nginx/nginx.conf"
l!l
2737
MC/DC100%1/1
$o{"conf"} // "/etc/nginx/nginx.conf"
$o{"conf"}
Truth table100%2/2
A
A= $o{"conf"}
Aresult
11
00
318 64 my $p = { read => $o{reader}, glob => $o{glob}, conf_files => {}, depth => 0 };
319 64 my $cfg = eval {
320 64 my $top = _expand( $p, _parse_file( $p, $conf ), 'M' );
321 58 _check( $p, $top, 'M' );
322 58 _model( $p, $top, \%o );
323 };
324 64 ▶ if ( my $e = $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $@) 13 51 64
325 13 ▶ my $msg = ref $e eq 'HASH' ? $e->{msg} . ( $e->{file} ? " in $e->{file}:$e->{line}" : '' ) : "$e";
Branch: 2 branches
BranchTrueFalseTotal
ref $e eq 'HASH' ? : 13 0 13
$$e{'file'} ? : 10 3 13
326 13 $msg =~ s/\s+\z//;
327 13 ▶ return { error => $msg, conf_files => $p->{conf_files}, files => $p->{files} || {} };
Condition100%2/2
$$p{'files'} || {}
l!l
310
MC/DC100%1/1
$$p{'files'} || {}
$$p{'files'}
Truth table100%2/2
A
A= $$p{'files'}
Aresult
11
00
328 }
329 51 $cfg->{conf} = $conf;
330 51 $cfg->{conf_files} = $p->{conf_files};
331 51 ▶ $cfg->{files} = { %{ $p->{conf_files} }, %{ $p->{files} || {} } };
Condition100%2/2
$$p{'files'} || {}
l!l
1536
MC/DC100%1/1
$$p{'files'} || {}
$$p{'files'}
Truth table100%2/2
A
A= $$p{'files'}
Aresult
11
00
332 51 return $cfg;
333 }
334  
335 58 ▶sub _model {
Subroutine _model: called CC=37 SCAR=39.3
336 58 my ( $p, $top, $o ) = @_;
337 58 my ($http) = grep { $_->{name} eq 'http' } @$top;
338 58 ▶ my $hd = $http ? $http->{block} : [];
Branch: 1 branch
BranchTrueFalseTotal
$http ? : 58 0 58
339 58 ▶ my %cfg = ( http => [ grep { $_->{name} ne 'server' && $_->{name} ne 'upstream' && $_->{name} ne 'map' } @$hd ],
Condition83%5/6
$$_{'name'} ne 'server' && $$_{'name'} ne 'upstream' && $$_{'name'} ne 'map'
!ll&&!rl&&r
640360
$$_{"name"} ne "server" and $$_{"name"} ne "upstream"
!ll&&!rl&&r
622360
MC/DC66%2/3
$$_{'name'} ne 'server' && $$_{'name'} ne 'upstream' && $$_{'name'} ne 'map'
$$_{"name"} ne "server" $$_{"name"} ne "upstream" $$_{'name'} ne 'map'
Truth table75%3/4
A and B && C
A= $$_{"name"} ne "server"B= $$_{"name"} ne "upstream"C= $$_{'name'} ne 'map'
ABCresult
0XX0
10X0
1100
1111
340 servers => [], upstreams => {}, maps => {}, warnings => [] );
341 58 for my $u ( grep { $_->{name} eq 'upstream' } @$hd ) {
342 2 my @s;
343 2 for my $s ( grep { $_->{name} eq 'server' } @{ $u->{block} } ) {
344 4 my ( $addr, @f ) = @{ $s->{args} };
345 4 ▶ _err( $s, 'invalid number of arguments in "server" directive' ) unless defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 4 4
346 2 ▶ push @s, { addr => $addr =~ /:\d+\z/ ? $addr : "$addr:80", backup => ( grep { $_ eq 'backup' } @f ) ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
grep({$_ eq 'down';} @f) ? : 0 4 4
347 4 ▶ down => ( grep { $_ eq 'down' } @f ) ? 1 : 0, d => $s };
Branch: 2 branches
BranchTrueFalseTotal
$addr =~ /:\d+\z/ ? : 4 0 4
grep({$_ eq 'backup';} @f) ? : 2 2 4
348 }
349 2 ▶ _err( $u, "no servers are inside upstream" ) unless @s;
Branch: 1 branch
BranchTrueFalseTotal
unless @s 0 2 2
350 2 $cfg{upstreams}{ $u->{args}[0] } = \@s;
351 }
352 58 for my $m ( grep { $_->{name} eq 'map' } @$hd ) {
353 0 my ( $src, $var ) = @{ $m->{args} };
354 0 $var =~ s/\A\$//;
355 0 ▶ $cfg{maps}{$var} = { src => $src, rules => [ map { [ $_->{name}, $_->{args}[0] // '' ] } @{ $m->{block} } ] };
Condition0%0/2
$$_{"args"}[0] // ""
l!l
00
MC/DC0%0/1
$$_{"args"}[0] // ""
$$_{"args"}[0]
Truth table0%0/2
A
A= $$_{"args"}[0]
Aresult
11
00
356 }
357 58 my %listen_default;
358 my %names;
359 58 for my $s ( grep { $_->{name} eq 'server' } @$hd ) {
360 61 my $srv = { d => $s, dirs => $s->{block}, listens => [], names => [], locations => _locations( $s->{block} ) };
361 61 for my $l ( grep { $_->{name} eq 'listen' } @{ $s->{block} } ) {
362 61 my ( $a, @f ) = @{ $l->{args} };
363 61 ▶ next if $a =~ /\A\[/ || $a =~ /\Aunix:/; # IPv6, Unix-Sockets: nicht nachgebildet
Branch: 1 branch
BranchTrueFalseTotal
if $a =~ /\A\[/ or $a =~ /\Aunix:/ 0 61 61
Condition33%1/3
$a =~ /\A\[/ or $a =~ /\Aunix:/
l!l&&r!l&&!r
0061
MC/DC0%0/2
$a =~ /\A\[/ or $a =~ /\Aunix:/
$a =~ /\A\[/ $a =~ /\Aunix:/
Truth table33%1/3
A or B
A= $a =~ /\A\[/B= $a =~ /\Aunix:/
ABresult
1X1
011
000
364 61 ▶ my ( $ip, $port ) = $a =~ /\A(.+):(\d+)\z/ ? ( $1, $2 ) : $a =~ /\A\d+\z/ ? ( '0.0.0.0', $a ) : ( $a, 80 );
Branch: 2 branches
BranchTrueFalseTotal
$a =~ /\A(.+):(\d+)\z/ ? : 0 61 61
$a =~ /\A\d+\z/ ? : 61 0 61
365 61 ▶ $ip = '0.0.0.0' if $ip eq '*';
Branch: 1 branch
BranchTrueFalseTotal
if $ip eq "*" 0 61 61
366 61 ▶ $ip = '127.0.0.1' if $ip eq 'localhost';
Branch: 1 branch
BranchTrueFalseTotal
if $ip eq "localhost" 0 61 61
367 61 ▶ my $def = ( grep { $_ eq 'default_server' || $_ eq 'default' } @f ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
grep({$_ eq 'default_server' or $_ eq 'default';} @f) ? : 4 57 61
Condition66%2/3
$_ eq 'default_server' || $_ eq 'default'
l!l&&r!l&&!r
4018
MC/DC50%1/2
$_ eq 'default_server' || $_ eq 'default'
$_ eq 'default_server' $_ eq 'default'
Truth table66%2/3
A || B
A= $_ eq 'default_server'B= $_ eq 'default'
ABresult
1X1
011
000
368 61 ▶ my $ssl = ( grep { $_ eq 'ssl' } @f ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
grep({$_ eq 'ssl';} @f) ? : 18 43 61
369 61 ▶ if ( $def && $listen_default{"$ip:$port"}++ ) { _err( $l, "a duplicate default server for $ip:$port" ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($def and $listen_default{"${ip}:$port"}++) 1 60 61
Condition100%3/3
$def and $listen_default{"${ip}:$port"}++
!ll&&!rl&&r
5731
MC/DC100%2/2
$def and $listen_default{"${ip}:$port"}++
$def $listen_default{"${ip}:$port"}++
Truth table100%3/3
A and B
A= $defB= $listen_default{"${ip}:$port"}++
ABresult
0X0
100
111
370 60 push @{ $srv->{listens} }, { ip => $ip, port => 0 + $port, default => $def, ssl => $ssl };
371 }
372 0 ▶ push @{ $srv->{listens} }, { ip => '0.0.0.0', port => 80, default => 0, ssl => 0 } unless grep { $_->{name} eq 'listen' } @{ $s->{block} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$$_{"name"} eq "listen";} @{$$s{"block"};} 0 60 60
373 60 $srv->{names} = [ map { lc } map { @{ $_->{args} } } grep { $_->{name} eq 'server_name' } @{ $s->{block} } ];
374 60 for my $n ( @{ $srv->{names} } ) {
375 59 for my $l ( @{ $srv->{listens} } ) {
376 0 push @{ $cfg{warnings} }, "conflicting server name \"$n\" on $l->{ip}:$l->{port}, ignored"
377 59 ▶ if length $n && $n ne '_' && $names{"$n $l->{ip}:$l->{port}"}++;
Branch: 1 branch
BranchTrueFalseTotal
if length $n and $n ne "_" and $names{qq[$n $$l{"ip"}:$$l{"port"}]}++ 0 59 59
Condition66%4/6
length $n and $n ne "_" and $names{qq[$n $$l{"ip"}:$$l{"port"}]}++
!ll&&!rl&&r
2570
length $n and $n ne "_"
!ll&&!rl&&r
0257
MC/DC0%0/3
length $n and $n ne "_" and $names{qq[$n $$l{"ip"}:$$l{"port"}]}++
length $n $n ne "_" $names{qq[$n $$l{"ip"}:$$l{"port"}]}++
Truth table50%2/4
A and B and C
A= length $nB= $n ne "_"C= $names{qq[$n $$l{"ip"}:$$l{"port"}]}++
ABCresult
0XX0
10X0
1100
1111
378 }
379 }
380 60 push @{ $cfg{servers} }, $srv;
381 }
382 # Sockets: ssl gilt fuer alle Server des Sockets
383 57 my %ssl;
384 57 ▶ for my $srv ( @{ $cfg{servers} } ) { $ssl{"$_->{ip}:$_->{port}"} ||= $_->{ssl} for @{ $srv->{listens} } }
Condition66%2/3
$ssl{qq[$$_{"ip"}:$$_{"port"}]} ||= $$_{"ssl"}
l!l&&r!l&&!r
01841
MC/DC50%1/2
$ssl{qq[$$_{"ip"}:$$_{"port"}]} ||= $$_{"ssl"}
$ssl{qq[$$_{"ip"}:$$_{"port"}]} $$_{"ssl"}
Truth table66%2/3
A ||= B
A= $ssl{qq[$$_{"ip"}:$$_{"port"}]}B= $$_{"ssl"}
ABresult
1X1
011
000
385 57 $cfg{ssl_sockets} = \%ssl;
386 # Pruefungen, die das Modell brauchen
387 57 ▶ my $cat = $o->{state} ? _pki()->can('catalog')->( $o->{state} ) : { certs => {}, keys => {} };
Branch: 1 branch
BranchTrueFalseTotal
$$o{'state'} ? : 57 0 57
388 57 for my $srv ( @{ $cfg{servers} } ) {
389 59 _check_server( $p, \%cfg, $srv, $o, $cat );
390 }
391 51 return \%cfg;
392 }
393  
394 278 ▶sub _locations {
Subroutine _locations: called CC=7 SCAR=19.8
395 278 my ($list) = @_;
396 278 my @l;
397 278 for my $d ( grep { $_->{name} eq 'location' } @$list ) {
398 217 my ( $mod, $uri ) = _loc_args($d);
399 217 my $loc = { mod => $mod, uri => $uri, d => $d, dirs => $d->{block}, children => _locations( $d->{block} ) };
400 217 ▶ $loc->{re} = $mod eq '~*' ? qr/$uri/i : qr/$uri/ if $mod eq '~' || $mod eq '~*';
Branch: 2 branches
BranchTrueFalseTotal
if $mod eq "~" or $mod eq "~*" 39 178 217
$mod eq '~*' ? : 39 0 39
Condition66%2/3
$mod eq "~" or $mod eq "~*"
l!l&&r!l&&!r
039178
MC/DC50%1/2
$mod eq "~" or $mod eq "~*"
$mod eq "~" $mod eq "~*"
Truth table66%2/3
A or B
A= $mod eq "~"B= $mod eq "~*"
ABresult
1X1
011
000
401 217 ▶ _err( $d, "duplicate location \"$uri\"" ) if grep { $_->{mod} eq $mod && $_->{uri} eq $uri } @l;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$$_{"mod"} eq $mod and $$_{"uri"} eq $uri;} @l 0 217 217
Condition66%2/3
$$_{'mod'} eq $mod && $$_{'uri'} eq $uri
!ll&&!rl&&r
1662440
MC/DC0%0/2
$$_{'mod'} eq $mod && $$_{'uri'} eq $uri
$$_{'mod'} eq $mod $$_{'uri'} eq $uri
Truth table66%2/3
A && B
A= $$_{'mod'} eq $modB= $$_{'uri'} eq $uri
ABresult
0X0
100
111
402 217 push @l, $loc;
403 }
404 278 return \@l;
405 }
406  
407 4 my %VARS = map { $_ => 1 } qw( host http_host scheme request_uri uri args query_string is_args remote_addr
408 proxy_add_x_forwarded_for server_name server_port server_addr request_method proxy_host proxy_port document_root
409 request_filename binary_remote_addr ssl_client_verify ssl_protocol ssl_server_name request remote_port
410 https server_protocol content_length content_type realpath_root nginx_version time_iso8601 msec status
411 request_id hostname connection request_time upstream_addr ssl_client_s_dn ssl_cipher body_bytes_sent );
412  
413 262 ▶sub _check_vars {
Subroutine _check_vars: called CC=7 SCAR=19.5
414 262 my ( $cfg, $d, $setvars ) = @_;
415 262 for my $a ( @{ $d->{args} } ) {
416 333 ▶ while ( $a =~ /\$\{?([A-Za-z_]\w*)\}?/g ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a =~ /\$\{?([A-Za-z_]\w*)\}?/g) 11 332 343
417 11 my $v = $1;
418 11 ▶ next if $VARS{$v} || $cfg->{maps}{$v} || $setvars->{$v} || $v =~ /\A(?:http|arg|cookie|sent_http|upstream_http|sent_trailer)_/;
Branch: 1 branch
BranchTrueFalseTotal
if $VARS{$v} or $$cfg{"maps"}{$v} or $$setvars{$v} or $v =~ /\A(?:http|arg|cookie|sent_http|upstream_http|sent_trailer)_/ 10 1 11
Condition77%7/9
$VARS{$v} or $$cfg{"maps"}{$v} or $$setvars{$v} or $v =~ /\A(?:http|arg|cookie|sent_http|upstream_http|sent_trailer)_/
l!l&&r!l&&!r
821
$VARS{$v} or $$cfg{"maps"}{$v} or $$setvars{$v}
l!l&&r!l&&!r
803
$VARS{$v} or $$cfg{"maps"}{$v}
l!l&&r!l&&!r
803
MC/DC50%2/4
$VARS{$v} or $$cfg{"maps"}{$v} or $$setvars{$v} or $v =~ /\A(?:http|arg|cookie|sent_http|upstream_http|sent_trailer)_/
$VARS{$v} $$cfg{"maps"}{$v} $$setvars{$v} $v =~ /\A(?:http|arg|cookie|sent_http|upstream_http|sent_trailer)_/
Truth table60%3/5
A or B or C or D
A= $VARS{$v}B= $$cfg{"maps"}{$v}C= $$setvars{$v}D= $v =~ /\A(?:http|arg|cookie|sent_http|upstream_http|sent_trailer)_/
ABCDresult
1XXX1
01XX1
001X1
00011
00000
419 1 _err( $d, "unknown \"$v\" variable" );
420 }
421 }
422 }
423  
424 267 ▶sub _walk { my ( $list, $cb, @up ) = @_; for my $d (@$list) { $cb->( $d, @up ); _walk( $d->{block}, $cb, @up, $d ) if $d->{block} && $d->{name} ne 'map' && $d->{name} ne 'types' } }
Subroutine _walk: called CC=5 SCAR=16.3
Branch: 1 branch
BranchTrueFalseTotal
if $$d{"block"} and $$d{"name"} ne "map" and $$d{"name"} ne "types" 208 528 736
Condition66%4/6
$$d{"block"} and $$d{"name"} ne "map" and $$d{"name"} ne "types"
!ll&&!rl&&r
5280208
$$d{"block"} and $$d{"name"} ne "map"
!ll&&!rl&&r
5280208
MC/DC33%1/3
$$d{"block"} and $$d{"name"} ne "map" and $$d{"name"} ne "types"
$$d{"block"} $$d{"name"} ne "map" $$d{"name"} ne "types"
Truth table50%2/4
A and B and C
A= $$d{"block"}B= $$d{"name"} ne "map"C= $$d{"name"} ne "types"
ABCresult
0XX0
10X0
1100
1111
425  
426 59 ▶sub _check_server {
Subroutine _check_server: called CC=37 SCAR=43.0
427 59 my ( $p, $cfg, $srv, $o, $cat ) = @_;
428 0 ▶ my %set = map { ( $_->{args}[0] // '' ) =~ /\A\$(\w+)/ ? ( $1 => 1 ) : () } grep { $_->{name} eq 'set' } map { _all($_) } $srv->{d};
Branch: 1 branch
BranchTrueFalseTotal
($$_{'args'}[0] // '') =~ /\A\$(\w+)/ ? : 0 0 0
Condition0%0/2
$$_{"args"}[0] // ""
l!l
00
MC/DC0%0/1
$$_{"args"}[0] // ""
$$_{"args"}[0]
Truth table0%0/2
A
A= $$_{"args"}[0]
Aresult
11
00
429 739 ▶ _walk( $srv->{dirs}, sub {
Subroutine __ANON__: called CC=17 SCAR=29.1
430 739 my ( $d, @up ) = @_;
431 739 ▶ _check_vars( $cfg, $d, \%set ) if $d->{name} =~ /\A(?:proxy_pass|proxy_set_header|add_header|return|rewrite|try_files|set|root|alias)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $$d{"name"} =~ /\A(?:proxy_pass|proxy_set_header|add_header|return|rewrite|try_files|set|root|alias)\z/ 262 477 739
432 738 ▶ if ( $d->{name} eq 'proxy_pass' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$d{"name"} eq "proxy_pass") 115 623 738
433 115 my $url = $d->{args}[0];
434 115 ▶ my ( $sch, $host, $port, $uri ) = $url =~ m{\A(https?)://([^/:]+)(?::(\d+))?(/.*)?\z} or _err( $d, "invalid URL prefix in \"$url\"" );
Branch: 1 branch
BranchTrueFalseTotal
() = $url =~ m[\A(https?)://([^/:]+)(?::(\d+))?(/.*)?\z] or _err($d, qq[invalid URL prefix in "$url"]) 115 0 115
435 115 my ($loc) = grep { $_->{name} eq 'location' } reverse @up;
436 115 my $in_if = grep { $_->{name} eq 'if' } @up;
437 115 ▶ if ( defined $uri && $url !~ /\$/ && ( $in_if || $loc && ( _loc_args($loc) )[0] =~ /\A(?:~|~\*|\@)\z/ ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $uri and not $url =~ /\$/ and $in_if || $loc && (_loc_args($loc))[0] =~ /\A(?:~|~\*|\@)\z/) 1 114 115
Condition75%9/12
defined $uri and not $url =~ /\$/ and $in_if || $loc && (_loc_args($loc))[0] =~ /\A(?:~|~\*|\@)\z/
!ll&&!rl&&r
76381
defined $uri and not $url =~ /\$/
!ll&&!rl&&r
76039
$in_if or $loc and (_loc_args($loc))[0] =~ /\A(?:~|~\*|\@)\z/
l!l&&r!l&&!r
0138
$loc and (_loc_args($loc))[0] =~ /\A(?:~|~\*|\@)\z/
!ll&&!rl&&r
0381
MC/DC40%2/5
defined $uri and not $url =~ /\$/ and $in_if || $loc && (_loc_args($loc))[0] =~ /\A(?:~|~\*|\@)\z/
defined $uri not $url =~ /\$/ $in_if $loc (_loc_args($loc))[0] =~ /\A(?:~|~\*|\@)\z/
Truth table50%3/6
A and not(B) and C or D and E
A= defined $uriB= not $url =~ /\$/C= $in_ifD= $locE= (_loc_args($loc))[0] =~ /\A(?:~|~\*|\@)\z/
ABCDEresult
0XXXX0
10XXX0
1100X0
110100
111XX1
110111
438 1 _err( $d, '"proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except" block' );
439 }
440 114 ▶ if ( $host !~ /\$/ && !( !defined $port && $cfg->{upstreams}{$host} ) && $host !~ /\A\d+\.\d+\.\d+\.\d+\z/ && $host ne 'localhost' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $host =~ /\$/ || !defined($port) && $$cfg{"upstreams"}{$host} || $host =~ /\A\d+\.\d+\.\d+\.\d+\z/ and $host ne "localhost") 1 113 114
Condition83%10/12
not $host =~ /\$/ || !defined($port) && $$cfg{"upstreams"}{$host} || $host =~ /\A\d+\.\d+\.\d+\.\d+\z/ and $host ne "localhost"
!ll&&!rl&&r
11301
$host =~ /\$/ || !defined($port) && $$cfg{'upstreams'}{$host} || $host =~ /\A\d+\.\d+\.\d+\.\d+\z/
l!l&&r!l&&!r
21111
$host =~ /\$/ or not defined $port and $$cfg{"upstreams"}{$host}
l!l&&r!l&&!r
02112
not defined $port and $$cfg{"upstreams"}{$host}
!ll&&!rl&&r
11112
MC/DC20%1/5
not $host =~ /\$/ || !defined($port) && $$cfg{"upstreams"}{$host} || $host =~ /\A\d+\.\d+\.\d+\.\d+\z/ and $host ne "localhost"
$host =~ /\$/ not defined $port $$cfg{"upstreams"}{$host} $host =~ /\A\d+\.\d+\.\d+\.\d+\z/ $host ne "localhost"
Truth table37%3/8
not(A or not(B) and C || D) and E
A= $host =~ /\$/B= not defined $portC= $$cfg{"upstreams"}{$host}D= $host =~ /\A\d+\.\d+\.\d+\.\d+\z/E= $host ne "localhost"
ABCDEresult
1XXXX0
011XX0
00X1X0
0101X0
00X000
010000
00X011
010011
441 1 ▶ my ($ip) = $o->{dev} ? _L()->can('_resolve')->( $o->{dev}, $host ) : ();
Branch: 1 branch
BranchTrueFalseTotal
$$o{'dev'} ? : 1 0 1
442 1 ▶ _err( $d, "host not found in upstream \"$host" . ( defined $port ? ":$port" : '' ) . "\"" ) unless defined $ip;
Branch: 2 branches
BranchTrueFalseTotal
unless defined $ip 1 0 1
defined $port ? : 0 1 1
443 }
444 }
445 59 } );
446 56 for my $u ( values %{ $cfg->{upstreams} } ) {
447 2 for my $s (@$u) {
448 4 my ($h) = $s->{addr} =~ /\A(.+):\d+\z/;
449 4 ▶ next if $h =~ /\A\d+\.\d+\.\d+\.\d+\z/ || $h eq 'localhost' || $s->{checked}++;
Branch: 1 branch
BranchTrueFalseTotal
if $h =~ /\A\d+\.\d+\.\d+\.\d+\z/ or $h eq "localhost" or $$s{"checked"}++ 4 0 4
Condition33%2/6
$h =~ /\A\d+\.\d+\.\d+\.\d+\z/ or $h eq "localhost" or $$s{"checked"}++
l!l&&r!l&&!r
400
$h =~ /\A\d+\.\d+\.\d+\.\d+\z/ or $h eq "localhost"
l!l&&r!l&&!r
400
MC/DC0%0/3
$h =~ /\A\d+\.\d+\.\d+\.\d+\z/ or $h eq "localhost" or $$s{"checked"}++
$h =~ /\A\d+\.\d+\.\d+\.\d+\z/ $h eq "localhost" $$s{"checked"}++
Truth table25%1/4
A or B or C
A= $h =~ /\A\d+\.\d+\.\d+\.\d+\z/B= $h eq "localhost"C= $$s{"checked"}++
ABCresult
1XX1
01X1
0011
0000
450 0 ▶ my ($ip) = $o->{dev} ? _L()->can('_resolve')->( $o->{dev}, $h ) : ();
Branch: 1 branch
BranchTrueFalseTotal
$$o{'dev'} ? : 0 0 0
451 0 ▶ _err( $s->{d}, "host not found in upstream \"$s->{addr}\"" ) unless defined $ip;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ip 0 0 0
452 }
453 }
454 # TLS: Zertifikat und Schluessel laden
455 56 ▶ return unless grep { $_->{ssl} || $cfg->{ssl_sockets}{"$_->{ip}:$_->{port}"} } @{ $srv->{listens} };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$$_{"ssl"} or $$cfg{"ssl_sockets"}{qq[$$_{"ip"}:$$_{"port"}]};} @{$$srv{"listens"};} 38 18 56
Condition66%2/3
$$_{'ssl'} || $$cfg{'ssl_sockets'}{"$$_{'ip'}:$$_{'port'}"}
l!l&&r!l&&!r
18038
MC/DC50%1/2
$$_{'ssl'} || $$cfg{'ssl_sockets'}{"$$_{'ip'}:$$_{'port'}"}
$$_{'ssl'} $$cfg{'ssl_sockets'}{"$$_{'ip'}:$$_{'port'}"}
Truth table66%2/3
A || B
A= $$_{'ssl'}B= $$cfg{'ssl_sockets'}{"$$_{'ip'}:$$_{'port'}"}
ABresult
1X1
011
000
456 18 my $cert = _eff1( $cfg, [ $srv->{dirs} ], 'ssl_certificate' );
457 18 my $key = _eff1( $cfg, [ $srv->{dirs} ], 'ssl_certificate_key' );
458 18 ▶ my ($ld) = grep { $_->{name} eq 'listen' && grep { $_ eq 'ssl' } @{ $_->{args} } } @{ $srv->{dirs} };
Condition66%2/3
$$_{'name'} eq 'listen' && grep({$_ eq 'ssl';} @{$$_{'args'};})
!ll&&!rl&&r
73018
MC/DC50%1/2
$$_{'name'} eq 'listen' && grep({$_ eq 'ssl';} @{$$_{'args'};})
$$_{'name'} eq 'listen' grep({$_ eq 'ssl';} @{$$_{'args'};})
Truth table66%2/3
A && B
A= $$_{'name'} eq 'listen'B= grep({$_ eq 'ssl';} @{$$_{'args'};})
ABresult
0X0
100
111
459 18 ▶ $ld //= $srv->{d};
Condition33%1/3
$ld //= $$srv{"d"}
l!l&&r!l&&!r
1800
MC/DC0%0/2
$ld //= $$srv{"d"}
$ld $$srv{"d"}
Truth table33%1/3
A //= B
A= $ldB= $$srv{"d"}
ABresult
1X1
011
000
460 18 ▶ _err( $ld, 'no "ssl_certificate" is defined for the "listen ... ssl" directive' ) unless $cert;
Branch: 1 branch
BranchTrueFalseTotal
unless $cert 0 18 18
461 18 ▶ _err( $ld, 'no "ssl_certificate_key" is defined for certificate "' . $cert->{args}[0] . '"' ) unless $key;
Branch: 1 branch
BranchTrueFalseTotal
unless $key 0 18 18
462 18 ▶ my $read = sub { my ($f) = @_; my $t = $p->{read}->($f); $p->{files}{$f} = $t if defined $t; return $t };
Subroutine __ANON__: called CC=2 SCAR=7.0
Branch: 1 branch
BranchTrueFalseTotal
if defined $t 37 0 37
463 18 my $cf = $cert->{args}[0];
464 18 my $ct = $read->($cf);
465 18 ▶ die { msg => "cannot load certificate \"$cf\": BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:calling fopen($cf, r) error:10000080:BIO routines::no such file)" }
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ct 0 18 18
466 unless defined $ct;
467 18 ▶ my @chain = map { $_->{id} } grep { $_->{kind} eq 'cert' && $cat->{certs}{ $_->{id} } } _pki()->can('blocks')->($ct);
Condition33%1/3
$$_{'kind'} eq 'cert' && $$cat{'certs'}{$$_{'id'}}
!ll&&!rl&&r
0024
MC/DC0%0/2
$$_{'kind'} eq 'cert' && $$cat{'certs'}{$$_{'id'}}
$$_{'kind'} eq 'cert' $$cat{'certs'}{$$_{'id'}}
Truth table33%1/3
A && B
A= $$_{'kind'} eq 'cert'B= $$cat{'certs'}{$$_{'id'}}
ABresult
0X0
100
111
468 18 ▶ die { msg => "cannot load certificate \"$cf\": PEM_read_bio_X509_AUX() failed (SSL: error:0480006C:PEM routines::no start line:Expecting: TRUSTED CERTIFICATE)" } unless @chain;
Branch: 1 branch
BranchTrueFalseTotal
unless @chain 0 18 18
469 18 my $kf = $key->{args}[0];
470 18 my $kt = $read->($kf);
471 18 ▶ die { msg => "cannot load certificate key \"$kf\": BIO_new_file() failed (SSL: error:80000002:system library::No such file or directory:calling fopen($kf, r) error:10000080:BIO routines::no such file)" }
Branch: 1 branch
BranchTrueFalseTotal
unless defined $kt 0 18 18
472 unless defined $kt;
473 18 ▶ my ($kb) = grep { $_->{kind} eq 'key' || $_->{kind} eq 'enckey' } _pki()->can('blocks')->($kt);
Condition66%2/3
$$_{'kind'} eq 'key' || $$_{'kind'} eq 'enckey'
l!l&&r!l&&!r
1530
MC/DC0%0/2
$$_{'kind'} eq 'key' || $$_{'kind'} eq 'enckey'
$$_{'kind'} eq 'key' $$_{'kind'} eq 'enckey'
Truth table66%2/3
A || B
A= $$_{'kind'} eq 'key'B= $$_{'kind'} eq 'enckey'
ABresult
1X1
011
000
474 die { msg => "cannot load certificate key \"$kf\": PEM_read_bio_PrivateKey() failed (SSL: error:1E08010C:DECODER routines::unsupported:No supported data to decode.)" }
475 18 ▶ unless $kb && $cat->{keys}{ $kb->{id} };
Branch: 1 branch
BranchTrueFalseTotal
unless $kb and $$cat{"keys"}{$$kb{"id"}} 0 18 18
Condition33%1/3
$kb and $$cat{"keys"}{$$kb{"id"}}
!ll&&!rl&&r
0018
MC/DC0%0/2
$kb and $$cat{"keys"}{$$kb{"id"}}
$kb $$cat{"keys"}{$$kb{"id"}}
Truth table33%1/3
A and B
A= $kbB= $$cat{"keys"}{$$kb{"id"}}
ABresult
0X0
100
111
476 18 ▶ if ( $kb->{kind} eq 'enckey' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$kb{"kind"} eq "enckey") 3 15 18
477 3 my $pf = _eff1( $cfg, [ $srv->{dirs} ], 'ssl_password_file' );
478 3 ▶ my $want = $cat->{keys}{ $kb->{id} }{passphrase} // '';
Condition50%1/2
$$cat{"keys"}{$$kb{"id"}}{"passphrase"} // ""
l!l
30
MC/DC0%0/1
$$cat{"keys"}{$$kb{"id"}}{"passphrase"} // ""
$$cat{"keys"}{$$kb{"id"}}{"passphrase"}
Truth table50%1/2
A
A= $$cat{"keys"}{$$kb{"id"}}{"passphrase"}
Aresult
11
00
479 3 ▶ my $pt = $pf ? $read->( $pf->{args}[0] ) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$pf ? : 1 2 3
480 3 ▶ die { msg => "open() \"$pf->{args}[0]\" failed (2: No such file or directory)", file => $pf->{file}, line => $pf->{line} } if $pf && !defined $pt;
Branch: 1 branch
BranchTrueFalseTotal
if $pf and not defined $pt 0 3 3
Condition66%2/3
$pf and not defined $pt
!ll&&!rl&&r
210
MC/DC0%0/2
$pf and not defined $pt
$pf not defined $pt
Truth table66%2/3
A and not(B)
A= $pfB= not defined $pt
ABresult
0X0
100
111
481 die { msg => "cannot load certificate key \"$kf\": PEM_read_bio_PrivateKey() failed (SSL: error:1400006B:UI routines::processing error:while reading strings error:0480006D:PEM routines::problems getting password error:07880109:common libcrypto routines::interrupted or cancelled)" }
482 3 ▶ unless defined $pt && grep { $_ eq $want } split /\n/, $pt;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pt and grep {$_ eq $want;} split(/\n/, $pt, 0) 2 1 3
Condition66%2/3
defined $pt and grep {$_ eq $want;} split(/\n/, $pt, 0)
!ll&&!rl&&r
201
MC/DC50%1/2
defined $pt and grep {$_ eq $want;} split(/\n/, $pt, 0)
defined $pt grep {$_ eq $want;} split(/\n/, $pt, 0)
Truth table66%2/3
A and B
A= defined $ptB= grep {$_ eq $want;} split(/\n/, $pt, 0)
ABresult
0X0
100
111
483 }
484 16 my $leaf = $cat->{certs}{ $chain[0] };
485 die { msg => "SSL_CTX_use_PrivateKey(\"$kf\") failed (SSL: error:05800074:x509 certificate routines::key values mismatch)" }
486 16 ▶ unless ( $leaf->{key} // '' ) eq $kb->{id};
Branch: 1 branch
BranchTrueFalseTotal
unless ($$leaf{"key"} // "") eq $$kb{"id"} 1 15 16
Condition50%1/2
$$leaf{"key"} // ""
l!l
160
MC/DC0%0/1
$$leaf{"key"} // ""
$$leaf{"key"}
Truth table50%1/2
A
A= $$leaf{"key"}
Aresult
11
00
487 15 $srv->{tls} = { chain => \@chain, key => $kb->{id} };
488 15 ▶ if ( my $cc = _eff1( $cfg, [ $srv->{dirs} ], 'ssl_client_certificate' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cc = _eff1($cfg, [$$srv{"dirs"}], "ssl_client_certificate")) 0 15 15
489 0 my $t = $read->( $cc->{args}[0] );
490 0 ▶ die { msg => "SSL_CTX_load_verify_locations(\"$cc->{args}[0]\") failed (SSL: error:80000002:system library::No such file or directory)" } unless defined $t;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $t 0 0 0
491 0 $srv->{tls}{client_ca} = [ map { $_->{id} } grep { $_->{kind} eq 'cert' } _pki()->can('blocks')->($t) ];
492 }
493 15 my $vc = _eff1( $cfg, [ $srv->{dirs} ], 'ssl_verify_client' );
494 15 ▶ if ( $vc && $vc->{args}[0] =~ /\A(?:on|optional)\z/ && !$srv->{tls}{client_ca} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($vc and $$vc{"args"}[0] =~ /\A(?:on|optional)\z/ and not $$srv{"tls"}{"client_ca"}) 0 15 15
Condition33%2/6
$vc and $$vc{"args"}[0] =~ /\A(?:on|optional)\z/ and not $$srv{"tls"}{"client_ca"}
!ll&&!rl&&r
1500
$vc and $$vc{"args"}[0] =~ /\A(?:on|optional)\z/
!ll&&!rl&&r
1500
MC/DC0%0/3
$vc and $$vc{"args"}[0] =~ /\A(?:on|optional)\z/ and not $$srv{"tls"}{"client_ca"}
$vc $$vc{"args"}[0] =~ /\A(?:on|optional)\z/ not $$srv{"tls"}{"client_ca"}
Truth table25%1/4
A and B and not(C)
A= $vcB= $$vc{"args"}[0] =~ /\A(?:on|optional)\z/C= not $$srv{"tls"}{"client_ca"}
ABCresult
0XX0
10X0
1100
1111
495 0 _err( $vc, 'no ssl_client_certificate for ssl_verify_client' );
496 }
497 15 return;
498 }
499  
500 823 ▶sub _all { my ($d) = @_; return ( $d, map { _all($_) } @{ $d->{block} || [] } ) }
Subroutine _all: called CC=2 SCAR=6.9
Condition100%2/2
$$d{'block'} || []
l!l
276547
MC/DC100%1/1
$$d{'block'} || []
$$d{'block'}
Truth table100%2/2
A
A= $$d{'block'}
Aresult
11
00
501  
502 # wirksame Direktive (eine): innerste Ebene zuerst; Ebenen = Listen von Direktiven
503 346 ▶sub _eff1 {
Subroutine _eff1: called CC=3 SCAR=11.0
504 346 my ( $cfg, $levels, $name ) = @_;
505 346 for my $l ( reverse( $cfg->{http}, @$levels ) ) {
506 804 my ($d) = grep { $_->{name} eq $name } @$l;
507 804 ▶ return $d if $d;
Branch: 1 branch
BranchTrueFalseTotal
if $d 126 678 804
508 }
509 220 return undef;
510 }
511  
512 # wirksame Liste (proxy_set_header, add_header, allow/deny): die innerste Ebene, die eine hat
513 275 ▶sub _effn {
Subroutine _effn: called CC=3 SCAR=11.0
514 275 my ( $cfg, $levels, @names ) = @_;
515 275 my %n = map { $_ => 1 } @names;
516 275 for my $l ( reverse( $cfg->{http}, @$levels ) ) {
517 727 my @d = grep { $n{ $_->{name} } } @$l;
518 727 ▶ return @d if @d;
Branch: 1 branch
BranchTrueFalseTotal
if @d 88 639 727
519 }
520 187 return ();
521 }
522  
523 # --- Laden ----------------------------------------------------------------------------
524  
525 50 ▶sub _live_reader {
Subroutine _live_reader: called CC=1 SCAR=0.0
526 50 my ( $dev, $over ) = @_;
527 166 ▶ return sub {
Subroutine __ANON__: called CC=4 SCAR=13.9
528 166 my ($f) = @_;
529 166 ▶ return $over->{$f} if $over && exists $over->{$f};
Branch: 1 branch
BranchTrueFalseTotal
if $over and exists $$over{$f} 1 165 166
Condition100%3/3
$over and exists $$over{$f}
!ll&&!rl&&r
16321
MC/DC100%2/2
$over and exists $$over{$f}
$over exists $$over{$f}
Truth table100%3/3
A and B
A= $overB= exists $$over{$f}
ABresult
0X0
100
111
530 165 my $t = _ftext( $dev, $f );
531 165 ▶ return $t // $BUILTIN{$f};
Condition66%2/3
$t // $BUILTIN{$f}
l!l&&r!l&&!r
128370
MC/DC0%0/2
$t // $BUILTIN{$f}
$t $BUILTIN{$f}
Truth table66%2/3
A // B
A= $tB= $BUILTIN{$f}
ABresult
1X1
011
000
532 50 };
533 }
534  
535 50 ▶sub _live_glob {
Subroutine _live_glob: called CC=1 SCAR=0.1
536 50 my ( $dev, $over ) = @_;
537 124 ▶ return sub {
Subroutine __ANON__: called CC=6 SCAR=18.4
538 124 my $re = _glob_re( $_[0] );
539 124 ▶ my %p = map { $_ => 1 } keys %{ $dev->{files} || {} }, keys %{ $over || {} };
Condition75%3/4
$$dev{'files'} || {}
l!l
1240
$over || {}
l!l
3121
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
MC/DC100%1/1
$over || {}
$over
Truth table50%1/2
A
A= $$dev{'files'}
Aresult
11
00
Truth table100%2/2
A
A= $over
Aresult
11
00
540 124 ▶ return sort grep { $_ =~ $re && !( $over && exists $over->{$_} && !defined $over->{$_} ) } keys %p;
Condition66%6/9
$_ =~ /$re/ && !($over && exists $$over{$_} && !defined($$over{$_}))
!ll&&!rl&&r
611052
$over && exists $$over{$_} && !defined($$over{$_})
!ll&&!rl&&r
5110
$over and exists $$over{$_}
!ll&&!rl&&r
5101
MC/DC25%1/4
$_ =~ /$re/ && !($over && exists $$over{$_} && !defined($$over{$_}))
$_ =~ /$re/ $over exists $$over{$_} !defined($$over{$_})
Truth table60%3/5
A && not(B and C && not(D))
A= $_ =~ /$re/B= $overC= exists $$over{$_}D= !defined($$over{$_})
ABCDresult
0XXX0
11110
10XX1
110X1
11101
541 50 };
542 }
543  
544 37 ▶sub _load {
Subroutine _load: called CC=1 SCAR=0.0
545 37 my ( $dev, $state, $over ) = @_;
546 37 my $ng = $dev->{nginx};
547 37 return parse( reader => _live_reader( $dev, $over ), glob => _live_glob( $dev, $over ), conf => $ng->{conf}, state => $state, dev => $dev );
548 }
549  
550 35 ▶sub _commit {
Subroutine _commit: called CC=3 SCAR=11.0
551 35 my ( $dev, $cfg ) = @_;
552 35 my $new = { conf => $cfg->{conf}, files => $cfg->{files} };
553 35 my $old = $dev->{nginx}{loaded};
554 35 ▶ $dev->{nginx}{loaded} = $new unless $old && $JSON->encode($old) eq $JSON->encode($new);
Branch: 1 branch
BranchTrueFalseTotal
unless $old and $JSON->encode($old) eq $JSON->encode($new) 33 2 35
Condition100%3/3
$old and $JSON->encode($old) eq $JSON->encode($new)
!ll&&!rl&&r
2492
MC/DC100%2/2
$old and $JSON->encode($old) eq $JSON->encode($new)
$old $JSON->encode($old) eq $JSON->encode($new)
Truth table100%3/3
A and B
A= $oldB= $JSON->encode($old) eq $JSON->encode($new)
ABresult
0X0
100
111
555 35 return;
556 }
557  
558 25 ▶sub _state { my ($ctx) = @_; return $ctx && $ctx->{state} ? $ctx->{state} : {} }
Subroutine _state: called CC=3 SCAR=13.1
Branch: 1 branch
BranchTrueFalseTotal
$ctx && $$ctx{'state'} ? : 25 0 25
Condition33%1/3
$ctx and $$ctx{"state"}
!ll&&!rl&&r
0025
MC/DC0%0/2
$ctx and $$ctx{"state"}
$ctx $$ctx{"state"}
Truth table33%1/3
A and B
A= $ctxB= $$ctx{"state"}
ABresult
0X0
100
111
559  
560  
561 100 ▶sub ensure {
Subroutine ensure: called CC=6 SCAR=18.1
Pod documented
562 100 my ( $dev, $host, $state ) = @_;
563 100 my $ng = $dev->{nginx};
564 100 ▶ return if $ng->{loaded};
Branch: 1 branch
BranchTrueFalseTotal
if $$ng{"loaded"} 75 25 100
565 25 ▶ return unless ( ( $dev->{services} || {} )->{nginx} || {} )->{active};
Branch: 1 branch
BranchTrueFalseTotal
unless (($$dev{"services"} || {})->{"nginx"} || {})->{"active"} 0 25 25
Condition50%2/4
($$dev{'services'} || {})->{'nginx'} || {}
l!l
250
$$dev{'services'} || {}
l!l
250
MC/DC0%0/1
($$dev{'services'} || {})->{'nginx'} || {}
$$dev{'services'}
Truth table50%1/2
A
A= $$dev{'services'}
Aresult
11
00
566 25 my $cfg = _load( $dev, $state, $ng->{initial} );
567 25 ▶ if ( $cfg->{error} ) { $ng->{loaded} = { error => $cfg->{error} }; return }
Branch: 1 branch
BranchTrueFalseTotal
if ($$cfg{"error"}) 1 24 25
568 24 _commit( $dev, $cfg );
569 24 return;
570 }
571  
572  
573 12 ▶sub service {
Subroutine service: called CC=3 SCAR=11.0
Pod documented
574 12 my ( $dev, $verb, $ctx ) = @_;
575 12 my $cfg = _load( $dev, _state($ctx) );
576 return "nginx: [emerg] $cfg->{error}\nnginx: configuration file " . ( $dev->{nginx}{conf} // '/etc/nginx/nginx.conf' ) . ' test failed'
577 12 ▶ if $cfg->{error};
Branch: 1 branch
BranchTrueFalseTotal
if $$cfg{"error"} 2 10 12
Condition50%1/2
$$dev{"nginx"}{"conf"} // "/etc/nginx/nginx.conf"
l!l
02
MC/DC0%0/1
$$dev{"nginx"}{"conf"} // "/etc/nginx/nginx.conf"
$$dev{"nginx"}{"conf"}
Truth table50%1/2
A
A= $$dev{"nginx"}{"conf"}
Aresult
11
00
578 10 _commit( $dev, $cfg );
579 10 return undef;
580 }
581  
582  
583 13 ▶sub nginx {
Subroutine nginx: called CC=36 SCAR=54.4
Pod documented
584 13 my ( $dev, $av, $ctx ) = @_;
585 13 my @a = @$av;
586 13 my ( %f, $sig );
587 13 ▶ while (@a) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a) 13 13 26
588 13 my $x = shift @a;
589 13 ▶ if ( $x eq '-s' ) { $sig = shift @a // return ( 'nginx: option "-s" requires parameter', 0 ) }
Branch: 5 branches
BranchTrueFalseTotal
if ($x eq '-s') { } 1 12 13
elsif ($x eq '-c') { } 0 12 12
elsif ($x eq '-g') { } 0 12 12
elsif ($x eq '-p') { } 0 12 12
elsif ($x =~ /\A-([tTqvV]+)\z/) { } 12 0 12
Condition50%1/2
shift @a // (return "nginx: option \"-s\" requires parameter", 0)
l!l
10
MC/DC0%0/1
shift @a // (return "nginx: option \"-s\" requires parameter", 0)
shift @a
Truth table50%1/2
A
A= shift @a
Aresult
11
00
590 0 elsif ( $x eq '-c' ) { $dev->{nginx}{conf_override} = shift @a; $f{c} = 1 }
591 0 elsif ( $x eq '-g' ) { shift @a }
592 0 elsif ( $x eq '-p' ) { shift @a }
593 12 elsif ( $x =~ /\A-([tTqvV]+)\z/ ) { $f{$_} = 1 for split //, $1 }
594 0 else { return ( "nginx: invalid option: \"" . substr( $x, 1 ) . "\"", 0 ) }
595 }
596 13 ▶ my $conf = delete( $dev->{nginx}{conf_override} ) // $dev->{nginx}{conf} // '/etc/nginx/nginx.conf';
Condition40%2/5
(delete $$dev{"nginx"}{"conf_override"} // $$dev{"nginx"}{"conf"}) // "/etc/nginx/nginx.conf"
l!l
013
delete $$dev{"nginx"}{"conf_override"} // $$dev{"nginx"}{"conf"}
l!l&&r!l&&!r
0013
MC/DC0%0/2
(delete $$dev{"nginx"}{"conf_override"} // $$dev{"nginx"}{"conf"}) // "/etc/nginx/nginx.conf"
delete $$dev{"nginx"}{"conf_override"} $$dev{"nginx"}{"conf"}
Truth table33%1/3
A // B
A= delete $$dev{"nginx"}{"conf_override"}B= $$dev{"nginx"}{"conf"}
ABresult
1X1
011
000
597 13 ▶ return ( "nginx version: $VERSION_TEXT", 1 ) if $f{v};
Branch: 1 branch
BranchTrueFalseTotal
if $f{"v"} 0 13 13
598 return ( "nginx version: $VERSION_TEXT\nbuilt with OpenSSL 3.0.11 19 Sep 2023 (running with OpenSSL 3.0.15 3 Sep 2024)\nTLS SNI support enabled\nconfigure arguments: --with-cc-opt='-g -O2' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_sub_module", 1 )
599 13 ▶ if $f{V};
Branch: 1 branch
BranchTrueFalseTotal
if $f{"V"} 0 13 13
600 13 my $state = _state($ctx);
601 13 ▶ my $svc = ( $dev->{services} || {} )->{nginx};
Condition50%1/2
$$dev{'services'} || {}
l!l
130
MC/DC0%0/1
$$dev{'services'} || {}
$$dev{'services'}
Truth table50%1/2
A
A= $$dev{'services'}
Aresult
11
00
602 13 ▶ if ( $f{t} || $f{T} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f{"t"} or $f{"T"}) 12 1 13
Condition66%2/3
$f{"t"} or $f{"T"}
l!l&&r!l&&!r
1201
MC/DC50%1/2
$f{"t"} or $f{"T"}
$f{"t"} $f{"T"}
Truth table66%2/3
A or B
A= $f{"t"}B= $f{"T"}
ABresult
1X1
011
000
603 12 my $cfg = parse( reader => _live_reader($dev), glob => _live_glob($dev), conf => $conf, state => $state, dev => $dev );
604 12 ▶ if ( $cfg->{error} ) { return ( "nginx: [emerg] $cfg->{error}\nnginx: configuration file $conf test failed", 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($$cfg{"error"}) 10 2 12
605 0 my @l = map {"nginx: [warn] $_"} @{ $cfg->{warnings} };
606 2 ▶ push @l, "nginx: the configuration file $conf syntax is ok", "nginx: configuration file $conf test is successful" unless $f{q};
Branch: 1 branch
BranchTrueFalseTotal
unless $f{"q"} 2 0 2
607 2 ▶ if ( $f{T} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($f{"T"}) 0 2 2
608 0 ▶ for my $file ( sort { $a eq $conf ? -1 : $b eq $conf ? 1 : 0 } keys %{ $cfg->{conf_files} } ) {
Branch: 2 branches
BranchTrueFalseTotal
$a eq $conf ? : 0 0 0
$b eq $conf ? : 0 0 0
609 0 push @l, "# configuration file $file:", $cfg->{conf_files}{$file} =~ s/\n\z//r, '';
610 }
611 }
612 2 return ( join( "\n", @l ), 1 );
613 }
614 1 ▶ if ( defined $sig ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sig) 1 0 1
615 1 ▶ return ( "nginx: invalid option: \"-s $sig\"", 0 ) unless $sig =~ /\A(?:reload|stop|quit|reopen)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $sig =~ /\A(?:reload|stop|quit|reopen)\z/ 0 1 1
616 1 my $cfg = parse( reader => _live_reader($dev), glob => _live_glob($dev), conf => $conf, state => $state, dev => $dev );
617 1 ▶ return ( "nginx: [emerg] $cfg->{error}", 0 ) if $cfg->{error};
Branch: 1 branch
BranchTrueFalseTotal
if $$cfg{"error"} 0 1 1
618 1 ▶ return ( 'nginx: [error] invalid PID number "" in "/run/nginx.pid"', 0 ) unless $svc && $svc->{active};
Branch: 1 branch
BranchTrueFalseTotal
unless $svc and $$svc{"active"} 0 1 1
Condition33%1/3
$svc and $$svc{"active"}
!ll&&!rl&&r
001
MC/DC0%0/2
$svc and $$svc{"active"}
$svc $$svc{"active"}
Truth table33%1/3
A and B
A= $svcB= $$svc{"active"}
ABresult
0X0
100
111
619 0 ▶ if ( $sig eq 'reload' ) { _commit( $dev, $cfg ); return ( join( "\n", map {"nginx: [warn] $_"} @{ $cfg->{warnings} } ), 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($sig eq "reload") 1 0 1
620 0 ▶ if ( $sig eq 'stop' || $sig eq 'quit' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sig eq "stop" or $sig eq "quit") 0 0 0
Condition0%0/3
$sig eq "stop" or $sig eq "quit"
l!l&&r!l&&!r
000
MC/DC0%0/2
$sig eq "stop" or $sig eq "quit"
$sig eq "stop" $sig eq "quit"
Truth table0%0/3
A or B
A= $sig eq "stop"B= $sig eq "quit"
ABresult
1X1
011
000
621 0 ▶ $svc->{restarts} = ( $svc->{restarts} // 0 ) + 1;
Condition0%0/2
$$svc{"restarts"} // 0
l!l
00
MC/DC0%0/1
$$svc{"restarts"} // 0
$$svc{"restarts"}
Truth table0%0/2
A
A= $$svc{"restarts"}
Aresult
11
00
622 0 $svc->{active} = JSON::MaybeXS::false();
623 }
624 0 return ( '', 1 );
625 }
626 # nginx ohne Argument: starten
627 0 my $cfg = parse( reader => _live_reader($dev), glob => _live_glob($dev), conf => $conf, state => $state, dev => $dev );
628 0 ▶ return ( "nginx: [emerg] $cfg->{error}", 0 ) if $cfg->{error};
Branch: 1 branch
BranchTrueFalseTotal
if $$cfg{"error"} 0 0 0
629 0 ▶ if ( $svc && $svc->{active} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($svc and $$svc{"active"}) 0 0 0
Condition0%0/3
$svc and $$svc{"active"}
!ll&&!rl&&r
000
MC/DC0%0/2
$svc and $$svc{"active"}
$svc $$svc{"active"}
Truth table0%0/3
A and B
A= $svcB= $$svc{"active"}
ABresult
0X0
100
111
630 0 return ( "nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)\nnginx: [emerg] still could not bind()", 0 );
631 }
632 0 ▶ $dev->{services}{nginx} //= {};
Condition0%0/2
$$dev{"services"}{"nginx"} //= {}
l!l
00
MC/DC0%0/1
$$dev{"services"}{"nginx"} //= {}
$$dev{"services"}{"nginx"}
Truth table0%0/2
A
A= $$dev{"services"}{"nginx"}
Aresult
11
00
633 0 $dev->{services}{nginx}{active} = JSON::MaybeXS::true();
634 0 ▶ $dev->{services}{nginx}{failed} = JSON::MaybeXS::false() if $dev->{services}{nginx}{failed};
Branch: 1 branch
BranchTrueFalseTotal
if $$dev{"services"}{"nginx"}{"failed"} 0 0 0
635 0 _commit( $dev, $cfg );
636 0 return ( '', 1 );
637 }
638  
639 # --- Anfragen ---------------------------------------------------------------------------
640  
641 4 my %CACHE;
642  
643 200 ▶sub _model_of {
Subroutine _model_of: called CC=7 SCAR=20.1
644 200 my ( $dev, $state ) = @_;
645 200 ▶ my $l = $dev->{nginx}{loaded} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $l = $$dev{"nginx"}{"loaded"} or return undef 200 0 200
646 200 ▶ return undef if $l->{error};
Branch: 1 branch
BranchTrueFalseTotal
if $$l{"error"} 5 195 200
647 195 my $key = Digest::SHA::sha1_hex( $JSON->encode( [ $l, _pki()->can('catalog')->($state) ] ) );
648 195 ▶ %CACHE = () if keys %CACHE > 200;
Branch: 1 branch
BranchTrueFalseTotal
if keys %CACHE > 200 0 195 195
649 195 ▶ return $CACHE{$key} //= do {
Condition66%2/3
$CACHE{$key} //= do { my $files = $$l{"files"} || {}; my $cfg = parse("reader", sub { exists $$files{$_[0]} ? $$files{$_[0]} : undef; } , "glob", sub { my $re = _glob_re($_[0]); sort grep({$_ =~ /$re/;} keys %$files); } , "conf", $$l{"conf"}, "state", $state, "dev", $dev); $$cfg{"error"} ? undef : $cfg }
l!l&&r!l&&!r
181140
MC/DC0%0/2
$CACHE{$key} //= do { my $files = $$l{"files"} || {}; my $cfg = parse("reader", sub { exists $$files{$_[0]} ? $$files{$_[0]} : undef; } , "glob", sub { my $re = _glob_re($_[0]); sort grep({$_ =~ /$re/;} keys %$files); } , "conf", $$l{"conf"}, "state", $state, "dev", $dev); $$cfg{"error"} ? undef : $cfg }
$CACHE{$key} do { my $files = $$l{"files"} || {}; my $cfg = parse("reader", sub { exists $$files{$_[0]} ? $$files{$_[0]} : undef; } , "glob", sub { my $re = _glob_re($_[0]); sort grep({$_ =~ /$re/;} keys %$files); } , "conf", $$l{"conf"}, "state", $state, "dev", $dev); $$cfg{"error"} ? undef : $cfg }
Truth table66%2/3
A //= B
A= $CACHE{$key}B= do { my $files = $$l{"files"} || {}; my $cfg = parse("reader", sub { exists $$files{$_[0]} ? $$files{$_[0]} : undef; } , "glob", sub { my $re = _glob_re($_[0]); sort grep({$_ =~ /$re/;} keys %$files); } , "conf", $$l{"conf"}, "state", $state, "dev", $dev); $$cfg{"error"} ? undef : $cfg }
ABresult
1X1
011
000
650 14 ▶ my $files = $l->{files} || {};
Condition50%1/2
$$l{'files'} || {}
l!l
140
MC/DC0%0/1
$$l{'files'} || {}
$$l{'files'}
Truth table50%1/2
A
A= $$l{'files'}
Aresult
11
00
651 48 ▶ my $cfg = parse( reader => sub { exists $files->{ $_[0] } ? $files->{ $_[0] } : undef },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
exists $$files{$_[0]} ? : 48 0 48
652 14 ▶ glob => sub { my $re = _glob_re( $_[0] ); sort grep { $_ =~ $re } keys %$files }, conf => $l->{conf}, state => $state, dev => $dev );
Subroutine __ANON__: called CC=1 SCAR=0.0
653 14 ▶ $cfg->{error} ? undef : $cfg;
Branch: 1 branch
BranchTrueFalseTotal
$$cfg{'error'} ? : 0 14 14
654 };
655 }
656  
657 4 my %REASON = ( 400 => 'Bad Request', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Not Allowed', 413 => 'Request Entity Too Large',
658 500 => 'Internal Server Error', 502 => 'Bad Gateway', 503 => 'Service Temporarily Unavailable', 504 => 'Gateway Time-out',
659 301 => 'Moved Permanently', 302 => 'Found', 303 => 'See Other', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect',
660 401 => 'Authorization Required', 429 => 'Too Many Requests', 444 => '' );
661  
662 5 ▶sub _page {
Subroutine _page: called CC=5 SCAR=17.8
663 5 my ( $code, $tokens, $extra ) = @_;
664 5 ▶ my $t = "$code " . ( $REASON{$code} // '' );
Condition50%1/2
$REASON{$code} // ""
l!l
50
MC/DC0%0/1
$REASON{$code} // ""
$REASON{$code}
Truth table50%1/2
A
A= $REASON{$code}
Aresult
11
00
665 5 ▶ my $sig = $tokens ? $VERSION_TEXT : 'nginx';
Branch: 1 branch
BranchTrueFalseTotal
$tokens ? : 5 0 5
666 5 ▶ return "<html>\r\n<head><title>" . ( $extra ? "$code $extra" : $t ) . "</title></head>\r\n<body>\r\n<center><h1>$t</h1></center>\r\n"
Branch: 2 branches
BranchTrueFalseTotal
$extra ? : 0 5 5
$extra ? : 0 5 5
667 . ( $extra ? "<center>$extra</center>\r\n" : '' ) . "<hr><center>$sig</center>\r\n</body>\r\n</html>\r\n";
668 }
669  
670 154 ▶sub _name_match {
Subroutine _name_match: called CC=23 SCAR=46.3
671 154 my ( $servers, $name ) = @_;
672 154 ▶ return undef unless defined $name && length $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and length $name 0 154 154
Condition33%1/3
defined $name and length $name
!ll&&!rl&&r
00154
MC/DC0%0/2
defined $name and length $name
defined $name length $name
Truth table33%1/3
A and B
A= defined $nameB= length $name
ABresult
0X0
100
111
673 154 ▶ for my $s (@$servers) { return $s if grep { $_ eq $name } @{ $s->{names} } }
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq $name;} @{$$s{"names"};} 150 11 161
674 4 my ( $best, $bl );
675 4 for my $s (@$servers) {
676 6 for my $n ( @{ $s->{names} } ) {
677 6 ▶ if ( $n =~ /\A\*\.(.+)\z/ || $n =~ /\A\.(.+)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n =~ /\A\*\.(.+)\z/ or $n =~ /\A\.(.+)\z/) 0 6 6
Condition33%1/3
$n =~ /\A\*\.(.+)\z/ or $n =~ /\A\.(.+)\z/
l!l&&r!l&&!r
006
MC/DC0%0/2
$n =~ /\A\*\.(.+)\z/ or $n =~ /\A\.(.+)\z/
$n =~ /\A\*\.(.+)\z/ $n =~ /\A\.(.+)\z/
Truth table33%1/3
A or B
A= $n =~ /\A\*\.(.+)\z/B= $n =~ /\A\.(.+)\z/
ABresult
1X1
011
000
678 0 my $d = $1;
679 0 ▶ if ( ( $name =~ /\.\Q$d\E\z/ || ( $n =~ /\A\./ && $name eq $d ) ) && ( !$bl || length $d > $bl ) ) { ( $best, $bl ) = ( $s, length $d ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /\.\Q$d\E\z/ || $n =~ /\A\./ && $name eq $d and !$bl || length $d > $bl) 0 0 0
Condition0%0/12
$name =~ /\.\Q$d\E\z/ || $n =~ /\A\./ && $name eq $d and !$bl || length $d > $bl
!ll&&!rl&&r
000
$name =~ /\.\Q$d\E\z/ or $n =~ /\A\./ and $name eq $d
l!l&&r!l&&!r
000
$n =~ /\A\./ and $name eq $d
!ll&&!rl&&r
000
not $bl or length $d > $bl
l!l&&r!l&&!r
000
MC/DC0%0/5
$name =~ /\.\Q$d\E\z/ || $n =~ /\A\./ && $name eq $d and !$bl || length $d > $bl
$name =~ /\.\Q$d\E\z/ $n =~ /\A\./ $name eq $d not $bl length $d > $bl
Truth table0%0/8
A or B and C and not(D) or E
A= $name =~ /\.\Q$d\E\z/B= $n =~ /\A\./C= $name eq $dD= not $blE= length $d > $bl
ABCDEresult
00XXX0
010XX0
1XX000
011000
1XX1X1
1XX011
0111X1
011011
680 }
681 }
682 }
683 4 ▶ return $best if $best;
Branch: 1 branch
BranchTrueFalseTotal
if $best 0 4 4
684 4 for my $s (@$servers) {
685 6 for my $n ( @{ $s->{names} } ) {
686 6 ▶ next unless $n =~ /\A(.+)\.\*\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $n =~ /\A(.+)\.\*\z/ 6 0 6
687 0 ▶ return $s if $name =~ /\A\Q$1\E\./;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\A\Q$1\E\./ 0 0 0
688 }
689 }
690 4 for my $s (@$servers) {
691 6 for my $n ( @{ $s->{names} } ) {
692 6 ▶ next unless $n =~ /\A~(.+)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $n =~ /\A~(.+)\z/ 6 0 6
693 0 my $re = $1;
694 0 ▶ return $s if eval { $name =~ /$re/ };
Branch: 1 branch
BranchTrueFalseTotal
if eval { do { $name =~ /$re/ } } 0 0 0
695 }
696 }
697 4 return undef;
698 }
699  
700  
701 202 ▶sub serve {
Subroutine serve: called CC=58 SCAR=57.8
Pod documented
702 202 my ( $state, $to, $req, $from, $depth ) = @_;
703 202 my $dev = $state->{$to};
704 202 ▶ return undef unless ( ( $dev->{services} || {} )->{nginx} || {} )->{active};
Branch: 1 branch
BranchTrueFalseTotal
unless (($$dev{"services"} || {})->{"nginx"} || {})->{"active"} 2 200 202
Condition50%2/4
($$dev{'services'} || {})->{'nginx'} || {}
l!l
2020
$$dev{'services'} || {}
l!l
2020
MC/DC0%0/1
($$dev{'services'} || {})->{'nginx'} || {}
$$dev{'services'}
Truth table50%1/2
A
A= $$dev{'services'}
Aresult
11
00
705 200 ▶ my $cfg = _model_of( $dev, $state ) or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $cfg = _model_of($dev, $state) or return undef 195 5 200
706 195 ▶ my $local = defined $from && $from eq $to;
Condition66%2/3
defined $from && $from eq $to
!ll&&!rl&&r
011877
MC/DC50%1/2
defined $from && $from eq $to
defined $from $from eq $to
Truth table66%2/3
A && B
A= defined $fromB= $from eq $to
ABresult
0X0
100
111
707 195 require Langertha::Holmgang::Sim::Linux::Http;
708 195 my ( @exact, @wild );
709 195 for my $s ( @{ $cfg->{servers} } ) {
710 207 for my $l ( @{ $s->{listens} } ) {
711 207 ▶ next unless $l->{port} == $req->{port};
Branch: 1 branch
BranchTrueFalseTotal
unless $$l{"port"} == $$req{"port"} 81 126 207
712 126 ▶ if ( $l->{ip} eq '0.0.0.0' ) { push @wild, [ $s, $l ] }
Branch: 2 branches
BranchTrueFalseTotal
if ($$l{'ip'} eq '0.0.0.0') { } 126 0 126
elsif ($$l{'ip'} eq $$req{'ip'} or $$l{'ip'} =~ /\A127\./ and $$req{'ip'} =~ /\A127\./) { } 0 0 0
713 0 ▶ elsif ( $l->{ip} eq $req->{ip} || ( $l->{ip} =~ /\A127\./ && $req->{ip} =~ /\A127\./ ) ) { push @exact, [ $s, $l ] if $local || $l->{ip} !~ /\A127\./ }
Branch: 1 branch
BranchTrueFalseTotal
if $local or not $$l{"ip"} =~ /\A127\./ 0 0 0
Condition0%0/9
$$l{"ip"} eq $$req{"ip"} or $$l{"ip"} =~ /\A127\./ and $$req{"ip"} =~ /\A127\./
l!l&&r!l&&!r
000
$$l{"ip"} =~ /\A127\./ and $$req{"ip"} =~ /\A127\./
!ll&&!rl&&r
000
$local or not $$l{"ip"} =~ /\A127\./
l!l&&r!l&&!r
000
MC/DC0%0/3
$$l{"ip"} eq $$req{"ip"} or $$l{"ip"} =~ /\A127\./ and $$req{"ip"} =~ /\A127\./
$$l{"ip"} eq $$req{"ip"} $$l{"ip"} =~ /\A127\./ $$req{"ip"} =~ /\A127\./
MC/DC0%0/2
$local or not $$l{"ip"} =~ /\A127\./
$local not $$l{"ip"} =~ /\A127\./
Truth table0%0/4
A or B and C
A= $$l{"ip"} eq $$req{"ip"}B= $$l{"ip"} =~ /\A127\./C= $$req{"ip"} =~ /\A127\./
ABCresult
1XX1
0111
00X0
0100
Truth table0%0/3
A or not(B)
A= $localB= not $$l{"ip"} =~ /\A127\./
ABresult
1X1
011
000
714 }
715 }
716 195 ▶ my @group = @exact ? @exact : @wild;
Branch: 1 branch
BranchTrueFalseTotal
@exact ? : 0 195 195
717 195 ▶ return undef unless @group;
Branch: 1 branch
BranchTrueFalseTotal
unless @group 76 119 195
718 119 my $sock = "$group[0][1]{ip}:$req->{port}";
719 119 my $ssl = $cfg->{ssl_sockets}{$sock};
720 119 my %seen;
721 119 my @servers = grep { !$seen{"$_"}++ } map { $_->[0] } @group;
722 119 my ($def) = map { $_->[0] } grep { $_->[1]{default} } @group;
723 119 ▶ $def //= $servers[0];
Condition66%2/3
$def //= $servers[0]
l!l&&r!l&&!r
71120
MC/DC0%0/2
$def //= $servers[0]
$def $servers[0]
Truth table66%2/3
A //= B
A= $defB= $servers[0]
ABresult
1X1
011
000
724 0 my $tokens = !grep { $_->{args}[0] eq 'off' } grep { $_->{name} eq 'server_tokens' } @{ $cfg->{http} };
725 119 ▶ my %base = ( server => $tokens ? $VERSION_TEXT : 'nginx' );
Branch: 1 branch
BranchTrueFalseTotal
$tokens ? : 119 0 119
726 119 ▶ my $html = sub { my ( $code, $extra ) = @_; return { %base, status => $code, headers => [ [ 'Content-Type', 'text/html' ] ], body => _page( $code, $tokens, $extra ) } };
Subroutine __ANON__: called CC=1 SCAR=0.0
727 0 ▶ if ( $ssl && $req->{scheme} eq 'http' ) { return $html->( 400, 'The plain HTTP request was sent to HTTPS port' ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl and $$req{"scheme"} eq "http") 0 119 119
Condition66%2/3
$ssl and $$req{"scheme"} eq "http"
!ll&&!rl&&r
83360
MC/DC0%0/2
$ssl and $$req{"scheme"} eq "http"
$ssl $$req{"scheme"} eq "http"
Truth table66%2/3
A and B
A= $sslB= $$req{"scheme"} eq "http"
ABresult
0X0
100
111
728 119 ▶ if ( !$ssl && $req->{scheme} eq 'https' ) { return { %base, status => 400 } } # kein TLS: der Client meldet den Fehler
Branch: 1 branch
BranchTrueFalseTotal
if (not $ssl and $$req{"scheme"} eq "https") 1 118 119
Condition100%3/3
not $ssl and $$req{"scheme"} eq "https"
!ll&&!rl&&r
36821
MC/DC100%2/2
not $ssl and $$req{"scheme"} eq "https"
not $ssl $$req{"scheme"} eq "https"
Truth table100%3/3
not(A) and B
A= not $sslB= $$req{"scheme"} eq "https"
ABresult
0X0
100
111
729 118 ▶ my ( $host_hdr ) = ( $req->{headers}{host} // '' );
Condition50%1/2
$$req{"headers"}{"host"} // ""
l!l
1180
MC/DC0%0/1
$$req{"headers"}{"host"} // ""
$$req{"headers"}{"host"}
Truth table50%1/2
A
A= $$req{"headers"}{"host"}
Aresult
11
00
730 118 ( my $hname = lc $host_hdr ) =~ s/:\d+\z//;
731 118 my $tls;
732 my $tsrv;
733 118 ▶ if ($ssl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl) 36 82 118
734 36 ▶ my $sni = $req->{sni} // ( $req->{host} =~ /\A[\d.]+\z/ ? undef : $req->{host} );
Branch: 1 branch
BranchTrueFalseTotal
$$req{'host'} =~ /\A[\d.]+\z/ ? : 0 35 35
Condition66%2/3
$$req{"sni"} // ($$req{"host"} =~ /\A[\d.]+\z/ ? undef : $$req{"host"})
l!l&&r!l&&!r
1350
MC/DC0%0/2
$$req{"sni"} // ($$req{"host"} =~ /\A[\d.]+\z/ ? undef : $$req{"host"})
$$req{"sni"} ($$req{"host"} =~ /\A[\d.]+\z/ ? undef : $$req{"host"})
Truth table66%2/3
A // B
A= $$req{"sni"}B= ($$req{"host"} =~ /\A[\d.]+\z/ ? undef : $$req{"host"})
ABresult
1X1
011
000
735 36 ▶ $tsrv = _name_match( \@servers, defined $sni ? lc $sni : undef ) // $def;
Branch: 1 branch
BranchTrueFalseTotal
defined $sni ? : 36 0 36
Condition66%2/3
_name_match(\@servers, defined $sni ? lc $sni : undef) // $def
l!l&&r!l&&!r
3510
MC/DC0%0/2
_name_match(\@servers, defined $sni ? lc $sni : undef) // $def
_name_match(\@servers, defined $sni ? lc $sni : undef) $def
Truth table66%2/3
A // B
A= _name_match(\@servers, defined $sni ? lc $sni : undef)B= $def
ABresult
1X1
011
000
736 36 ▶ my $t = $tsrv->{tls} || {};
Condition50%1/2
$$tsrv{'tls'} || {}
l!l
360
MC/DC0%0/1
$$tsrv{'tls'} || {}
$$tsrv{'tls'}
Truth table50%1/2
A
A= $$tsrv{'tls'}
Aresult
11
00
737 0 my @prot = map { @{ $_->{args} } } grep {defined} _eff1( $cfg, [ $tsrv->{dirs} ], 'ssl_protocols' );
738 36 ▶ @prot = qw( TLSv1.2 TLSv1.3 ) unless @prot;
Branch: 1 branch
BranchTrueFalseTotal
unless @prot 36 0 36
739 36 my %p = map { $_ => 1 } @prot;
740 36 ▶ if ( defined $req->{tls_version} && !$p{ $req->{tls_version} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$req{"tls_version"} and not $p{$$req{"tls_version"}}) 0 36 36
Condition33%1/3
defined $$req{"tls_version"} and not $p{$$req{"tls_version"}}
!ll&&!rl&&r
3600
MC/DC0%0/2
defined $$req{"tls_version"} and not $p{$$req{"tls_version"}}
defined $$req{"tls_version"} not $p{$$req{"tls_version"}}
Truth table33%1/3
A and not(B)
A= defined $$req{"tls_version"}B= not $p{$$req{"tls_version"}}
ABresult
0X0
100
111
741 0 return { error => '(35) OpenSSL/3.0.15: error:0A00042E:SSL routines::tlsv1 alert protocol version', code => 35 };
742 }
743 36 ▶ my $proto = $req->{tls_version} // ( $p{'TLSv1.3'} ? 'TLSv1.3' : $p{'TLSv1.2'} ? 'TLSv1.2' : $p{'TLSv1.1'} ? 'TLSv1.1' : 'TLSv1' );
Branch: 3 branches
BranchTrueFalseTotal
$p{'TLSv1.3'} ? : 36 0 36
$p{'TLSv1.2'} ? : 0 0 0
$p{'TLSv1.1'} ? : 0 0 0
Condition50%1/2
$$req{"tls_version"} // ($p{"TLSv1.3"} ? "TLSv1.3" : ($p{"TLSv1.2"} ? "TLSv1.2" : ($p{"TLSv1.1"} ? "TLSv1.1" : "TLSv1")))
l!l
036
MC/DC0%0/1
$$req{"tls_version"} // ($p{"TLSv1.3"} ? "TLSv1.3" : ($p{"TLSv1.2"} ? "TLSv1.2" : ($p{"TLSv1.1"} ? "TLSv1.1" : "TLSv1")))
$$req{"tls_version"}
Truth table50%1/2
A
A= $$req{"tls_version"}
Aresult
11
00
744 36 ▶ $tls = { chain => $t->{chain} || [], protocol => $proto, sni => $sni, ( $t->{client_ca} ? ( client_ca => $t->{client_ca} ) : () ) };
Branch: 1 branch
BranchTrueFalseTotal
$$t{'client_ca'} ? : 0 36 36
Condition50%1/2
$$t{'chain'} || []
l!l
360
MC/DC0%0/1
$$t{'chain'} || []
$$t{'chain'}
Truth table50%1/2
A
A= $$t{'chain'}
Aresult
11
00
745 36 $tls->{lines} = [ _pki()->can('tls_lines')->( $state, $tls ) ];
746 }
747 118 ▶ my $srv = _name_match( \@servers, $hname ) // $def;
Condition66%2/3
_name_match(\@servers, $hname) // $def
l!l&&r!l&&!r
11530
MC/DC0%0/2
_name_match(\@servers, $hname) // $def
_name_match(\@servers, $hname) $def
Truth table66%2/3
A // B
A= _name_match(\@servers, $hname)B= $def
ABresult
1X1
011
000
748 118 ▶ my %ctx = ( cfg => $cfg, srv => $srv, req => $req, state => $state, to => $to, from => $from, depth => $depth // 0,
Condition50%1/2
$depth // 0
l!l
1180
MC/DC0%0/1
$depth // 0
$depth
Truth table50%1/2
A
A= $depth
Aresult
11
00
749 dev => $dev, tokens => $tokens, html => $html, ssl => $ssl, sock => $sock );
750 # Client-Zertifikat
751 118 ▶ if ( $ssl && $tsrv->{tls} && $tsrv->{tls}{client_ca} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl and $$tsrv{"tls"} and $$tsrv{"tls"}{"client_ca"}) 0 118 118
Condition66%4/6
$ssl and $$tsrv{"tls"} and $$tsrv{"tls"}{"client_ca"}
!ll&&!rl&&r
82360
$ssl and $$tsrv{"tls"}
!ll&&!rl&&r
82036
MC/DC0%0/3
$ssl and $$tsrv{"tls"} and $$tsrv{"tls"}{"client_ca"}
$ssl $$tsrv{"tls"} $$tsrv{"tls"}{"client_ca"}
Truth table50%2/4
A and B and C
A= $sslB= $$tsrv{"tls"}C= $$tsrv{"tls"}{"client_ca"}
ABCresult
0XX0
10X0
1100
1111
752 0 my $vc = _eff1( $cfg, [ $tsrv->{dirs} ], 'ssl_verify_client' );
753 0 ▶ my $mode = $vc ? $vc->{args}[0] : 'off';
Branch: 1 branch
BranchTrueFalseTotal
$vc ? : 0 0 0
754 0 my $st = 'NONE';
755 0 ▶ if ( defined $req->{cert} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$req{"cert"}) 0 0 0
756 0 ▶ my $fd = $state->{$from} || {};
Condition0%0/2
$$state{$from} || {}
l!l
00
MC/DC0%0/1
$$state{$from} || {}
$$state{$from}
Truth table0%0/2
A
A= $$state{$from}
Aresult
11
00
757 0 ▶ my $ct = _ftext( $fd, $req->{cert} ) // '';
Condition0%0/2
_ftext($fd, $$req{"cert"}) // ""
l!l
00
MC/DC0%0/1
_ftext($fd, $$req{"cert"}) // ""
_ftext($fd, $$req{"cert"})
Truth table0%0/2
A
A= _ftext($fd, $$req{"cert"})
Aresult
11
00
758 0 my @ids = map { $_->{id} } grep { $_->{kind} eq 'cert' } _pki()->can('blocks')->($ct);
759 0 my $cat = _pki()->can('catalog')->($state);
760 0 ▶ $st = @ids && !_pki()->can('verify_chain')->( $cat, $ids[0], [ @ids[ 1 .. $#ids ] ], $tsrv->{tls}{client_ca} ) ? 'SUCCESS' : 'FAILED';
Branch: 1 branch
BranchTrueFalseTotal
@ids && !_pki()->can('verify_chain')->($cat, $ids[0], [@ids[1 .. $#ids]], $$tsrv{'tls'}{'client_ca'}) ? : 0 0 0
Condition0%0/3
@ids and not _pki()->can("verify_chain")->($cat, $ids[0], [@ids[1 .. $#ids]], $$tsrv{"tls"}{"client_ca"})
!ll&&!rl&&r
000
MC/DC0%0/2
@ids and not _pki()->can("verify_chain")->($cat, $ids[0], [@ids[1 .. $#ids]], $$tsrv{"tls"}{"client_ca"})
@ids not _pki()->can("verify_chain")->($cat, $ids[0], [@ids[1 .. $#ids]], $$tsrv{"tls"}{"client_ca"})
Truth table0%0/3
A and not(B)
A= @idsB= not _pki()->can("verify_chain")->($cat, $ids[0], [@ids[1 .. $#ids]], $$tsrv{"tls"}{"client_ca"})
ABresult
0X0
100
111
761 }
762 0 $ctx{ssl_client_verify} = $st;
763 0 ▶ if ( $mode eq 'on' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq "on") 0 0 0
764 0 ▶ my $r = $st eq 'NONE' ? $html->( 400, 'No required SSL certificate was sent' ) : $st eq 'FAILED' ? $html->( 400, 'The SSL certificate error' ) : undef;
Branch: 2 branches
BranchTrueFalseTotal
$st eq 'NONE' ? : 0 0 0
$st eq 'FAILED' ? : 0 0 0
765 0 ▶ if ($r) { $r->{tls} = $tls; return $r }
Branch: 1 branch
BranchTrueFalseTotal
if ($r) 0 0 0
766 }
767 }
768 118 my $res = _handle( \%ctx );
769 118 ▶ $res->{server} //= $base{server};
Condition66%2/3
$$res{"server"} //= $base{"server"}
l!l&&r!l&&!r
51130
MC/DC0%0/2
$$res{"server"} //= $base{"server"}
$$res{"server"} $base{"server"}
Truth table66%2/3
A //= B
A= $$res{"server"}B= $base{"server"}
ABresult
1X1
011
000
770 118 ▶ if ( $ssl && !defined $res->{error} ) { $res->{tls} = $tls; $res->{cert} = $tls->{chain}[0]; $res->{protocol} = $tls->{protocol} }
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl and not defined $$res{"error"}) 36 82 118
Condition66%2/3
$ssl and not defined $$res{"error"}
!ll&&!rl&&r
82036
MC/DC50%1/2
$ssl and not defined $$res{"error"}
$ssl not defined $$res{"error"}
Truth table66%2/3
A and not(B)
A= $sslB= not defined $$res{"error"}
ABresult
0X0
100
111
771 118 ▶ $res->{tls_lines} = $tls->{lines} if $ssl;
Branch: 1 branch
BranchTrueFalseTotal
if $ssl 36 82 118
772 118 return $res;
773 }
774  
775 # Variablen
776 83 ▶sub _var {
Subroutine _var: called CC=43 SCAR=61.5
777 83 my ( $c, $v ) = @_;
778 83 my $r = $c->{req};
779 83 ▶ my %h = %{ $c->{out_headers} || {} };
Condition50%1/2
$$c{'out_headers'} || {}
l!l
083
MC/DC0%0/1
$$c{'out_headers'} || {}
$$c{'out_headers'}
Truth table50%1/2
A
A= $$c{'out_headers'}
Aresult
11
00
780 83 ▶ my $host = lc( $r->{headers}{host} // '' );
Condition50%1/2
$$r{"headers"}{"host"} // ""
l!l
830
MC/DC0%0/1
$$r{"headers"}{"host"} // ""
$$r{"headers"}{"host"}
Truth table50%1/2
A
A= $$r{"headers"}{"host"}
Aresult
11
00
781 83 $host =~ s/:\d+\z//;
782 83 my $uri = $c->{uri};
783 83 ▶ return $c->{cap}[$v] // '' if $v =~ /\A\d\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $v =~ /\A\d\z/ 0 83 83
Condition0%0/2
$$c{"cap"}[$v] // ""
l!l
00
MC/DC0%0/1
$$c{"cap"}[$v] // ""
$$c{"cap"}[$v]
Truth table0%0/2
A
A= $$c{"cap"}[$v]
Aresult
11
00
784 83 ▶ return $c->{set}{$v} if $c->{set} && exists $c->{set}{$v};
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"set"} and exists $$c{"set"}{$v} 0 83 83
Condition33%1/3
$$c{"set"} and exists $$c{"set"}{$v}
!ll&&!rl&&r
8300
MC/DC0%0/2
$$c{"set"} and exists $$c{"set"}{$v}
$$c{"set"} exists $$c{"set"}{$v}
Truth table33%1/3
A and B
A= $$c{"set"}B= exists $$c{"set"}{$v}
ABresult
0X0
100
111
785 83 ▶ if ( my $m = $c->{cfg}{maps}{$v} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $m = $$c{"cfg"}{"maps"}{$v}) 0 83 83
786 0 my $src = _interp( $c, $m->{src} );
787 0 my $def = '';
788 0 for my $rule ( @{ $m->{rules} } ) {
789 0 my ( $k, $val ) = @$rule;
790 0 ▶ if ( $k eq 'default' ) { $def = $val; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($k eq "default") 0 0 0
791 0 ▶ if ( $k =~ /\A~(\*)?(.*)\z/s ) { my ( $ci, $re ) = ( $1, $2 ); return $val if eval { $ci ? $src =~ /$re/i : $src =~ /$re/ } ; next }
Branch: 3 branches
BranchTrueFalseTotal
if ($k =~ /\A~(\*)?(.*)\z/s) 0 0 0
if eval { do { $ci ? $src =~ /$re/i : $src =~ /$re/ } } 0 0 0
$ci ? : 0 0 0
792 0 ▶ $k = '' if $k eq "''" || $k eq '""';
Branch: 1 branch
BranchTrueFalseTotal
if $k eq "''" or $k eq "\"\"" 0 0 0
Condition0%0/3
$k eq "''" or $k eq "\"\""
l!l&&r!l&&!r
000
MC/DC0%0/2
$k eq "''" or $k eq "\"\""
$k eq "''" $k eq "\"\""
Truth table0%0/3
A or B
A= $k eq "''"B= $k eq "\"\""
ABresult
1X1
011
000
793 0 ▶ return $val if $src eq $k;
Branch: 1 branch
BranchTrueFalseTotal
if $src eq $k 0 0 0
794 }
795 0 return $def;
796 }
797 my %v = (
798 host => length $host ? $host : ( $c->{srv}{names}[0] // '' ), http_host => $r->{headers}{host} // '',
799 scheme => $r->{scheme}, request_uri => $r->{path}, uri => $uri, args => $c->{args} // '',
800 query_string => $c->{args} // '', is_args => length( $c->{args} // '' ) ? '?' : '',
801 remote_addr => $r->{client_ip} // '127.0.0.1', server_name => $c->{srv}{names}[0] // '', server_port => $r->{port},
802 server_addr => $r->{ip}, request_method => $r->{method}, proxy_host => $c->{proxy_host} // '',
803 proxy_port => $c->{proxy_port} // '', document_root => $c->{root} // '', request_filename => ( $c->{root} // '' ) . $uri,
804 https => $r->{scheme} eq 'https' ? 'on' : '', ssl_client_verify => $c->{ssl_client_verify} // 'NONE',
805 ssl_server_name => $r->{sni} // $host, server_protocol => 'HTTP/1.1', binary_remote_addr => $r->{client_ip} // '',
806 request => "$r->{method} $r->{path} HTTP/1.1", nginx_version => '1.22.1', hostname => $c->{to},
807 83 ▶ );
Branch: 3 branches
BranchTrueFalseTotal
length $host ? : 83 0 83
length($$c{'args'} // '') ? : 65 18 83
$$r{'scheme'} eq 'https' ? : 0 83 83
Condition58%17/29
$$c{"srv"}{"names"}[0] // ""
l!l
00
$$r{"headers"}{"host"} // ""
l!l
830
$$c{"args"} // ""
l!l
830
$$c{"args"} // ""
l!l
830
$$c{"args"} // ""
l!l
830
$$r{"client_ip"} // "127.0.0.1"
l!l
830
$$c{"srv"}{"names"}[0] // ""
l!l
830
$$c{"proxy_host"} // ""
l!l
803
$$c{"proxy_port"} // ""
l!l
803
$$c{"root"} // ""
l!l
380
$$c{"root"} // ""
l!l
380
$$c{"ssl_client_verify"} // "NONE"
l!l
083
$$r{"sni"} // $host
l!l&&r!l&&!r
0830
$$r{"client_ip"} // ""
l!l
830
MC/DC0%0/1
$$c{"srv"}{"names"}[0] // ""
$$c{"srv"}{"names"}[0]
MC/DC0%0/1
$$r{"headers"}{"host"} // ""
$$r{"headers"}{"host"}
MC/DC0%0/1
$$c{"args"} // ""
$$c{"args"}
MC/DC0%0/1
$$c{"args"} // ""
$$c{"args"}
MC/DC0%0/1
$$c{"args"} // ""
$$c{"args"}
MC/DC0%0/1
$$r{"client_ip"} // "127.0.0.1"
$$r{"client_ip"}
MC/DC0%0/1
$$c{"srv"}{"names"}[0] // ""
$$c{"srv"}{"names"}[0]
MC/DC100%1/1
$$c{"proxy_host"} // ""
$$c{"proxy_host"}
MC/DC100%1/1
$$c{"proxy_port"} // ""
$$c{"proxy_port"}
MC/DC100%1/1
$$c{"root"} // ""
$$c{"root"}
MC/DC100%1/1
$$c{"root"} // ""
$$c{"root"}
MC/DC0%0/1
$$c{"ssl_client_verify"} // "NONE"
$$c{"ssl_client_verify"}
MC/DC0%0/2
$$r{"sni"} // $host
$$r{"sni"} $host
MC/DC0%0/1
$$r{"client_ip"} // ""
$$r{"client_ip"}
Truth table0%0/2
A
A= $$c{"srv"}{"names"}[0]
Aresult
11
00
Truth table50%1/2
A
A= $$r{"headers"}{"host"}
Aresult
11
00
Truth table50%1/2
A
A= $$c{"args"}
Aresult
11
00
Truth table50%1/2
A
A= $$c{"args"}
Aresult
11
00
Truth table50%1/2
A
A= $$c{"args"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"client_ip"}
Aresult
11
00
Truth table50%1/2
A
A= $$c{"srv"}{"names"}[0]
Aresult
11
00
Truth table100%2/2
A
A= $$c{"proxy_host"}
Aresult
11
00
Truth table100%2/2
A
A= $$c{"proxy_port"}
Aresult
11
00
Truth table100%2/2
A
A= $$c{"root"}
Aresult
11
00
Truth table100%2/2
A
A= $$c{"root"}
Aresult
11
00
Truth table50%1/2
A
A= $$c{"ssl_client_verify"}
Aresult
11
00
Truth table33%1/3
A // B
A= $$r{"sni"}B= $host
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$r{"client_ip"}
Aresult
11
00
808 83 ▶ $v{proxy_add_x_forwarded_for} = defined $r->{headers}{'x-forwarded-for'} ? "$r->{headers}{'x-forwarded-for'}, $v{remote_addr}" : $v{remote_addr};
Branch: 1 branch
BranchTrueFalseTotal
defined $$r{'headers'}{'x-forwarded-for'} ? : 0 83 83
809 83 ▶ return $v{$v} if exists $v{$v};
Branch: 1 branch
BranchTrueFalseTotal
if exists $v{$v} 82 1 83
810 1 ▶ if ( $v =~ /\Ahttp_(\w+)\z/ ) { ( my $n = lc $1 ) =~ tr/_/-/; return $r->{headers}{$n} // '' }
Branch: 1 branch
BranchTrueFalseTotal
if ($v =~ /\Ahttp_(\w+)\z/) 1 0 1
Condition50%1/2
$$r{"headers"}{$n} // ""
l!l
10
MC/DC0%0/1
$$r{"headers"}{$n} // ""
$$r{"headers"}{$n}
Truth table50%1/2
A
A= $$r{"headers"}{$n}
Aresult
11
00
811 0 ▶ if ( $v =~ /\Aarg_(\w+)\z/ ) { my $n = $1; return ( $c->{args} // '' ) =~ /(?:\A|&)\Q$n\E=([^&]*)/ ? $1 : '' }
Branch: 2 branches
BranchTrueFalseTotal
if ($v =~ /\Aarg_(\w+)\z/) 0 0 0
($$c{'args'} // '') =~ /(?:\A|&)\Q$n\E=([^&]*)/ ? : 0 0 0
Condition0%0/2
$$c{"args"} // ""
l!l
00
MC/DC0%0/1
$$c{"args"} // ""
$$c{"args"}
Truth table0%0/2
A
A= $$c{"args"}
Aresult
11
00
812 0 ▶ if ( $v =~ /\Acookie_(\w+)\z/ ) { my $n = $1; return ( $r->{headers}{cookie} // '' ) =~ /(?:\A|;\s*)\Q$n\E=([^;]*)/ ? $1 : '' }
Branch: 2 branches
BranchTrueFalseTotal
if ($v =~ /\Acookie_(\w+)\z/) 0 0 0
($$r{'headers'}{'cookie'} // '') =~ /(?:\A|;\s*)\Q$n\E=([^;]*)/ ? : 0 0 0
Condition0%0/2
$$r{"headers"}{"cookie"} // ""
l!l
00
MC/DC0%0/1
$$r{"headers"}{"cookie"} // ""
$$r{"headers"}{"cookie"}
Truth table0%0/2
A
A= $$r{"headers"}{"cookie"}
Aresult
11
00
813 0 return '';
814 }
815  
816 349 ▶sub _interp {
Subroutine _interp: called CC=2 SCAR=7.4
817 349 my ( $c, $s ) = @_;
818 349 ▶ $s =~ s/\$(?:\{(\w+)\}|(\d|[A-Za-z_]\w*))/_var( $c, $1 \/\/ $2 )/ge;
Condition33%1/3
$1 // $2
l!l&&r!l&&!r
0830
MC/DC0%0/2
$1 // $2
$1 $2
Truth table33%1/3
A // B
A= $1B= $2
ABresult
1X1
011
000
819 349 return $s;
820 }
821  
822 0 ▶sub _cond {
Subroutine _cond: not called CC=13 SCAR=52.0
823 0 my ( $c, @a ) = @_;
824 0 my $e = join ' ', @a;
825 0 $e =~ s/\A\(\s*//;
826 0 $e =~ s/\s*\)\z//;
827 0 ▶ if ( $e =~ /\A(\$\S+)\s*(=|!=|~\*|~|!~\*|!~)\s*(.*)\z/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ /\A(\$\S+)\s*(=|!=|~\*|~|!~\*|!~)\s*(.*)\z/s) 0 0 0
828 0 my ( $l, $op, $r ) = ( _interp( $c, $1 ), $2, $3 );
829 0 $r =~ s/\A(["'])(.*)\1\z/$2/s;
830 0 ▶ return $l eq _interp( $c, $r ) if $op eq '=';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "=" 0 0 0
831 0 ▶ return $l ne _interp( $c, $r ) if $op eq '!=';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "!=" 0 0 0
832 0 ▶ my $m = $op =~ /\*/ ? $l =~ /$r/i : $l =~ /$r/;
Branch: 1 branch
BranchTrueFalseTotal
$op =~ /\*/ ? : 0 0 0
833 0 ▶ $c->{cap} = [ $&, map { substr( $l, $-[$_], $+[$_] - $-[$_] ) } 1 .. $#- ] if $m && $op !~ /!/;
Branch: 1 branch
BranchTrueFalseTotal
if $m and not $op =~ /!/ 0 0 0
Condition0%0/3
$m and not $op =~ /!/
!ll&&!rl&&r
000
MC/DC0%0/2
$m and not $op =~ /!/
$m not $op =~ /!/
Truth table0%0/3
A and not(B)
A= $mB= not $op =~ /!/
ABresult
0X0
100
111
834 0 ▶ return $op =~ /!/ ? !$m : $m;
Branch: 1 branch
BranchTrueFalseTotal
$op =~ /!/ ? : 0 0 0
835 }
836 0 ▶ if ( $e =~ /\A(!?)-([fde])\s+(\S+)\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ /\A(!?)-([fde])\s+(\S+)\z/) 0 0 0
837 0 my ( $neg, $t, $p ) = ( $1, $2, _interp( $c, $3 ) );
838 0 ▶ my $x = $t eq 'd' ? _L()->can('_is_dir')->( $c->{dev}, $p ) : defined _ftext( $c->{dev}, $p );
Branch: 1 branch
BranchTrueFalseTotal
$t eq 'd' ? : 0 0 0
839 0 ▶ return $neg ? !$x : $x;
Branch: 1 branch
BranchTrueFalseTotal
$neg ? : 0 0 0
840 }
841 0 ▶ if ( $e =~ /\A(\$\S+)\z/ ) { my $v = _interp( $c, $1 ); return length $v && $v ne '0' }
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ /\A(\$\S+)\z/) 0 0 0
Condition0%0/3
length $v && $v ne '0'
!ll&&!rl&&r
000
MC/DC0%0/2
length $v && $v ne '0'
length $v $v ne '0'
Truth table0%0/3
A && B
A= length $vB= $v ne '0'
ABresult
0X0
100
111
842 0 return 0;
843 }
844  
845 # Rewrite-Phase: ( 'res', $res ) | ( 'last' ) | ( 'break' ) | ()
846 235 ▶sub _rewrite_phase {
Subroutine _rewrite_phase: called CC=29 SCAR=61.7
847 235 my ( $c, $dirs ) = @_;
848 235 my $changed;
849 235 for my $d (@$dirs) {
850 1051 my $n = $d->{name};
851 1051 ▶ if ( $n eq 'return' ) { return ( 'res', _return( $c, @{ $d->{args} } ) ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "return") 38 1013 1051
852 0 ▶ if ( $n eq 'set' ) { ( my $v = $d->{args}[0] ) =~ s/\A\$//; $c->{set}{$v} = _interp( $c, $d->{args}[1] ); next }
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "set") 0 1013 1013
853 0 ▶ if ( $n eq 'break' ) { return ('break') }
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "break") 0 1013 1013
854 1013 ▶ if ( $n eq 'if' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "if") 0 1013 1013
855 0 ▶ next unless _cond( $c, @{ $d->{args} } );
Branch: 1 branch
BranchTrueFalseTotal
unless _cond($c, @{$$d{"args"};}) 0 0 0
856 0 $c->{if_dirs} = $d->{block};
857 0 my @r = _rewrite_phase( $c, $d->{block} );
858 0 ▶ return @r if @r;
Branch: 1 branch
BranchTrueFalseTotal
if @r 0 0 0
859 0 next;
860 }
861 1013 ▶ if ( $n eq 'rewrite' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "rewrite") 0 1013 1013
862 0 my ( $re, $rep, $flag ) = @{ $d->{args} };
863 0 ▶ my @m = $c->{uri} =~ /$re/ or next;
Branch: 1 branch
BranchTrueFalseTotal
my(@m) = $$c{"uri"} =~ /$re/ or next 0 0 0
864 0 ▶ $c->{cap} = [ $&, map { defined $-[$_] ? substr( $c->{uri}, $-[$_], $+[$_] - $-[$_] ) : '' } 1 .. $#- ];
Branch: 1 branch
BranchTrueFalseTotal
defined $-[$_] ? : 0 0 0
865 0 my $no_args = $rep =~ s/\?\z//;
866 0 my $new = _interp( $c, $rep );
867 0 ▶ if ( $new =~ /\?/ ) { ( $new, my $a ) = split /\?/, $new, 2; $c->{args} = length( $c->{args} // '' ) && !$no_args ? "$a&$c->{args}" : $a }
Branch: 3 branches
BranchTrueFalseTotal
if ($new =~ /\?/) { } 0 0 0
elsif ($no_args) { } 0 0 0
length($$c{'args'} // '') && !$no_args ? : 0 0 0
Condition0%0/5
length($$c{"args"} // "") and not $no_args
!ll&&!rl&&r
000
$$c{"args"} // ""
l!l
00
MC/DC0%0/2
length($$c{"args"} // "") and not $no_args
$$c{"args"} not $no_args
Truth table0%0/3
A and not(B)
A= $$c{"args"}B= not $no_args
ABresult
0X0
100
111
868 0 elsif ($no_args) { $c->{args} = '' }
869 0 ▶ my $redir = ( $flag // '' ) =~ /\A(?:redirect|permanent)\z/ || $new =~ m{\Ahttps?://};
Condition0%0/5
($flag // '') =~ /\A(?:redirect|permanent)\z/ || $new =~ m[\Ahttps?://]
l!l&&r!l&&!r
000
$flag // ""
l!l
00
MC/DC0%0/2
($flag // '') =~ /\A(?:redirect|permanent)\z/ || $new =~ m[\Ahttps?://]
$flag $new =~ m[\Ahttps?://]
Truth table0%0/3
A || B
A= $flagB= $new =~ m[\Ahttps?://]
ABresult
1X1
011
000
870 0 ▶ if ($redir) {
Branch: 1 branch
BranchTrueFalseTotal
if ($redir) 0 0 0
871 0 ▶ my $code = ( $flag // '' ) eq 'permanent' ? 301 : 302;
Branch: 1 branch
BranchTrueFalseTotal
($flag // '') eq 'permanent' ? : 0 0 0
Condition0%0/2
$flag // ""
l!l
00
MC/DC0%0/1
$flag // ""
$flag
Truth table0%0/2
A
A= $flag
Aresult
11
00
872 0 ▶ my $loc = $new =~ m{\Ahttps?://} ? $new : "$c->{req}{scheme}://" . _var( $c, 'host' ) . _port_part($c) . $new;
Branch: 1 branch
BranchTrueFalseTotal
$new =~ m[\Ahttps?://] ? : 0 0 0
873 0 ▶ $loc .= '?' . $c->{args} if length( $c->{args} // '' );
Branch: 1 branch
BranchTrueFalseTotal
if length($$c{"args"} // "") 0 0 0
Condition0%0/2
$$c{"args"} // ""
l!l
00
MC/DC0%0/1
$$c{"args"} // ""
$$c{"args"}
Truth table0%0/2
A
A= $$c{"args"}
Aresult
11
00
874 0 return ( 'res', { status => $code, headers => [ [ 'Content-Type', 'text/html' ], [ 'Location', $loc ] ], body => _page( $code, $c->{tokens} ) } );
875 }
876 0 $c->{uri} = $new;
877 0 $c->{rewritten} = 1;
878 0 ▶ return ('last') if ( $flag // '' ) eq 'last';
Branch: 1 branch
BranchTrueFalseTotal
if ($flag // "") eq "last" 0 0 0
Condition0%0/2
$flag // ""
l!l
00
MC/DC0%0/1
$flag // ""
$flag
Truth table0%0/2
A
A= $flag
Aresult
11
00
879 0 ▶ return ('break') if ( $flag // '' ) eq 'break';
Branch: 1 branch
BranchTrueFalseTotal
if ($flag // "") eq "break" 0 0 0
Condition0%0/2
$flag // ""
l!l
00
MC/DC0%0/1
$flag // ""
$flag
Truth table0%0/2
A
A= $flag
Aresult
11
00
880 0 $changed = 1;
881 }
882 }
883 197 ▶ return $changed ? ('last') : ();
Branch: 1 branch
BranchTrueFalseTotal
$changed ? : 0 197 197
884 }
885  
886 0 ▶sub _port_part { my ($c) = @_; my $p = $c->{req}{port}; return ( $c->{req}{scheme} eq 'https' && $p == 443 || $c->{req}{scheme} eq 'http' && $p == 80 ) ? '' : ":$p" }
Subroutine _port_part: not called CC=5 SCAR=34.0
Branch: 1 branch
BranchTrueFalseTotal
$$c{'req'}{'scheme'} eq 'https' && $p == 443 || $$c{'req'}{'scheme'} eq 'http' && $p == 80 ? : 0 0 0
Condition0%0/9
$$c{"req"}{"scheme"} eq "https" and $p == 443 or $$c{"req"}{"scheme"} eq "http" and $p == 80
l!l&&r!l&&!r
000
$$c{"req"}{"scheme"} eq "https" and $p == 443
!ll&&!rl&&r
000
$$c{"req"}{"scheme"} eq "http" and $p == 80
!ll&&!rl&&r
000
MC/DC0%0/4
$$c{"req"}{"scheme"} eq "https" and $p == 443 or $$c{"req"}{"scheme"} eq "http" and $p == 80
$$c{"req"}{"scheme"} eq "https" $p == 443 $$c{"req"}{"scheme"} eq "http" $p == 80
Truth table0%0/7
A and B or C and D
A= $$c{"req"}{"scheme"} eq "https"B= $p == 443C= $$c{"req"}{"scheme"} eq "http"D= $p == 80
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
887  
888 38 ▶sub _return {
Subroutine _return: called CC=7 SCAR=27.0
889 38 my ( $c, $code, $text ) = @_;
890 0 ▶ if ( $code !~ /\A\d+\z/ ) { ( $code, $text ) = ( 302, $code ) }
Branch: 1 branch
BranchTrueFalseTotal
unless ($code =~ /\A\d+\z/) 0 38 38
891 38 ▶ return { error => '(52) Empty reply from server', code => 52 } if $code == 444;
Branch: 1 branch
BranchTrueFalseTotal
if $code == 444 2 36 38
892 36 ▶ if ( $code =~ /\A30[12378]\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code =~ /\A30[12378]\z/) 0 36 36
893 0 ▶ my $loc = _interp( $c, $text // '' );
Condition0%0/2
$text // ""
l!l
00
MC/DC0%0/1
$text // ""
$text
Truth table0%0/2
A
A= $text
Aresult
11
00
894 0 ▶ $loc = "$c->{req}{scheme}://" . _var( $c, 'host' ) . _port_part($c) . $loc if $loc =~ m{\A/};
Branch: 1 branch
BranchTrueFalseTotal
if $loc =~ m[\A/] 0 0 0
895 0 return { status => 0 + $code, headers => [ [ 'Content-Type', 'text/html' ], [ 'Location', $loc ] ], body => _page( $code, $c->{tokens} ) };
896 }
897 36 ▶ return { status => 0 + $code, headers => [ [ 'Content-Type', 'text/plain' ] ], body => _interp( $c, $text ) } if defined $text;
Branch: 1 branch
BranchTrueFalseTotal
if defined $text 36 0 36
898 0 return { status => 0 + $code, headers => [ [ 'Content-Type', 'text/html' ] ], body => _page( $code, $c->{tokens} ) };
899 }
900  
901 # Location-Suche (verschachtelt): ( location, [ kette ] )
902 117 ▶sub _find_loc {
Subroutine _find_loc: called CC=15 SCAR=31.3
903 117 my ( $locs, $uri ) = @_;
904 117 ▶ my ($ex) = grep { $_->{mod} eq '=' && $_->{uri} eq $uri } @$locs;
Condition33%1/3
$$_{'mod'} eq '=' && $$_{'uri'} eq $uri
!ll&&!rl&&r
44700
MC/DC0%0/2
$$_{'mod'} eq '=' && $$_{'uri'} eq $uri
$$_{'mod'} eq '=' $$_{'uri'} eq $uri
Truth table33%1/3
A && B
A= $$_{'mod'} eq '='B= $$_{'uri'} eq $uri
ABresult
0X0
100
111
905 117 ▶ return ( $ex, [$ex] ) if $ex;
Branch: 1 branch
BranchTrueFalseTotal
if $ex 0 117 117
906 71 my ($best) = sort { length $b->{uri} <=> length $a->{uri} }
907 117 ▶ grep { ( $_->{mod} eq '' || $_->{mod} eq '^~' ) && substr( $uri, 0, length $_->{uri} ) eq $_->{uri} } @$locs;
Condition100%6/6
($$_{'mod'} eq '' || $$_{'mod'} eq '^~') && substr($uri, 0, length $$_{'uri'}) eq $$_{'uri'}
!ll&&!rl&&r
81178188
$$_{"mod"} eq "" or $$_{"mod"} eq "^~"
l!l&&r!l&&!r
363381
MC/DC100%3/3
($$_{'mod'} eq '' || $$_{'mod'} eq '^~') && substr($uri, 0, length $$_{'uri'}) eq $$_{'uri'}
$$_{"mod"} eq "" $$_{"mod"} eq "^~" substr($uri, 0, length $$_{'uri'}) eq $$_{'uri'}
Truth table80%4/5
A or B && C
A= $$_{"mod"} eq ""B= $$_{"mod"} eq "^~"C= substr($uri, 0, length $$_{'uri'}) eq $$_{'uri'}
ABCresult
00X0
1X00
0100
1X11
0111
908 117 ▶ if ( $best && @{ $best->{children} } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($best and @{$$best{"children"};}) 0 117 117
Condition33%1/3
$best and @{$$best{"children"};}
!ll&&!rl&&r
01170
MC/DC0%0/2
$best and @{$$best{"children"};}
$best @{$$best{"children"};}
Truth table33%1/3
A and B
A= $bestB= @{$$best{"children"};}
ABresult
0X0
100
111
909 0 my ( $in, $chain ) = _find_loc( $best->{children}, $uri );
910 0 ▶ return ( $in, [ $best, @$chain ] ) if $in;
Branch: 1 branch
BranchTrueFalseTotal
if $in 0 0 0
911 }
912 117 ▶ return ( $best, [$best] ) if $best && $best->{mod} eq '^~';
Branch: 1 branch
BranchTrueFalseTotal
if $best and $$best{"mod"} eq "^~" 3 114 117
Condition66%2/3
$best and $$best{"mod"} eq "^~"
!ll&&!rl&&r
01143
MC/DC50%1/2
$best and $$best{"mod"} eq "^~"
$best $$best{"mod"} eq "^~"
Truth table66%2/3
A and B
A= $bestB= $$best{"mod"} eq "^~"
ABresult
0X0
100
111
913 114 for my $l ( grep { $_->{re} } @$locs ) {
914 78 ▶ if ( my @m = $uri =~ $l->{re} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@m) = $uri =~ /$$l{"re"}/) 2 76 78
915 0 ▶ if ( @{ $l->{children} } ) { my ( $in, $chain ) = _find_loc( $l->{children}, $uri ); return ( $in, [ $l, @$chain ] ) if $in }
Branch: 2 branches
BranchTrueFalseTotal
if (@{$$l{"children"};}) 0 2 2
if $in 0 0 0
916 2 return ( $l, [$l] );
917 }
918 }
919 112 ▶ return $best ? ( $best, [$best] ) : ();
Branch: 1 branch
BranchTrueFalseTotal
$best ? : 112 0 112
920 }
921  
922 3 ▶sub _in_cidr {
Subroutine _in_cidr: called CC=3 SCAR=11.0
923 3 my ( $ip, $c ) = @_;
924 3 ▶ return 1 if $c eq 'all';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "all" 1 2 3
925 2 ▶ $c .= '/32' unless $c =~ m{/};
Branch: 1 branch
BranchTrueFalseTotal
unless $c =~ m[/] 0 2 2
926 2 return _L()->can('_in')->( $ip, $c );
927 }
928  
929 118 ▶sub _handle {
Subroutine _handle: called CC=35 SCAR=41.2
930 118 my ($c) = @_;
931 118 my $cfg = $c->{cfg};
932 118 my $srv = $c->{srv};
933 118 my $r = $c->{req};
934 118 ( $c->{uri}, $c->{args} ) = split /\?/, $r->{path}, 2;
935 118 ▶ $c->{args} //= '';
Condition100%2/2
$$c{"args"} //= ""
l!l
6256
MC/DC100%1/1
$$c{"args"} //= ""
$$c{"args"}
Truth table100%2/2
A
A= $$c{"args"}
Aresult
11
00
936 118 my @sr = _rewrite_phase( $c, $srv->{dirs} );
937 118 ▶ return _finish( $c, $sr[1], [] ) if @sr && $sr[0] eq 'res';
Branch: 1 branch
BranchTrueFalseTotal
if @sr and $sr[0] eq "res" 2 116 118
Condition66%2/3
@sr and $sr[0] eq "res"
!ll&&!rl&&r
11602
MC/DC50%1/2
@sr and $sr[0] eq "res"
@sr $sr[0] eq "res"
Truth table66%2/3
A and B
A= @srB= $sr[0] eq "res"
ABresult
0X0
100
111
938 116 my ( $loc, $chain );
939 116 my $named;
940 116 for my $round ( 1 .. 11 ) {
941 117 ▶ return _finish( $c, $c->{html}->(500), [] ) if $round == 11;
Branch: 1 branch
BranchTrueFalseTotal
if $round == 11 0 117 117
942 0 ▶ if ($named) { ($loc) = grep { $_->{mod} eq '@' && $_->{uri} eq $named } @{ $srv->{locations} }; $chain = [$loc]; undef $named }
Branch: 1 branch
BranchTrueFalseTotal
if ($named) { } 0 117 117
Condition0%0/3
$$_{'mod'} eq '@' && $$_{'uri'} eq $named
!ll&&!rl&&r
000
MC/DC0%0/2
$$_{'mod'} eq '@' && $$_{'uri'} eq $named
$$_{'mod'} eq '@' $$_{'uri'} eq $named
Truth table0%0/3
A && B
A= $$_{'mod'} eq '@'B= $$_{'uri'} eq $named
ABresult
0X0
100
111
943 117 else { ( $loc, $chain ) = _find_loc( $srv->{locations}, $c->{uri} ) }
944 117 $c->{loc} = $loc;
945 117 $c->{if_dirs} = undef;
946 117 ▶ my @lv = ( $srv->{dirs}, map { $_->{dirs} } grep {defined} @{ $chain || [] } );
Condition50%1/2
$chain || []
l!l
1170
MC/DC0%0/1
$chain || []
$chain
Truth table50%1/2
A
A= $chain
Aresult
11
00
947 117 $c->{levels} = \@lv;
948 117 ▶ if ($loc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($loc) 117 0 117
949 117 my @rr = _rewrite_phase( $c, $loc->{dirs} );
950 117 ▶ return _finish( $c, $rr[1], \@lv ) if @rr && $rr[0] eq 'res';
Branch: 1 branch
BranchTrueFalseTotal
if @rr and $rr[0] eq "res" 36 81 117
Condition66%2/3
@rr and $rr[0] eq "res"
!ll&&!rl&&r
81036
MC/DC50%1/2
@rr and $rr[0] eq "res"
@rr $rr[0] eq "res"
Truth table66%2/3
A and B
A= @rrB= $rr[0] eq "res"
ABresult
0X0
100
111
951 81 ▶ next if @rr && $rr[0] eq 'last';
Branch: 1 branch
BranchTrueFalseTotal
if @rr and $rr[0] eq "last" 0 81 81
Condition33%1/3
@rr and $rr[0] eq "last"
!ll&&!rl&&r
8100
MC/DC0%0/2
@rr and $rr[0] eq "last"
@rr $rr[0] eq "last"
Truth table33%1/3
A and B
A= @rrB= $rr[0] eq "last"
ABresult
0X0
100
111
952 }
953 # Zugriff
954 81 my @ad = _effn( $cfg, \@lv, 'allow', 'deny' );
955 81 for my $d (@ad) {
956 3 ▶ next unless _in_cidr( $r->{client_ip} // '127.0.0.1', $d->{args}[0] );
Branch: 1 branch
BranchTrueFalseTotal
unless _in_cidr($$r{"client_ip"} // "127.0.0.1", $$d{"args"}[0]) 1 2 3
Condition50%1/2
$$r{"client_ip"} // "127.0.0.1"
l!l
30
MC/DC0%0/1
$$r{"client_ip"} // "127.0.0.1"
$$r{"client_ip"}
Truth table50%1/2
A
A= $$r{"client_ip"}
Aresult
11
00
957 2 ▶ return _finish( $c, $c->{html}->(403), \@lv ) if $d->{name} eq 'deny';
Branch: 1 branch
BranchTrueFalseTotal
if $$d{"name"} eq "deny" 1 1 2
958 1 last;
959 }
960 80 my $mx = _eff1( $cfg, \@lv, 'client_max_body_size' );
961 80 ▶ my $limit = $mx ? _size( $mx->{args}[0] ) : 1024 * 1024;
Branch: 1 branch
BranchTrueFalseTotal
$mx ? : 80 0 80
962 80 ▶ return _finish( $c, $c->{html}->(413), \@lv ) if $limit && ( $r->{body_size} // 0 ) > $limit;
Branch: 1 branch
BranchTrueFalseTotal
if $limit and ($$r{"body_size"} // 0) > $limit 1 79 80
Condition80%4/5
$limit and ($$r{"body_size"} // 0) > $limit
!ll&&!rl&&r
0791
$$r{"body_size"} // 0
l!l
179
MC/DC50%1/2
$limit and ($$r{"body_size"} // 0) > $limit
$limit $$r{"body_size"}
Truth table66%2/3
A and B
A= $limitB= $$r{"body_size"}
ABresult
0X0
100
111
963 79 ▶ my @pp_levels = ( @lv, $c->{if_dirs} ? $c->{if_dirs} : () );
Branch: 1 branch
BranchTrueFalseTotal
$$c{'if_dirs'} ? : 0 79 79
964 79 ▶ my ($pp) = grep { $_->{name} eq 'proxy_pass' } map {@$_} grep {defined} ( $loc ? $loc->{dirs} : undef ), $c->{if_dirs};
Branch: 1 branch
BranchTrueFalseTotal
$loc ? : 79 0 79
965 79 ▶ return _finish( $c, _proxy( $c, $pp, \@pp_levels ), \@pp_levels ) if $pp;
Branch: 1 branch
BranchTrueFalseTotal
if $pp 74 5 79
966 5 my ( $res, $next ) = _static( $c, \@lv );
967 5 ▶ if ( !defined $next && $res && !$c->{error_paged} && ( my $ep = _error_page( $c, \@lv, $res->{status} ) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $next and $res and not $$c{"error_paged"} and my $ep = _error_page($c, \@lv, $$res{"status"})) 0 5 5
Condition66%6/9
not defined $next and $res and not $$c{"error_paged"} and my $ep = _error_page($c, \@lv, $$res{"status"})
!ll&&!rl&&r
140
not defined $next and $res and not $$c{"error_paged"}
!ll&&!rl&&r
104
not defined $next and $res
!ll&&!rl&&r
104
MC/DC0%0/4
not defined $next and $res and not $$c{"error_paged"} and my $ep = _error_page($c, \@lv, $$res{"status"})
not defined $next $res not $$c{"error_paged"} my $ep = _error_page($c, \@lv, $$res{"status"})
Truth table40%2/5
not(A) and B and not(C) and D
A= not defined $nextB= $resC= not $$c{"error_paged"}D= my $ep = _error_page($c, \@lv, $$res{"status"})
ABCDresult
0XXX0
10XX0
110X0
11100
11111
968 0 ( $next, $c->{status_override} ) = @$ep;
969 0 $c->{error_paged} = 1;
970 }
971 5 ▶ if ( defined $next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $next) 1 4 5
972 0 ▶ if ( $next =~ /\A\@/ ) { $named = $next }
Branch: 1 branch
BranchTrueFalseTotal
if ($next =~ /\A\@/) { } 0 1 1
973 1 ▶ else { ( $c->{uri}, my $a ) = split /\?/, $next, 2; $c->{args} = $a if defined $a }
Branch: 1 branch
BranchTrueFalseTotal
if defined $a 0 1 1
974 1 next;
975 }
976 4 ▶ $res->{status} = $c->{status_override} if $c->{status_override} && ( $res->{status} // 200 ) == 200;
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"status_override"} and ($$res{"status"} // 200) == 200 0 4 4
Condition20%1/5
$$c{"status_override"} and ($$res{"status"} // 200) == 200
!ll&&!rl&&r
400
$$res{"status"} // 200
l!l
00
MC/DC0%0/2
$$c{"status_override"} and ($$res{"status"} // 200) == 200
$$c{"status_override"} $$res{"status"}
Truth table33%1/3
A and B
A= $$c{"status_override"}B= $$res{"status"}
ABresult
0X0
100
111
977 4 return _finish( $c, $res, \@lv );
978 }
979 }
980  
981 # error_page CODE … [=ANTWORT] URI: ( uri, status ) oder undef
982 4 ▶sub _error_page {
Subroutine _error_page: called CC=8 SCAR=39.3
983 4 my ( $c, $lv, $status ) = @_;
984 4 for my $d ( _effn( $c->{cfg}, $lv, 'error_page' ) ) {
985 0 my @a = @{ $d->{args} };
986 0 my $uri = pop @a;
987 0 ▶ my ($resp) = map { /\A=(\d*)\z/ ? $1 : () } @a;
Branch: 1 branch
BranchTrueFalseTotal
/\A=(\d*)\z/ ? : 0 0 0
988 0 ▶ next unless grep { /\A\d{3}\z/ && $_ == ( $status // 0 ) } @a;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {/\A\d{3}\z/ and $_ == ($status // 0);} @a 0 0 0
Condition0%0/5
/\A\d{3}\z/ && $_ == ($status // 0)
!ll&&!rl&&r
000
$status // 0
l!l
00
MC/DC0%0/2
/\A\d{3}\z/ && $_ == ($status // 0)
/\A\d{3}\z/ $_ == ($status // 0)
MC/DC0%0/1
$status // 0
$status
Truth table0%0/3
A && B
A= /\A\d{3}\z/B= $_ == ($status // 0)
ABresult
0X0
100
111
Truth table0%0/2
A
A= $status
Aresult
11
00
989 0 ▶ return [ $uri, defined $resp ? ( length $resp ? $resp : 200 ) : $status ];
Branch: 2 branches
BranchTrueFalseTotal
defined $resp ? : 0 0 0
length $resp ? : 0 0 0
990 }
991 4 return undef;
992 }
993  
994 4 my %ADD_OK = map { $_ => 1 } qw( 200 201 204 206 301 302 303 304 307 308 );
995  
996 118 ▶sub _finish {
Subroutine _finish: called CC=8 SCAR=21.1
997 118 my ( $c, $res, $levels ) = @_;
998 118 ▶ return $res if defined $res->{error};
Branch: 1 branch
BranchTrueFalseTotal
if defined $$res{"error"} 2 116 118
999 116 ▶ my @h = @{ $res->{headers} || [] };
Condition50%1/2
$$res{'headers'} || []
l!l
1160
MC/DC0%0/1
$$res{'headers'} || []
$$res{'headers'}
Truth table50%1/2
A
A= $$res{'headers'}
Aresult
11
00
1000 116 for my $d ( _effn( $c->{cfg}, $levels, 'add_header' ) ) {
1001 80 my ( $n, $v, $always ) = @{ $d->{args} };
1002 80 ▶ next unless $always || $ADD_OK{ $res->{status} // 200 };
Branch: 1 branch
BranchTrueFalseTotal
unless $always or $ADD_OK{$$res{"status"} // 200} 5 75 80
Condition60%3/5
$always or $ADD_OK{$$res{"status"} // 200}
l!l&&r!l&&!r
0755
$$res{"status"} // 200
l!l
800
MC/DC50%1/2
$always or $ADD_OK{$$res{"status"} // 200}
$always $ADD_OK{$$res{"status"} // 200}
MC/DC0%0/1
$$res{"status"} // 200
$$res{"status"}
Truth table66%2/3
A or B
A= $alwaysB= $ADD_OK{$$res{"status"} // 200}
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$res{"status"}
Aresult
11
00
1003 75 my $val = _interp( $c, $v );
1004 75 ▶ push @h, [ $n, $val ] if length $val;
Branch: 1 branch
BranchTrueFalseTotal
if length $val 75 0 75
1005 }
1006 116 $res->{headers} = \@h;
1007 116 return $res;
1008 }
1009  
1010 4 my %TYPE = ( html => 'text/html', htm => 'text/html', css => 'text/css', js => 'application/javascript', json => 'application/json',
1011 png => 'image/png', jpg => 'image/jpeg', jpeg => 'image/jpeg', svg => 'image/svg+xml', txt => 'text/plain', ico => 'image/x-icon' );
1012  
1013 6 ▶sub _is_file {
Subroutine _is_file: called CC=4 SCAR=14.2
1014 6 my ( $dev, $p ) = @_;
1015 6 ▶ return 0 if $p =~ m{/\z};
Branch: 1 branch
BranchTrueFalseTotal
if $p =~ m[/\z] 0 6 6
1016 6 ▶ return defined _ftext( $dev, $p ) && !_L()->can('_is_dir')->( $dev, $p ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined _ftext($dev, $p) && !_L()->can('_is_dir')->($dev, $p) ? : 3 3 6
Condition66%2/3
defined _ftext($dev, $p) and not _L()->can("_is_dir")->($dev, $p)
!ll&&!rl&&r
303
MC/DC50%1/2
defined _ftext($dev, $p) and not _L()->can("_is_dir")->($dev, $p)
defined _ftext($dev, $p) not _L()->can("_is_dir")->($dev, $p)
Truth table66%2/3
A and not(B)
A= defined _ftext($dev, $p)B= not _L()->can("_is_dir")->($dev, $p)
ABresult
0X0
100
111
1017 }
1018  
1019 # statische Dateien: ( antwort ) oder ( undef, neue_uri ) fuer interne Umleitung
1020 5 ▶sub _static {
Subroutine _static: called CC=22 SCAR=36.6
1021 5 my ( $c, $lv ) = @_;
1022 5 my $cfg = $c->{cfg};
1023 5 my $dev = $c->{dev};
1024 5 my $loc = $c->{loc};
1025 5 ▶ my $al = $loc ? ( grep { $_->{name} eq 'alias' } @{ $loc->{dirs} } )[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$loc ? : 5 0 5
1026 5 my $rd = _eff1( $cfg, $lv, 'root' );
1027 5 ▶ my $root = $rd ? _interp( $c, $rd->{args}[0] ) : '/usr/share/nginx/html';
Branch: 1 branch
BranchTrueFalseTotal
$rd ? : 4 1 5
1028 5 ▶ $root = "/usr/share/nginx/$root" unless $root =~ m{\A/};
Branch: 1 branch
BranchTrueFalseTotal
unless $root =~ m[\A/] 0 5 5
1029 5 $c->{root} = $root;
1030 6 ▶ my $map = sub {
Subroutine __ANON__: called CC=6 SCAR=20.5
1031 6 my ($u) = @_;
1032 6 ▶ if ($al) {
Branch: 1 branch
BranchTrueFalseTotal
if ($al) 1 5 6
1033 1 my $a = _interp( $c, $al->{args}[0] );
1034 1 ▶ my $pre = $loc->{mod} eq '' || $loc->{mod} eq '^~' ? $loc->{uri} : '';
Branch: 1 branch
BranchTrueFalseTotal
$$loc{'mod'} eq '' || $$loc{'mod'} eq '^~' ? : 1 0 1
Condition33%1/3
$$loc{"mod"} eq "" or $$loc{"mod"} eq "^~"
l!l&&r!l&&!r
100
MC/DC0%0/2
$$loc{"mod"} eq "" or $$loc{"mod"} eq "^~"
$$loc{"mod"} eq "" $$loc{"mod"} eq "^~"
Truth table33%1/3
A or B
A= $$loc{"mod"} eq ""B= $$loc{"mod"} eq "^~"
ABresult
1X1
011
000
1035 1 ▶ return $a . substr( $u, length $pre ) if length $pre && substr( $u, 0, length $pre ) eq $pre;
Branch: 1 branch
BranchTrueFalseTotal
if length $pre and substr($u, 0, length $pre) eq $pre 1 0 1
Condition33%1/3
length $pre and substr($u, 0, length $pre) eq $pre
!ll&&!rl&&r
001
MC/DC0%0/2
length $pre and substr($u, 0, length $pre) eq $pre
length $pre substr($u, 0, length $pre) eq $pre
Truth table33%1/3
A and B
A= length $preB= substr($u, 0, length $pre) eq $pre
ABresult
0X0
100
111
1036 0 return $a;
1037 }
1038 5 return $root . $u;
1039 5 };
1040 5 my $id = _eff1( $cfg, $lv, 'index' );
1041 0 ▶ my @index = $id ? @{ $id->{args} } : ('index.html');
Branch: 1 branch
BranchTrueFalseTotal
$id ? : 0 5 5
1042 3 ▶ my $serve = sub {
Subroutine __ANON__: called CC=5 SCAR=20.1
1043 3 my ($path) = @_;
1044 3 my ($ext) = $path =~ /\.(\w+)\z/;
1045 3 my $dt = _eff1( $cfg, $lv, 'default_type' );
1046 3 ▶ return { status => 200, headers => [ [ 'Content-Type', $TYPE{ lc( $ext // '' ) } // ( $dt ? $dt->{args}[0] : 'application/octet-stream' ) ] ],
Branch: 1 branch
BranchTrueFalseTotal
$dt ? : 0 0 0
Condition42%3/7
$TYPE{lc($ext // "")} // ($dt ? $$dt{"args"}[0] : "application/octet-stream")
l!l&&r!l&&!r
300
$ext // ""
l!l
30
_ftext($dev, $path) // ""
l!l
30
MC/DC0%0/2
$TYPE{lc($ext // "")} // ($dt ? $$dt{"args"}[0] : "application/octet-stream")
$TYPE{lc($ext // "")} ($dt ? $$dt{"args"}[0] : "application/octet-stream")
MC/DC0%0/1
$ext // ""
$ext
MC/DC0%0/1
_ftext($dev, $path) // ""
_ftext($dev, $path)
Truth table33%1/3
A // B
A= $TYPE{lc($ext // "")}B= ($dt ? $$dt{"args"}[0] : "application/octet-stream")
ABresult
1X1
011
000
Truth table50%1/2
A
A= $ext
Aresult
11
00
Truth table50%1/2
A
A= _ftext($dev, $path)
Aresult
11
00
1047 body => _ftext( $dev, $path ) // '', file => $path };
1048 5 };
1049 5 ▶ my $tf = $loc ? ( grep { $_->{name} eq 'try_files' } @{ $loc->{dirs} } )[0] : undef;
Branch: 1 branch
BranchTrueFalseTotal
$loc ? : 5 0 5
1050 0 ▶ $tf //= ( grep { $_->{name} eq 'try_files' } @{ $c->{srv}{dirs} } )[0] unless $loc;
Branch: 1 branch
BranchTrueFalseTotal
unless $loc 0 5 5
Condition0%0/3
$tf //= (grep {$$_{"name"} eq "try_files";} @{$$c{"srv"}{"dirs"};})[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$tf //= (grep {$$_{"name"} eq "try_files";} @{$$c{"srv"}{"dirs"};})[0]
$tf (grep {$$_{"name"} eq "try_files";} @{$$c{"srv"}{"dirs"};})[0]
Truth table0%0/3
A //= B
A= $tfB= (grep {$$_{"name"} eq "try_files";} @{$$c{"srv"}{"dirs"};})[0]
ABresult
1X1
011
000
1051 5 ▶ if ($tf) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tf) 2 3 5
1052 2 my @a = @{ $tf->{args} };
1053 2 my $last = pop @a;
1054 2 for my $x (@a) {
1055 3 my $u = _interp( $c, $x );
1056 3 ▶ if ( $u =~ m{/\z} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($u =~ m[/\z]) 1 2 3
1057 1 my $d = $map->($u);
1058 1 ▶ for my $i (@index) { return $serve->("$d$i") if _is_file( $dev, "$d$i" ) }
Branch: 1 branch
BranchTrueFalseTotal
if _is_file($dev, "$d$i") 0 1 1
1059 1 next;
1060 }
1061 2 my $p = $map->($u);
1062 2 ▶ return $serve->($p) if _is_file( $dev, $p );
Branch: 1 branch
BranchTrueFalseTotal
if _is_file($dev, $p) 1 1 2
1063 }
1064 1 ▶ return ( $c->{html}->( 0 + $1 ) ) if $last =~ /\A=(\d{3})\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $last =~ /\A=(\d{3})\z/ 0 1 1
1065 1 ▶ return ( undef, $last ) if $last =~ /\A\@/;
Branch: 1 branch
BranchTrueFalseTotal
if $last =~ /\A\@/ 0 1 1
1066 1 return ( undef, _interp( $c, $last ) );
1067 }
1068 3 my $u = $c->{uri};
1069 3 ▶ if ( $u =~ m{/\z} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($u =~ m[/\z]) 0 3 3
1070 0 my $d = $map->($u);
1071 0 for my $i (@index) {
1072 0 ▶ return $serve->("$d$i") if _is_file( $dev, "$d$i" );
Branch: 1 branch
BranchTrueFalseTotal
if _is_file($dev, "$d$i") 0 0 0
1073 }
1074 0 ▶ return $c->{html}->( _L()->can('_is_dir')->( $dev, $d ) ? 403 : 404 );
Branch: 1 branch
BranchTrueFalseTotal
_L()->can('_is_dir')->($dev, $d) ? : 0 0 0
1075 }
1076 3 my $p = $map->($u);
1077 3 ▶ return $serve->($p) if _is_file( $dev, $p );
Branch: 1 branch
BranchTrueFalseTotal
if _is_file($dev, $p) 2 1 3
1078 1 ▶ if ( _L()->can('_is_dir')->( $dev, $p ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_L()->can("_is_dir")->($dev, $p)) 0 1 1
1079 0 my $loc2 = "$c->{req}{scheme}://" . _var( $c, 'host' ) . _port_part($c) . "$u/";
1080 0 return { status => 301, headers => [ [ 'Content-Type', 'text/html' ], [ 'Location', $loc2 ] ], body => _page( 301, $c->{tokens} ) };
1081 }
1082 1 return $c->{html}->(404);
1083 }
1084  
1085 74 ▶sub _proxy {
Subroutine _proxy: called CC=37 SCAR=39.1
1086 74 my ( $c, $pp, $lv ) = @_;
1087 74 my $cfg = $c->{cfg};
1088 74 my $r = $c->{req};
1089 74 my $url = _interp( $c, $pp->{args}[0] );
1090 74 ▶ my ( $sch, $host, $port, $upart ) = $url =~ m{\A(https?)://([^/:]+)(?::(\d+))?(/.*)?\z} or return $c->{html}->(500);
Branch: 1 branch
BranchTrueFalseTotal
() = $url =~ m[\A(https?)://([^/:]+)(?::(\d+))?(/.*)?\z] or return $$c{"html"}(500) 74 0 74
1091 74 ▶ my $ups = !defined $port && $cfg->{upstreams}{$host};
Condition66%2/3
!defined($port) && $$cfg{'upstreams'}{$host}
!ll&&!rl&&r
7202
MC/DC50%1/2
!defined($port) && $$cfg{'upstreams'}{$host}
!defined($port) $$cfg{'upstreams'}{$host}
Truth table66%2/3
not(A) && B
A= !defined($port)B= $$cfg{'upstreams'}{$host}
ABresult
0X0
100
111
1092 74 ▶ $c->{proxy_host} = $ups ? $host : $host . ( defined $port ? ":$port" : '' );
Branch: 2 branches
BranchTrueFalseTotal
$ups ? : 2 72 74
defined $port ? : 72 0 72
1093 74 ▶ $c->{proxy_port} = $port // ( $sch eq 'https' ? 443 : 80 );
Branch: 1 branch
BranchTrueFalseTotal
$sch eq 'https' ? : 0 2 2
Condition100%2/2
$port // ($sch eq "https" ? 443 : 80)
l!l
722
MC/DC100%1/1
$port // ($sch eq "https" ? 443 : 80)
$port
Truth table100%2/2
A
A= $port
Aresult
11
00
1094 74 my $loc = $c->{loc};
1095 74 ▶ my $args = length( $c->{args} // '' ) ? "?$c->{args}" : '';
Branch: 1 branch
BranchTrueFalseTotal
length($$c{'args'} // '') ? : 62 12 74
Condition50%1/2
$$c{"args"} // ""
l!l
740
MC/DC0%0/1
$$c{"args"} // ""
$$c{"args"}
Truth table50%1/2
A
A= $$c{"args"}
Aresult
11
00
1096 74 my $out_uri;
1097 74 ▶ if ( defined $upart && !$c->{rewritten} && $loc && ( $loc->{mod} eq '' || $loc->{mod} eq '^~' || $loc->{mod} eq '=' ) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $upart and not $$c{'rewritten'} and $loc and $$loc{'mod'} eq '' || $$loc{'mod'} eq '^~' || $$loc{'mod'} eq '=') { } 65 9 74
elsif ($$c{'rewritten'} or defined $upart) { } 0 9 9
Condition60%9/15
defined $upart and not $$c{"rewritten"} and $loc and $$loc{"mod"} eq "" || $$loc{"mod"} eq "^~" || $$loc{"mod"} eq "="
!ll&&!rl&&r
9065
defined $upart and not $$c{"rewritten"} and $loc
!ll&&!rl&&r
9065
defined $upart and not $$c{"rewritten"}
!ll&&!rl&&r
9065
$$loc{"mod"} eq "" or $$loc{"mod"} eq "^~" or $$loc{"mod"} eq "="
l!l&&r!l&&!r
6500
$$loc{"mod"} eq "" or $$loc{"mod"} eq "^~"
l!l&&r!l&&!r
6230
MC/DC16%1/6
defined $upart and not $$c{"rewritten"} and $loc and $$loc{"mod"} eq "" || $$loc{"mod"} eq "^~" || $$loc{"mod"} eq "="
defined $upart not $$c{"rewritten"} $loc $$loc{"mod"} eq "" $$loc{"mod"} eq "^~" $$loc{"mod"} eq "="
Truth table42%3/7
A and not(B) and C and D or E or F
A= defined $upartB= not $$c{"rewritten"}C= $locD= $$loc{"mod"} eq ""E= $$loc{"mod"} eq "^~"F= $$loc{"mod"} eq "="
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110000
1111XX1
11101X1
1110011
1098 65 my $rest = substr( $c->{uri}, length $loc->{uri} );
1099 65 ▶ $rest = '' if $loc->{mod} eq '=';
Branch: 1 branch
BranchTrueFalseTotal
if $$loc{"mod"} eq "=" 0 65 65
1100 65 $out_uri = $upart . $rest . $args;
1101 }
1102 0 ▶ elsif ( $c->{rewritten} || defined $upart ) { $out_uri = $c->{uri} . $args }
Condition33%1/3
$$c{"rewritten"} or defined $upart
l!l&&r!l&&!r
009
MC/DC0%0/2
$$c{"rewritten"} or defined $upart
$$c{"rewritten"} defined $upart
Truth table33%1/3
A or B
A= $$c{"rewritten"}B= defined $upart
ABresult
1X1
011
000
1103 9 else { $out_uri = $r->{path} }
1104 # Kopfzeilen an das Backend
1105 74 ▶ my %h = %{ $r->{headers} || {} };
Condition50%1/2
$$r{'headers'} || {}
l!l
740
MC/DC0%0/1
$$r{'headers'} || {}
$$r{'headers'}
Truth table50%1/2
A
A= $$r{'headers'}
Aresult
11
00
1106 74 delete @h{qw( host connection upgrade keep-alive te proxy-connection )};
1107 74 my @set = ( [ 'Host', '$proxy_host' ], [ 'Connection', 'close' ] );
1108 74 push @set, map { [ $_->{args}[0], $_->{args}[1] ] } _effn( $cfg, $lv, 'proxy_set_header' );
1109 74 for my $s (@set) {
1110 155 my $v = _interp( $c, $s->[1] );
1111 0 ▶ if ( length $v ) { $h{ lc $s->[0] } = $v } else { delete $h{ lc $s->[0] } }
Branch: 1 branch
BranchTrueFalseTotal
if (length $v) { } 155 0 155
1112 }
1113 74 my $hv = _eff1( $cfg, $lv, 'proxy_http_version' );
1114 74 ▶ delete $h{upgrade} unless $hv && $hv->{args}[0] eq '1.1';
Branch: 1 branch
BranchTrueFalseTotal
unless $hv and $$hv{"args"}[0] eq "1.1" 73 1 74
Condition66%2/3
$hv and $$hv{"args"}[0] eq "1.1"
!ll&&!rl&&r
7301
MC/DC50%1/2
$hv and $$hv{"args"}[0] eq "1.1"
$hv $$hv{"args"}[0] eq "1.1"
Truth table66%2/3
A and B
A= $hvB= $$hv{"args"}[0] eq "1.1"
ABresult
0X0
100
111
1115 74 my $rt = _eff1( $cfg, $lv, 'proxy_read_timeout' );
1116 74 ▶ my $timeout = $rt ? _secs( $rt->{args}[0] ) : 60;
Branch: 1 branch
BranchTrueFalseTotal
$rt ? : 1 73 74
1117 my @cand = $ups
1118 74 ▶ ? ( ( map { $_->{addr} } grep { !$_->{down} && !$_->{backup} } @$ups ), ( map { $_->{addr} } grep { !$_->{down} && $_->{backup} } @$ups ) )
Branch: 2 branches
BranchTrueFalseTotal
$ups ? : 2 72 74
defined $port ? : 72 0 72
Condition66%4/6
$$_{'down'} || $$_{'backup'}
l!l&&r!l&&!r
022
!$$_{'down'} && $$_{'backup'}
!ll&&!rl&&r
022
MC/DC50%1/2
$$_{'down'} || $$_{'backup'}
$$_{'down'} $$_{'backup'}
MC/DC50%1/2
!$$_{'down'} && $$_{'backup'}
!$$_{'down'} $$_{'backup'}
Truth table66%2/3
A || B
A= $$_{'down'}B= $$_{'backup'}
ABresult
1X1
011
000
Truth table66%2/3
not(A) && B
A= !$$_{'down'}B= $$_{'backup'}
ABresult
0X0
100
111
1119 : ( $host . ( defined $port ? ":$port" : '' ) );
1120 74 ▶ return $c->{html}->(502) if $c->{depth} > 6;
Branch: 1 branch
BranchTrueFalseTotal
if $$c{"depth"} > 6 0 74 74
1121 74 my $timed_out;
1122 74 for my $addr (@cand) {
1123 my $res = Langertha::Holmgang::Sim::Linux::Http::request( $c->{state}, $c->{to},
1124 { url => "$sch://$addr$out_uri", method => $r->{method}, headers => {%h}, insecure => 1,
1125 76 ▶ ( defined $r->{body_size} ? ( body_size => $r->{body_size} ) : () ) }, $c->{depth} + 1 );
Branch: 1 branch
BranchTrueFalseTotal
defined $$r{'body_size'} ? : 0 76 76
1126 76 ▶ if ( defined $res->{error} ) { next }
Branch: 1 branch
BranchTrueFalseTotal
if (defined $$res{"error"}) 3 73 76
1127 73 ▶ if ( ( $res->{delay} // 0 ) > $timeout ) { $timed_out = 1; next }
Branch: 1 branch
BranchTrueFalseTotal
if (($$res{"delay"} // 0) > $timeout) 1 72 73
Condition50%1/2
$$res{"delay"} // 0
l!l
730
MC/DC0%0/1
$$res{"delay"} // 0
$$res{"delay"}
Truth table50%1/2
A
A= $$res{"delay"}
Aresult
11
00
1128 72 my %out = %$res;
1129 72 delete @out{qw( tls tls_lines server )};
1130 0 ▶ $out{headers} = [ grep { lc( $_->[0] ) ne 'server' } @{ $res->{headers} || [] } ];
Condition50%1/2
$$res{'headers'} || []
l!l
720
MC/DC0%0/1
$$res{'headers'} || []
$$res{'headers'}
Truth table50%1/2
A
A= $$res{'headers'}
Aresult
11
00
1131 72 return \%out;
1132 }
1133 2 ▶ my $e = $c->{html}->( $timed_out ? 504 : 502 );
Branch: 1 branch
BranchTrueFalseTotal
$timed_out ? : 1 1 2
1134 2 ▶ $e->{delay} = $timeout if $timed_out;
Branch: 1 branch
BranchTrueFalseTotal
if $timed_out 1 1 2
1135 2 return $e;
1136 }
1137  
1138 4 1;
1139  
1140 __END__
« blib/lib/Langertha/Holmgang/Grader.pm ↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/RedisService.pm »