Respite/Server.pm

filter: Statementstmt 21.9% 106 / 484 Branchbran 10.9% 38 / 346 Conditioncond 10.7% 25 / 233 MC/DCmcdc 1.4% 2 / 134 Subroutinesub 30.2% 23 / 76 Podpod 26.1% 11 / 42 totaltotal 15.5% 205 / 1315 CC 264 SCAR 61.8
CC
264
Cov
16%
cgihandler
1722.0
verify_sig
1640.0
get_api_pass
650.0
CRAP 481.5
« Respite/Validate.pm ↑ Summary Respite/CommandLine.pm »
1 package Net::Respite::Server;
2  
3 # Net::Respite::Server - generic Respite based Respite server
4  
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 our @ISA;
8 4 ▶use base 'Net::Respite::Common'; # Default _configs
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Digest::MD5 qw(md5_hex);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Throw qw(throw);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Time::HiRes qw(sleep);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 18 ▶sub server_name { $_[0]->{'server_name'} ||= ($0 =~ m|/(\w+)$|x) ? $1 : throw 'Missing server_name' }
Subroutine server_name: called CC=3 SCAR=17.3
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$0 =~ m[/(\w+)$]x ? : 0 0 0
Condition33%1/3
$_[0]{"server_name"} ||= $0 =~ m[/(\w+)$]x ? $1 : throw("Missing server_name")
l!l&&r!l&&!r
1800
MC/DC0%0/2
$_[0]{"server_name"} ||= $0 =~ m[/(\w+)$]x ? $1 : throw("Missing server_name")
$_[0]{"server_name"} $0 =~ m[/(\w+)$]x ? $1 : throw("Missing server_name")
Truth table33%1/3
A ||= B
A= $_[0]{"server_name"}B= $0 =~ m[/(\w+)$]x ? $1 : throw("Missing server_name")
ABresult
1X1
011
000
14 0 ▶sub revision { $_[0]->{'revision'} ||= eval { $_[0]->dispatch_class->_revision } || '-' }
Subroutine revision: not called CC=3 SCAR=24.8
Pod undocumented
Condition0%0/5
$_[0]{"revision"} ||= eval { do { $_[0]->dispatch_class->_revision } } || "-"
l!l&&r!l&&!r
000
eval { do { $_[0]->dispatch_class->_revision } } || '-'
l!l
00
MC/DC0%0/2
$_[0]{"revision"} ||= eval { do { $_[0]->dispatch_class->_revision } } || "-"
$_[0]{"revision"} eval { do { $_[0]->dispatch_class->_revision } }
Truth table0%0/3
A ||= B
A= $_[0]{"revision"}B= eval { do { $_[0]->dispatch_class->_revision } }
ABresult
1X1
011
000
15 0 ▶sub max_request_size { $_[0]->{'max_request_size'} || 2_000_000 }
Subroutine max_request_size: not called CC=2 SCAR=17.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"max_request_size"} or 2000000 0 0 0
16 5 ▶sub api_meta { shift->{'api_meta'} }
Subroutine api_meta: called CC=1 SCAR=0.0
Pod documented
17 0 ▶sub dispatch_class { shift->{'dispatch_class'} }
Subroutine dispatch_class: not called CC=1 SCAR=6.9
Pod undocumented
18  
19 ###----------------------------------------------------------------###
20  
21 5 ▶sub new {
Subroutine new: called CC=9 SCAR=23.8
Pod documented
22 5 my $class = shift;
23 5 ▶ my $self = bless ref($_[0]) ? shift : {@_}, $class;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 5 0 5
24 5 ▶ %$self = (%$_, %$self) if $_ = $self->new_args;
Branch: 1 branch
BranchTrueFalseTotal
if $_ = $self->new_args 0 5 5
25 5 ▶ return $self if $self->{'non_daemon'} || ($ENV{'MOD_PERL'} && ! $self->{'force_daemon'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"non_daemon"} or $ENV{"MOD_PERL"} and not $self->{"force_daemon"} 0 5 5
Condition33%2/6
$self->{"non_daemon"} or $ENV{"MOD_PERL"} and not $self->{"force_daemon"}
l!l&&r!l&&!r
005
$ENV{"MOD_PERL"} and not $self->{"force_daemon"}
!ll&&!rl&&r
500
MC/DC0%0/3
$self->{"non_daemon"} or $ENV{"MOD_PERL"} and not $self->{"force_daemon"}
$self->{"non_daemon"} $ENV{"MOD_PERL"} not $self->{"force_daemon"}
Truth table25%1/4
A or B and not(C)
A= $self->{"non_daemon"}B= $ENV{"MOD_PERL"}C= not $self->{"force_daemon"}
ABCresult
1XX1
0111
00X0
0100
26 5 require Net::Server;
27 5 require Net::Server::HTTP;
28 5 ▶ unshift @ISA, qw(Net::Server::HTTP) if !$self->isa(qw(Net::Server::HTTP));;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa("Net::Server::HTTP") 3 2 5
29 5 ▶ throw 'We need a more recent Net::Server revision', {v => $Net::Server::VERSION} if $Net::Server::VERSION < 2.007;
Branch: 1 branch
BranchTrueFalseTotal
if $Net::Server::VERSION < "2.007" 0 5 5
30 5 $self->json; # vivify before fork
31 5 my $server = $class->SUPER::new(%$self, %{ $self->server_args });
32 5 @$server{keys %$self} = values %$self; # TODO - avoid duplicates
33 5 ▶ $self->dispatch_factory('preload') if !$ENV{'NO_PRELOAD'}; # void call will load necessary classes
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"NO_PRELOAD"} 5 0 5
34  
35 5 return $server;
36 }
37  
38 5 ▶sub new_args {}
Subroutine new_args: called CC=1 SCAR=0.0
Pod undocumented
39  
40 60 ▶sub config {
Subroutine config: called CC=7 SCAR=22.9
Pod undocumented
41 60 my ($self, $key, $def, $name) = @_;
42 60 ▶ $name ||= $self->server_name;
Condition33%1/3
$name ||= $self->server_name
l!l&&r!l&&!r
6000
MC/DC0%0/2
$name ||= $self->server_name
$name $self->server_name
Truth table33%1/3
A ||= B
A= $nameB= $self->server_name
ABresult
1X1
011
000
43 60 my $c = $self->_configs($name);
44 return exists($self->{$key}) ? $self->{$key}
45 : exists($c->{"${name}_${key}"}) ? $c->{"${name}_${key}"}
46 60 ▶ : (ref($c->{$name}) && exists $c->{$name}->{$key}) ? $c->{$name}->{$key}
Branch: 4 branches
BranchTrueFalseTotal
exists $self->{$key} ? : 45 15 60
exists $$c{"${name}_$key"} ? : 0 15 15
ref $c->{$name} && exists $c->{$name}{$key} ? : 0 15 15
ref $def eq 'CODE' ? : 0 15 15
Condition33%1/3
ref $c->{$name} and exists $c->{$name}{$key}
!ll&&!rl&&r
1500
MC/DC0%0/2
ref $c->{$name} and exists $c->{$name}{$key}
ref $c->{$name} exists $c->{$name}{$key}
Truth table33%1/3
A and B
A= ref $c->{$name}B= exists $c->{$name}{$key}
ABresult
0X0
100
111
47 : ref($def) eq 'CODE' ? $def->($self) : $def;
48 }
49  
50 5 ▶sub dispatch_factory {
Subroutine dispatch_factory: called CC=9 SCAR=31.8
Pod undocumented
51 5 my ($self, $preload) = @_;
52 5 ▶ return $self->{'dispatch_factory'} ||= do {
Condition33%1/3
$self->{"dispatch_factory"} ||= do { my $meta = $self->api_meta || $self->dispatch_class || throw("Missing one of api_meta or dispatch_class"); if (not ref $meta) { (my $file = "$meta.pm") =~ s[::][/]g; throw("Failed to load dispatch class", {"class", $meta, "file", $file, "msg", $@}) unless $meta->can("new") or eval { do { require $file } }; throw("Specified class does not have a run_method method", {"class", $meta}) unless $meta->can("run_method"); sub { $meta->new(@_); } ; } else { require Net::Respite::Base; "Net::Respite::Base"->new({"api_meta", $meta})->api_preload if $preload; sub { "Net::Respite::Base"->new({%{shift();}, "api_meta", $meta}); } ; } }
l!l&&r!l&&!r
050
MC/DC0%0/2
$self->{"dispatch_factory"} ||= do { my $meta = $self->api_meta || $self->dispatch_class || throw("Missing one of api_meta or dispatch_class"); if (not ref $meta) { (my $file = "$meta.pm") =~ s[::][/]g; throw("Failed to load dispatch class", {"class", $meta, "file", $file, "msg", $@}) unless $meta->can("new") or eval { do { require $file } }; throw("Specified class does not have a run_method method", {"class", $meta}) unless $meta->can("run_method"); sub { $meta->new(@_); } ; } else { require Net::Respite::Base; "Net::Respite::Base"->new({"api_meta", $meta})->api_preload if $preload; sub { "Net::Respite::Base"->new({%{shift();}, "api_meta", $meta}); } ; } }
$self->{"dispatch_factory"} do { my $meta = $self->api_meta || $self->dispatch_class || throw("Missing one of api_meta or dispatch_class"); if (not ref $meta) { (my $file = "$meta.pm") =~ s[::][/]g; throw("Failed to load dispatch class", {"class", $meta, "file", $file, "msg", $@}) unless $meta->can("new") or eval { do { require $file } }; throw("Specified class does not have a run_method method", {"class", $meta}) unless $meta->can("run_method"); sub { $meta->new(@_); } ; } else { require Net::Respite::Base; "Net::Respite::Base"->new({"api_meta", $meta})->api_preload if $preload; sub { "Net::Respite::Base"->new({%{shift();}, "api_meta", $meta}); } ; } }
Truth table33%1/3
A ||= B
A= $self->{"dispatch_factory"}B= do { my $meta = $self->api_meta || $self->dispatch_class || throw("Missing one of api_meta or dispatch_class"); if (not ref $meta) { (my $file = "$meta.pm") =~ s[::][/]g; throw("Failed to load dispatch class", {"class", $meta, "file", $file, "msg", $@}) unless $meta->can("new") or eval { do { require $file } }; throw("Specified class does not have a run_method method", {"class", $meta}) unless $meta->can("run_method"); sub { $meta->new(@_); } ; } else { require Net::Respite::Base; "Net::Respite::Base"->new({"api_meta", $meta})->api_preload if $preload; sub { "Net::Respite::Base"->new({%{shift();}, "api_meta", $meta}); } ; } }
ABresult
1X1
011
000
53 5 ▶ my $meta = $self->api_meta || $self->dispatch_class || throw "Missing one of api_meta or dispatch_class";
Condition33%2/6
$self->api_meta || $self->dispatch_class || throw('Missing one of api_meta or dispatch_class')
l!l&&r!l&&!r
500
$self->api_meta or $self->dispatch_class
l!l&&r!l&&!r
500
MC/DC0%0/3
$self->api_meta || $self->dispatch_class || throw('Missing one of api_meta or dispatch_class')
$self->api_meta $self->dispatch_class throw('Missing one of api_meta or dispatch_class')
Truth table25%1/4
A or B || C
A= $self->api_metaB= $self->dispatch_classC= throw('Missing one of api_meta or dispatch_class')
ABCresult
1XX1
01X1
0011
0000
54 5 ▶ if (!ref $meta) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $meta) { } 5 0 5
55 5 (my $file = "$meta.pm") =~ s|::|/|g;
56 0 ▶ throw "Failed to load dispatch class", {class => $meta, file => $file, msg => $@} if !$meta->can('new') && !eval { require $file };
Branch: 1 branch
BranchTrueFalseTotal
unless $meta->can("new") or eval { do { require $file } } 0 5 5
Condition33%1/3
$meta->can("new") or eval { do { require $file } }
l!l&&r!l&&!r
500
MC/DC0%0/2
$meta->can("new") or eval { do { require $file } }
$meta->can("new") eval { do { require $file } }
Truth table33%1/3
A or B
A= $meta->can("new")B= eval { do { require $file } }
ABresult
1X1
011
000
57 5 ▶ throw "Specified class does not have a run_method method", {class => $meta} if ! $meta->can('run_method');
Branch: 1 branch
BranchTrueFalseTotal
unless $meta->can("run_method") 0 5 5
58 0 ▶ sub { $meta->new(@_) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
59 } else {
60 0 require Net::Respite::Base;
61 0 ▶ Net::Respite::Base->new({api_meta => $meta})->api_preload if $preload;
Branch: 1 branch
BranchTrueFalseTotal
if $preload 0 0 0
62 0 ▶ sub { Net::Respite::Base->new({%{shift()}, api_meta => $meta}) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
63 }
64 };
65 }
66  
67 ###----------------------------------------------------------------###
68 # request handling and method dispatching
69  
70 # mod_perl handler - used via apache conf
71 # <Location /foo/>
72 # SetHandler modperl
73 # PerlResponseHandler FooServer
74 # </Location>
75 # sub handler { __PACKAGE__->modperlhandler(@_) }
76 0 ▶sub modperlhandler {
Subroutine modperlhandler: not called CC=3 SCAR=24.8
Pod undocumented
77 0 my $class = shift;
78 0 ▶ my $r = shift || throw "Missing apache request during ${class}::modperlhandler", {trace => 1};
Condition0%0/3
shift() || throw("Missing apache request during ${class}::modperlhandler", {'trace', 1})
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || throw("Missing apache request during ${class}::modperlhandler", {'trace', 1})
shift() throw("Missing apache request during ${class}::modperlhandler", {'trace', 1})
Truth table0%0/3
A || B
A= shift()B= throw("Missing apache request during ${class}::modperlhandler", {'trace', 1})
ABresult
1X1
011
000
79 0 my $self = $class->new({apache_req => $r, non_daemon => 1});
80 0 my %env = %ENV;
81 0 ▶ if (eval { $self->modperl_init($r); $r->subprocess_env(); 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { $self->modperl_init($r); $r->subprocess_env; 1 } }) { } 0 0 0
82 0 $self->cgihandler();
83 } else {
84 0 warn my $err = $self->json->encode({error => "$@", type => 'mod_perl_header'});
85 0 $self->send_response($err);
86 }
87 0 %ENV = %env;
88 0 return 0; # OK - TODO - we actually may want a 403 for digest errors
89 }
90  
91 4 my $modperl_init;
92 0 ▶sub modperl_init {
Subroutine modperl_init: not called CC=2 SCAR=17.9
Pod undocumented
93 0 ▶ return if $modperl_init;
Branch: 1 branch
BranchTrueFalseTotal
if $modperl_init 0 0 0
94 0 $modperl_init = 1;
95 0 require Apache2::RequestRec;
96 0 require Apache2::RequestIO;
97 0 require APR::Table;
98 }
99  
100 # normal cgi-bin or Net::Server::HTTP handler
101 # Net::Server::HTTP app => \&cgihandler
102 # cgi-bin/server App::cgihandler() or App->new->cgihandler or App->cgihandler
103 0 ▶sub cgihandler {
Subroutine cgihandler: not called CC=41 SCAR=74.5
Pod undocumented
104 0 my $self = shift;
105 0 ▶ $self = ($self || __PACKAGE__)->new({%{shift() || {}}, non_daemon => 1}) if ! $self || ! ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless $self and ref $self 0 0 0
Condition0%0/7
$self and ref $self
!ll&&!rl&&r
000
$self || __PACKAGE__
l!l
00
shift() || {}
l!l
00
MC/DC0%0/2
$self and ref $self
$self ref $self
MC/DC0%0/1
$self || __PACKAGE__
$self
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/3
A and B
A= $selfB= ref $self
ABresult
0X0
100
111
Truth table0%0/2
A
A= $self
Aresult
11
00
Truth table0%0/2
A
A= shift()
Aresult
11
00
106 0 local $self->{'transport'};
107 0 local $self->{'extra_headers'};
108 0 local $self->{'cgi_obj'};
109  
110 0 my $req_sum;
111 0 my $args = eval {
112 0 my $r = $self->{'apache_req'};
113 0 my $req;
114 0 ▶ if ($ENV{'CONTENT_TYPE'} && $ENV{'CONTENT_TYPE'} =~ /\bjson\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{'CONTENT_TYPE'} and $ENV{'CONTENT_TYPE'} =~ /\bjson\b/) { } 0 0 0
Condition0%0/3
$ENV{"CONTENT_TYPE"} and $ENV{"CONTENT_TYPE"} =~ /\bjson\b/
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"CONTENT_TYPE"} and $ENV{"CONTENT_TYPE"} =~ /\bjson\b/
$ENV{"CONTENT_TYPE"} $ENV{"CONTENT_TYPE"} =~ /\bjson\b/
Truth table0%0/3
A and B
A= $ENV{"CONTENT_TYPE"}B= $ENV{"CONTENT_TYPE"} =~ /\bjson\b/
ABresult
0X0
100
111
115 0 ▶ throw 'JSON data may not be submitted via GET' if !$ENV{'REQUEST_METHOD'} || $ENV{'REQUEST_METHOD'} eq 'GET' || $ENV{'REQUEST_METHOD'} eq 'HEAD';
Branch: 1 branch
BranchTrueFalseTotal
if not $ENV{"REQUEST_METHOD"} or $ENV{"REQUEST_METHOD"} eq "GET" or $ENV{"REQUEST_METHOD"} eq "HEAD" 0 0 0
Condition0%0/6
not $ENV{"REQUEST_METHOD"} or $ENV{"REQUEST_METHOD"} eq "GET" or $ENV{"REQUEST_METHOD"} eq "HEAD"
l!l&&r!l&&!r
000
not $ENV{"REQUEST_METHOD"} or $ENV{"REQUEST_METHOD"} eq "GET"
l!l&&r!l&&!r
000
MC/DC0%0/3
not $ENV{"REQUEST_METHOD"} or $ENV{"REQUEST_METHOD"} eq "GET" or $ENV{"REQUEST_METHOD"} eq "HEAD"
not $ENV{"REQUEST_METHOD"} $ENV{"REQUEST_METHOD"} eq "GET" $ENV{"REQUEST_METHOD"} eq "HEAD"
Truth table0%0/4
not(A) or B or C
A= not $ENV{"REQUEST_METHOD"}B= $ENV{"REQUEST_METHOD"} eq "GET"C= $ENV{"REQUEST_METHOD"} eq "HEAD"
ABCresult
1XX1
01X1
0011
0000
116 0 ▶ my $len = $ENV{'CONTENT_LENGTH'} || throw "Missing CONTENT_LENGTH on $ENV{'REQUEST_METHOD'} request", {len => $ENV{'CONTENT_LENGTH'}};
Condition0%0/3
$ENV{'CONTENT_LENGTH'} || throw("Missing CONTENT_LENGTH on $ENV{'REQUEST_METHOD'} request", {'len', $ENV{'CONTENT_LENGTH'}})
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'CONTENT_LENGTH'} || throw("Missing CONTENT_LENGTH on $ENV{'REQUEST_METHOD'} request", {'len', $ENV{'CONTENT_LENGTH'}})
$ENV{'CONTENT_LENGTH'} throw("Missing CONTENT_LENGTH on $ENV{'REQUEST_METHOD'} request", {'len', $ENV{'CONTENT_LENGTH'}})
Truth table0%0/3
A || B
A= $ENV{'CONTENT_LENGTH'}B= throw("Missing CONTENT_LENGTH on $ENV{'REQUEST_METHOD'} request", {'len', $ENV{'CONTENT_LENGTH'}})
ABresult
1X1
011
000
117 0 ▶ throw "Too large a $ENV{'REQUEST_METHOD'} request found", {length => $len, max => $self->max_request_size} if $len > $self->max_request_size;
Branch: 1 branch
BranchTrueFalseTotal
if $len > $self->max_request_size 0 0 0
118 0 my $size = 0;
119 0 while (1) {
120 0 ▶ $r ? $r->read($req, $len - $size, $size) : read(STDIN, $req, $len - $size, $size);
Branch: 1 branch
BranchTrueFalseTotal
$r ? : 0 0 0
121 0 ▶ throw "Failed to read bytes", {needed => $len, got => $size} if length($req) == $size;
Branch: 1 branch
BranchTrueFalseTotal
if length $req == $size 0 0 0
122 0 ▶ last if ($size = length $req) >= $len;
Branch: 1 branch
BranchTrueFalseTotal
if ($size = length $req) >= $len 0 0 0
123 }
124 0 ▶ throw "Failed to read entire $ENV{'REQUEST_METHOD'} request", {length => $len, actual => length($req)} if length($req) != $len;
Branch: 1 branch
BranchTrueFalseTotal
if length $req != $len 0 0 0
125 } else {
126 0 my $args = $self->parse_form($r);
127 0 $req = delete $args->{'POSTDATA'}; # CGI.pm - non-form POST
128 0 ▶ if (!$req) { # get
Branch: 1 branch
BranchTrueFalseTotal
unless ($req) 0 0 0
129 0 $self->{'transport'} = 'form';
130 0 ▶ $args = Data::URIEncode::flat_to_complex($args) || {} if !$self->{'no_data_uriencode'} && (eval { require Data::URIEncode } || ((grep {$_ =~ /[:.]/} keys %$args) && throw "Failed to load Data::URIEncode", {msg => $@}));
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"no_data_uriencode"} and eval { do { require Data::URIEncode } } || grep({$_ =~ /[:.]/;} keys %$args) && throw("Failed to load Data::URIEncode", {"msg", $@}) 0 0 0
Condition0%0/11
not $self->{"no_data_uriencode"} and eval { do { require Data::URIEncode } } || grep({$_ =~ /[:.]/;} keys %$args) && throw("Failed to load Data::URIEncode", {"msg", $@})
!ll&&!rl&&r
000
eval { do { require Data::URIEncode } } or grep {$_ =~ /[:.]/;} keys %$args and throw("Failed to load Data::URIEncode", {"msg", $@})
l!l&&r!l&&!r
000
grep {$_ =~ /[:.]/;} keys %$args and throw("Failed to load Data::URIEncode", {"msg", $@})
!ll&&!rl&&r
000
Data::URIEncode::flat_to_complex($args) || {}
l!l
00
MC/DC0%0/4
not $self->{"no_data_uriencode"} and eval { do { require Data::URIEncode } } || grep({$_ =~ /[:.]/;} keys %$args) && throw("Failed to load Data::URIEncode", {"msg", $@})
not $self->{"no_data_uriencode"} eval { do { require Data::URIEncode } } grep {$_ =~ /[:.]/;} keys %$args throw("Failed to load Data::URIEncode", {"msg", $@})
MC/DC0%0/1
Data::URIEncode::flat_to_complex($args) || {}
Data::URIEncode::flat_to_complex($args)
Truth table0%0/5
not(A) and B or C and D
A= not $self->{"no_data_uriencode"}B= eval { do { require Data::URIEncode } }C= grep {$_ =~ /[:.]/;} keys %$argsD= throw("Failed to load Data::URIEncode", {"msg", $@})
ABCDresult
0XXX0
100X0
10100
11XX1
10111
Truth table0%0/2
A
A= Data::URIEncode::flat_to_complex($args)
Aresult
11
00
131 0 return $args;
132 }
133 0 ▶ throw "Found other args in addition to POSTDATA", {args => $args} if scalar keys %$args;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %$args 0 0 0
134 }
135 0 $self->{'transport'} = 'json';
136 0 ▶ throw "Content data did not look like JSON hash", {head => substr($req, 0, 10)."...", content_type => $ENV{'CONTENT_TYPE'}} if $req !~ /^\{/;
Branch: 1 branch
BranchTrueFalseTotal
unless $req =~ /^\{/ 0 0 0
137 0 $req_sum = md5_hex($req);
138 0 return eval { $self->json->decode($req) }
139 0 ▶ || throw 'Trouble unencoding json', {ip => $ENV{'REMOTE_ADDR'}, msg => $@, head => substr($req, 0, 10)."..."};
Condition0%0/3
eval { do { $self->json->decode($req) } } || throw('Trouble unencoding json', {'ip', $ENV{'REMOTE_ADDR'}, 'msg', $@, 'head', substr($req, 0, 10) . '...'})
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { $self->json->decode($req) } } || throw('Trouble unencoding json', {'ip', $ENV{'REMOTE_ADDR'}, 'msg', $@, 'head', substr($req, 0, 10) . '...'})
eval { do { $self->json->decode($req) } } throw('Trouble unencoding json', {'ip', $ENV{'REMOTE_ADDR'}, 'msg', $@, 'head', substr($req, 0, 10) . '...'})
Truth table0%0/3
A || B
A= eval { do { $self->json->decode($req) } }B= throw('Trouble unencoding json', {'ip', $ENV{'REMOTE_ADDR'}, 'msg', $@, 'head', substr($req, 0, 10) . '...'})
ABresult
1X1
011
000
140 };
141 0 ▶ if (! $args) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args) 0 0 0
142 0 my $err = $self->json->encode({error => "$@", type => 'cgihandler'});
143 0 warn $err;
144 0 return $self->send_response($err);
145 }
146 0 ▶ $ENV{'PATH_INFO'} ||= '';
Condition0%0/2
$ENV{"PATH_INFO"} ||= ""
l!l
00
MC/DC0%0/1
$ENV{"PATH_INFO"} ||= ""
$ENV{"PATH_INFO"}
Truth table0%0/2
A
A= $ENV{"PATH_INFO"}
Aresult
11
00
147  
148 0 ▶ my ($old_out, $out_ref) = $self->{'warn_on_stdout'} ? do { open my $fh, ">", \(my $str =""); (select($fh), \$str) } : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->{'warn_on_stdout'} ? : 0 0 0
149 0 local $self->{'_warn_info'};
150 0 my $ref = eval { $self->_do_request($args, $req_sum, \%ENV) };
151 0 ▶ if (! $ref) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ref) 0 0 0
152 0 $ref = $@;
153 0 ▶ $ref = eval { throw 'Trouble dispatching', {path => $ENV{'PATH_INFO'}, msg => $ref} } || $@ if !ref($ref) || !$ref->{'error'};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ref and $ref->{"error"} 0 0 0
Condition0%0/6
ref $ref and $ref->{"error"}
!ll&&!rl&&r
000
eval { do { throw('Trouble dispatching', {'path', $ENV{'PATH_INFO'}, 'msg', $ref}) } } || $@
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $ref and $ref->{"error"}
ref $ref $ref->{"error"}
MC/DC0%0/2
eval { do { throw('Trouble dispatching', {'path', $ENV{'PATH_INFO'}, 'msg', $ref}) } } || $@
eval { do { throw('Trouble dispatching', {'path', $ENV{'PATH_INFO'}, 'msg', $ref}) } } $@
Truth table0%0/3
A and B
A= ref $refB= $ref->{"error"}
ABresult
0X0
100
111
Truth table0%0/3
A || B
A= eval { do { throw('Trouble dispatching', {'path', $ENV{'PATH_INFO'}, 'msg', $ref}) } }B= $@
ABresult
1X1
011
000
154 0 ▶ local @$ref{keys %$_} = values %$_ if $_ = $self->{'_warn_info'};
Branch: 1 branch
BranchTrueFalseTotal
if $_ = $self->{"_warn_info"} 0 0 0
155 0 warn $ref;
156 }
157 0 ▶ if ($old_out) {
Branch: 1 branch
BranchTrueFalseTotal
if ($old_out) 0 0 0
158 0 select $old_out;
159 0 ▶ warn "--- INVALID STDOUT ---\n$$out_ref\n" if $$out_ref;
Branch: 1 branch
BranchTrueFalseTotal
if $$out_ref 0 0 0
160 }
161  
162 0 ▶ if (ref($ref) eq 'ARRAY' && @$ref == 3 && $ref->[0] =~ /^\d+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref eq "ARRAY" and @$ref == 3 and $ref->[0] =~ /^\d+$/) 0 0 0
Condition0%0/6
ref $ref eq "ARRAY" and @$ref == 3 and $ref->[0] =~ /^\d+$/
!ll&&!rl&&r
000
ref $ref eq "ARRAY" and @$ref == 3
!ll&&!rl&&r
000
MC/DC0%0/3
ref $ref eq "ARRAY" and @$ref == 3 and $ref->[0] =~ /^\d+$/
ref $ref eq "ARRAY" @$ref == 3 $ref->[0] =~ /^\d+$/
Truth table0%0/4
A and B and C
A= ref $ref eq "ARRAY"B= @$ref == 3C= $ref->[0] =~ /^\d+$/
ABCresult
0XX0
10X0
1100
1111
163 0 ▶ return $ref if $self->{'is_psgi'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"is_psgi"} 0 0 0
164 0 require Net::Server::PSGI;
165 0 $self->Net::Server::PSGI::print_psgi_headers($ref->[0], $ref->[1]);
166 0 $self->Net::Server::PSGI::print_psgi_body($ref->[2]);
167 0 return 1;
168 }
169  
170 0 ▶ $self->{'extra_headers'} = delete $ref->{'_extra_headers'} if $ref->{'_extra_headers'};
Branch: 1 branch
BranchTrueFalseTotal
if $ref->{"_extra_headers"} 0 0 0
171 0 ▶ my $out = eval { $self->json->encode($ref) } || do { warn "Trouble encoding json: $@"; "{'error':'Trouble encoding json - check server logs for details'}" };
Condition0%0/3
eval { do { $self->json->encode($ref) } } || do { warn "Trouble encoding json: $@"; q[{'error':'Trouble encoding json - check server logs for details'}] }
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { $self->json->encode($ref) } } || do { warn "Trouble encoding json: $@"; q[{'error':'Trouble encoding json - check server logs for details'}] }
eval { do { $self->json->encode($ref) } } do { warn "Trouble encoding json: $@"; q[{'error':'Trouble encoding json - check server logs for details'}] }
Truth table0%0/3
A || B
A= eval { do { $self->json->encode($ref) } }B= do { warn "Trouble encoding json: $@"; q[{'error':'Trouble encoding json - check server logs for details'}] }
ABresult
1X1
011
000
172 0 return $self->send_response($out);
173 }
174  
175 0 ▶sub _do_request {
Subroutine _do_request: not called CC=8 SCAR=42.8
176 0 my ($self, $args, $req_sum, $env) = @_;
177 0 my ($method, $brand, $extra) = $self->_map_request($args, $env);
178 0 my $ver = $self->verify_sig($args, $req_sum, $env, $method, $brand);
179  
180 0 $self->{'_warn_info'} = {caller => {who => $args->{'_w'}, source => $args->{'_c'}, method => $method, brand => $brand, ip => $env->{'REMOTE_ADDR'}}};
181 0 local $env->{'REMOTE_USER'};
182 my $disp = $self->dispatch_factory->({
183 0 ▶ %{ $extra || {} },
Branch: 1 branch
BranchTrueFalseTotal
$env->{'HTTP_X_FORWARDED_FOR'} ? : 0 0 0
Condition0%0/5
$extra || {}
l!l
00
delete $args->{'_t'} || do { my $k = $self->config('admin_cookie_key'); $k ? $self->parse_cookies->{$k} : '' }
l!l&&r!l&&!r
000
MC/DC0%0/1
$extra || {}
$extra
MC/DC0%0/2
delete $args->{'_t'} || do { my $k = $self->config('admin_cookie_key'); $k ? $self->parse_cookies->{$k} : '' }
delete $args->{'_t'} do { my $k = $self->config('admin_cookie_key'); $k ? $self->parse_cookies->{$k} : '' }
Truth table0%0/2
A
A= $extra
Aresult
11
00
Truth table0%0/3
A || B
A= delete $args->{'_t'}B= do { my $k = $self->config('admin_cookie_key'); $k ? $self->parse_cookies->{$k} : '' }
ABresult
1X1
011
000
184 is_server => $self->server_name,
185 ($env->{'HTTP_X_FORWARDED_FOR'}
186 ? (api_ip => $env->{'HTTP_X_FORWARDED_FOR'}, is_proxy => $env->{'REMOTE_ADDR'})
187 : (api_ip => $env->{'REMOTE_ADDR'})),
188 api_auth => $ver,
189 api_brand => $brand,
190 api_method => $method,
191 remote_user => delete($args->{'_w'}),
192 remote_ip => delete($args->{'_i'}),
193 0 ▶ token => delete($args->{'_t'}) || do { my $k = $self->config('admin_cookie_key'); $k ? $self->parse_cookies->{$k} : '' },
Branch: 1 branch
BranchTrueFalseTotal
$k ? : 0 0 0
194 caller => delete($args->{'_c'}),
195 dbh_cache => $self->_dbh_cache,
196 0 transport => $self->{'transport'},
197 });
198 0 ▶ $disp->server_init($method, $args, $self) if $disp->can('server_init');
Branch: 1 branch
BranchTrueFalseTotal
if $disp->can("server_init") 0 0 0
199  
200 0 local $0 = "$0 ".$self->server_name." $method - $env->{'REMOTE_ADDR'}";
201 0 ▶ return $disp->run_method($method, $args) if !$disp->can('server_post_request');
Branch: 1 branch
BranchTrueFalseTotal
unless $disp->can("server_post_request") 0 0 0
202  
203 0 my $ref;
204 0 my $ok = eval { $ref = $disp->run_method($method, $args); 1 };
205 0 my $err = $@;
206 0 $disp->server_post_request($method, $args, $ok, $ref, $err);
207 0 ▶ return $ref if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 0 0 0
208 0 die $err;
209 }
210  
211 0 ▶sub _map_request {
Subroutine _map_request: not called CC=6 SCAR=37.4
212 0 my ($self, $args, $env) = @_;
213 0 my $no_brand = $self->_no_brand;
214 my ($meth, $brand) = ((!$no_brand || $no_brand < 0) && $env->{'PATH_INFO'} =~ m|^/+(.+)/([^/]+)$|) ? ($1, $2)
215 : ($env->{'PATH_INFO'} =~ m|^/+(.+)$|) ? ($1, $no_brand ? undef : throw "Failed to find brand with method", {uri => "/$1"})
216 0 ▶ : throw "Failed to find method in URI", {uri => $env->{'PATH_INFO'}};
Branch: 3 branches
BranchTrueFalseTotal
(!$no_brand || $no_brand < 0) && $env->{'PATH_INFO'} =~ m[^/+(.+)/([^/]+)$] ? : 0 0 0
$env->{'PATH_INFO'} =~ m[^/+(.+)$] ? : 0 0 0
$no_brand ? : 0 0 0
Condition0%0/6
!$no_brand || $no_brand < 0 and $env->{"PATH_INFO"} =~ m[^/+(.+)/([^/]+)$]
!ll&&!rl&&r
000
not $no_brand or $no_brand < 0
l!l&&r!l&&!r
000
MC/DC0%0/3
!$no_brand || $no_brand < 0 and $env->{"PATH_INFO"} =~ m[^/+(.+)/([^/]+)$]
not $no_brand $no_brand < 0 $env->{"PATH_INFO"} =~ m[^/+(.+)/([^/]+)$]
Truth table0%0/5
not(A) or B and C
A= not $no_brandB= $no_brand < 0C= $env->{"PATH_INFO"} =~ m[^/+(.+)/([^/]+)$]
ABCresult
00X0
1X00
0100
1X11
0111
217 0 delete @$args{qw(_p _b)}; # legacy brand and password passing
218 0 return ($meth, $brand);
219 }
220  
221 0 ▶sub _dbh_cache { {} } # intentionally not persistent
Subroutine _dbh_cache: not called CC=1 SCAR=6.9
222  
223 0 ▶sub cgi_obj {
Subroutine cgi_obj: not called CC=9 SCAR=45.0
Pod undocumented
224 0 my ($self, $r) = @_;
225 0 ▶ return $self->{'cgi_obj'} ||= do {
Condition0%0/3
$self->{"cgi_obj"} ||= do { eval { do { CGI::initialize_globals() } } or warn "Failed to initialize globals: $@" if $INC{"CGI.pm"}; eval { do { $self->{"is_psgi"} ? require CGI::PSGI : require CGI } } or throw("Cannot load CGI library during a non-JSON request", {"msg", $@, "type", $ENV{"CONTENT_TYPE"}}); local $CGI::POST_MAX = $self->max_request_size; my $q = $self->{"is_psgi"} ? "CGI::PSGI"->new($self->{"is_psgi"}) : "CGI"->new($r || $self->{"apache_req"} || ()) }
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"cgi_obj"} ||= do { eval { do { CGI::initialize_globals() } } or warn "Failed to initialize globals: $@" if $INC{"CGI.pm"}; eval { do { $self->{"is_psgi"} ? require CGI::PSGI : require CGI } } or throw("Cannot load CGI library during a non-JSON request", {"msg", $@, "type", $ENV{"CONTENT_TYPE"}}); local $CGI::POST_MAX = $self->max_request_size; my $q = $self->{"is_psgi"} ? "CGI::PSGI"->new($self->{"is_psgi"}) : "CGI"->new($r || $self->{"apache_req"} || ()) }
$self->{"cgi_obj"} do { eval { do { CGI::initialize_globals() } } or warn "Failed to initialize globals: $@" if $INC{"CGI.pm"}; eval { do { $self->{"is_psgi"} ? require CGI::PSGI : require CGI } } or throw("Cannot load CGI library during a non-JSON request", {"msg", $@, "type", $ENV{"CONTENT_TYPE"}}); local $CGI::POST_MAX = $self->max_request_size; my $q = $self->{"is_psgi"} ? "CGI::PSGI"->new($self->{"is_psgi"}) : "CGI"->new($r || $self->{"apache_req"} || ()) }
Truth table0%0/3
A ||= B
A= $self->{"cgi_obj"}B= do { eval { do { CGI::initialize_globals() } } or warn "Failed to initialize globals: $@" if $INC{"CGI.pm"}; eval { do { $self->{"is_psgi"} ? require CGI::PSGI : require CGI } } or throw("Cannot load CGI library during a non-JSON request", {"msg", $@, "type", $ENV{"CONTENT_TYPE"}}); local $CGI::POST_MAX = $self->max_request_size; my $q = $self->{"is_psgi"} ? "CGI::PSGI"->new($self->{"is_psgi"}) : "CGI"->new($r || $self->{"apache_req"} || ()) }
ABresult
1X1
011
000
226 0 ▶ eval { CGI::initialize_globals() } or warn "Failed to initialize globals: $@" if $INC{'CGI.pm'}; # CGI.pm caches query parameters
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"CGI.pm"} 0 0 0
Condition0%0/5
$INC{'CGI.pm'} && (eval { do { CGI::initialize_globals() } } || warn("Failed to initialize globals: $@"))
!ll&&!rl&&r
000
eval { do { CGI::initialize_globals() } } or warn "Failed to initialize globals: $@"
l!l
00
MC/DC0%0/2
$INC{'CGI.pm'} && (eval { do { CGI::initialize_globals() } } || warn("Failed to initialize globals: $@"))
$INC{'CGI.pm'} eval { do { CGI::initialize_globals() } }
Truth table0%0/3
A && B
A= $INC{'CGI.pm'}B= eval { do { CGI::initialize_globals() } }
ABresult
0X0
100
111
227 0 ▶ eval { $self->{'is_psgi'} ? require CGI::PSGI : require CGI } || throw 'Cannot load CGI library during a non-JSON request', {msg => $@, type => $ENV{'CONTENT_TYPE'}};
Branch: 2 branches
BranchTrueFalseTotal
eval { do { $self->{"is_psgi"} ? require CGI::PSGI : require CGI } } or throw("Cannot load CGI library during a non-JSON request", {"msg", $@, "type", $ENV{"CONTENT_TYPE"}}) 0 0 0
$self->{'is_psgi'} ? : 0 0 0
228 0 local $CGI::POST_MAX = $self->max_request_size;
229 0 ▶ my $q = $self->{'is_psgi'} ? CGI::PSGI->new($self->{'is_psgi'}) : CGI->new($r || $self->{'apache_req'} || ());
Branch: 1 branch
BranchTrueFalseTotal
$self->{'is_psgi'} ? : 0 0 0
Condition0%0/6
$r || $self->{'apache_req'} || ()
l!l&&r!l&&!r
000
$r or $self->{"apache_req"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$r || $self->{'apache_req'} || ()
$r $self->{"apache_req"} ()
Truth table0%0/4
A or B || C
A= $rB= $self->{"apache_req"}C= ()
ABCresult
1XX1
01X1
0011
0000
230 };
231 }
232  
233 0 ▶sub parse_form {
Subroutine parse_form: not called CC=2 SCAR=17.9
Pod undocumented
234 0 my ($self, $r) = @_;
235 0 my $q = $self->cgi_obj($r);
236 0 ▶ return {map {my @v = $q->param($_); $_ => (@v <= 1 ? $v[0] : \@v)} $q->param};
Branch: 1 branch
BranchTrueFalseTotal
@v <= 1 ? : 0 0 0
237 }
238  
239 0 ▶sub parse_cookies {
Subroutine parse_cookies: not called CC=4 SCAR=30.0
Pod undocumented
240 0 my ($self, $r) = @_;
241 0 ▶ my $env = $self->{'is_psgi'} || \%ENV;
Condition0%0/2
$self->{'is_psgi'} || \%ENV
l!l
00
MC/DC0%0/1
$self->{'is_psgi'} || \%ENV
$self->{'is_psgi'}
Truth table0%0/2
A
A= $self->{'is_psgi'}
Aresult
11
00
242 0 ▶ return {} if !$env->{'HTTP_COOKIE'};
Branch: 1 branch
BranchTrueFalseTotal
unless $env->{"HTTP_COOKIE"} 0 0 0
243 0 my $q = $self->cgi_obj($r);
244 0 ▶ return {map {my @v = $q->cookie($_); $_ => (@v <= 1 ? $v[0] : \@v)} $q->cookie};
Branch: 1 branch
BranchTrueFalseTotal
@v <= 1 ? : 0 0 0
245 }
246  
247 0 ▶sub content_type { shift->{'content_type'} ||= 'application/json' }
Subroutine content_type: not called CC=2 SCAR=17.9
Pod undocumented
Condition0%0/2
+(shift())->{"content_type"} ||= "application/json"
l!l
00
MC/DC0%0/1
+(shift())->{"content_type"} ||= "application/json"
+(shift())->{"content_type"}
Truth table0%0/2
A
A= +(shift())->{"content_type"}
Aresult
11
00
248  
249 0 ▶sub send_response {
Subroutine send_response: not called CC=13 SCAR=52.0
Pod undocumented
250 0 my ($self, $str) = @_;
251 0 ▶ $str =~ s/\s*$/\r\n/ if $self->content_type =~ m{^(?:text/|application/json$)};
Branch: 1 branch
BranchTrueFalseTotal
if $self->content_type =~ m[^(?:text/|application/json$)] 0 0 0
252 0 ▶ my @extra = $self->{'extra_headers'} ? @{ $self->{'extra_headers'} } : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->{'extra_headers'} ? : 0 0 0
253 0 ▶ if ($self->{'is_psgi'}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'is_psgi'}) { } 0 0 0
elsif (my $r = $self->{'apache_req'} || eval { do { $ENV{'MOD_PERL'} and 'Apache2::RequestUtil'->request } }) { } 0 0 0
elsif (my $c = $self->{'server'}{'client'}) { } 0 0 0
254 0 return [200, [(map {$_->[0], $_->[1]} @extra), 'Content-type' => $self->content_type, 'Content-length' => length($str)], [$str]];
255 0 ▶ } elsif (my $r = $self->{'apache_req'} || eval { $ENV{'MOD_PERL'} && Apache2::RequestUtil->request }) {
Condition0%0/6
$self->{'apache_req'} || eval { do { $ENV{'MOD_PERL'} and 'Apache2::RequestUtil'->request } }
l!l&&r!l&&!r
000
$ENV{'MOD_PERL'} && 'Apache2::RequestUtil'->request
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{'apache_req'} || eval { do { $ENV{'MOD_PERL'} and 'Apache2::RequestUtil'->request } }
$self->{'apache_req'} eval { do { $ENV{'MOD_PERL'} and 'Apache2::RequestUtil'->request } }
MC/DC0%0/2
$ENV{'MOD_PERL'} && 'Apache2::RequestUtil'->request
$ENV{'MOD_PERL'} 'Apache2::RequestUtil'->request
Truth table0%0/3
A || B
A= $self->{'apache_req'}B= eval { do { $ENV{'MOD_PERL'} and 'Apache2::RequestUtil'->request } }
ABresult
1X1
011
000
Truth table0%0/3
A && B
A= $ENV{'MOD_PERL'}B= 'Apache2::RequestUtil'->request
ABresult
0X0
100
111
256 0 $r->headers_out->set($_->[0] => $_->[1]) for @extra;
257 0 $r->headers_out->set('Content-length', length($str));
258 0 $r->content_type($self->content_type);
259 0 $r->print($str);
260 } elsif (my $c = $self->{'server'}->{'client'}) { # accelerate output header generation under Net::Server
261 0 my $ri = $self->{'request_info'};
262 0 my $out = "HTTP/1.0 200 OK\015\012";
263 0 foreach my $row (@{ $self->http_base_headers }, @extra, ['Content-length', length($str)], ['Content-type', $self->content_type]) {
264 0 $out .= "$row->[0]: $row->[1]\015\012";
265 0 push @{ $ri->{'response_headers'} }, $row;
266 }
267 0 $ri->{'response_header_size'} += length $out;
268 0 $ri->{'http_version'} = '1.0';
269 0 $ri->{'response_status'} = 200;
270 0 $ri->{'headers_sent'} = 1;
271 0 $ri->{'response_size'} = length $str;
272 0 $c->print("$out\015\012$str");
273 } else {
274 # Otherwise, this is a normal CGI process.
275 # XXX - Do we need to also convert "Status" header for the special NPH format?
276 0 ▶ print "HTTP/1.0 200 OK\r\n" if ($ENV{SCRIPT_FILENAME} // "") =~ m{/nph-[^/]+($|\s)};
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"SCRIPT_FILENAME"} // "") =~ m[/nph-[^/]+($|\s)] 0 0 0
Condition0%0/2
$ENV{"SCRIPT_FILENAME"} // ""
l!l
00
MC/DC0%0/1
$ENV{"SCRIPT_FILENAME"} // ""
$ENV{"SCRIPT_FILENAME"}
Truth table0%0/2
A
A= $ENV{"SCRIPT_FILENAME"}
Aresult
11
00
277 0 for my $h (@extra) {
278 0 print "$h->[0]: $h->[1]\r\n";
279 }
280 0 print "Content-Type: ".$self->content_type."\r\nContent-Length: ".length($str)."\r\nContent-Type: ".$self->content_type."\r\n\r\n",$str;
281 }
282 0 return 1;
283 }
284  
285 0 ▶sub _no_brand { shift->config(no_brand => undef) }
Subroutine _no_brand: not called CC=1 SCAR=6.9
286  
287 0 ▶sub verify_sig {
Subroutine verify_sig: not called CC=40 SCAR=74.0
Pod undocumented
288 0 my ($self, $args, $req_sum, $env, $meth, $brand) = @_;
289 0 my ($ip, $sig, $script, $path_info, $qs, $auth) = @$env{qw(REMOTE_ADDR HTTP_X_RESPITE_AUTH SCRIPT_NAME PATH_INFO QUERY_STRING HTTP_AUTHORIZATION)};
290 0 ▶ my $uri = $script || throw "Missing script";
Condition0%0/3
$script || throw('Missing script')
l!l&&r!l&&!r
000
MC/DC0%0/2
$script || throw('Missing script')
$script throw('Missing script')
Truth table0%0/3
A || B
A= $scriptB= throw('Missing script')
ABresult
1X1
011
000
291 0 ▶ $uri .= $path_info if $path_info;
Branch: 1 branch
BranchTrueFalseTotal
if $path_info 0 0 0
292 0 ▶ $uri .= "?$qs" if $qs;
Branch: 1 branch
BranchTrueFalseTotal
if $qs 0 0 0
293  
294 0 my ($type, $user, $exception);
295 0 ▶ if ($auth) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auth) { } 0 0 0
296 0 ▶ throw "Cannot pass both Authorization and X-Respite-Auth", {authorization => $auth, x_respite_auth => $sig, uri => $uri, ip => $ip} if $sig;
Branch: 1 branch
BranchTrueFalseTotal
if $sig 0 0 0
297 0 ▶ if ($auth =~ s/^Basic \s+ (\S+)$/$1/x) {
Branch: 3 branches
BranchTrueFalseTotal
if ($auth =~ s/^Basic \s+ (\S+)$/$1/x) { } 0 0 0
elsif ($auth =~ s/^Digest \s+//x) { } 0 0 0
elsif ($auth =~ s/^RespiteAuth \s+//x) { } 0 0 0
298 0 $type = 'basic';
299 0 require MIME::Base64;
300 0 ($user, $sig) = split /:/, MIME::Base64::decode_base64($auth), 2;
301 0 ▶ $exception = Throw->new("Basic authentication not allowed", {user => $user}) if ! $self->allow_auth_basic($brand, $user);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->allow_auth_basic($brand, $user) 0 0 0
302 } elsif ($auth =~ s/^Digest \s+//x) {
303 0 $type = 'digest';
304 0 $sig->{'method'} = $ENV{'REQUEST_METHOD'};
305 0 ▶ $sig->{$1} = (defined($3) && length($3)) ? $3 : $2 while $auth =~ s/^ (\w+) = (?: "([^\"]+)" | ([^\s\",]+)) (?:\s*$|,\s*) //gxs;
Branch: 2 branches
BranchTrueFalseTotal
$auth =~ s/^ (\w+) = (?: "([^\"]+)" | ([^\s\",]+)) (?:\s*$|,\s*) //gsx and do { $sig->{$1} = defined $3 && length $3 ? $3 : $2 } 0 0 0
defined $3 && length $3 ? : 0 0 0
Condition0%0/3
defined $3 and length $3
!ll&&!rl&&r
000
MC/DC0%0/2
defined $3 and length $3
defined $3 length $3
Truth table0%0/3
A and B
A= defined $3B= length $3
ABresult
0X0
100
111
306 0 $user = $sig->{'username'};
307 } elsif ($auth =~ s/^RespiteAuth \s+//x) {
308 0 $type = 'signed';
309 0 $sig = $auth;
310 } else {
311 0 $exception = Throw->new("Unknown auth type", {authorization => $auth, uri => $uri, ip => $ip, authtype => 'unknown'});
312 }
313 } else {
314 0 my $allow_md5 = $self->allow_auth_md5_pass($brand);
315 0 ▶ $sig ||= $args->{'x_respite_auth'} if $allow_md5;
Branch: 1 branch
BranchTrueFalseTotal
if $allow_md5 0 0 0
Condition0%0/3
$sig ||= $args->{"x_respite_auth"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$sig ||= $args->{"x_respite_auth"}
$sig $args->{"x_respite_auth"}
Truth table0%0/3
A ||= B
A= $sigB= $args->{"x_respite_auth"}
ABresult
1X1
011
000
316 0 ▶ $type = !$sig ? 'none' : ($sig !~ /^[a-f0-z]{32}$/) ? 'signed' : $allow_md5 ? 'md5_pass' : throw 'Auth type md5_pass not allowed';
Branch: 3 branches
BranchTrueFalseTotal
!$sig ? : 0 0 0
!($sig =~ /^[a-f0-z]{32}$/) ? : 0 0 0
$allow_md5 ? : 0 0 0
317 }
318 0 ▶ my $pass = $self->get_api_pass($brand || '', $ip, $sig, $type, $user, $exception) || [];
Condition0%0/4
$self->get_api_pass($brand || '', $ip, $sig, $type, $user, $exception) || []
l!l
00
$brand || ''
l!l
00
MC/DC0%0/1
$self->get_api_pass($brand || '', $ip, $sig, $type, $user, $exception) || []
$self->get_api_pass($brand || '', $ip, $sig, $type, $user, $exception)
MC/DC0%0/1
$brand || ''
$brand
Truth table0%0/2
A
A= $self->get_api_pass($brand || '', $ip, $sig, $type, $user, $exception)
Aresult
11
00
Truth table0%0/2
A
A= $brand
Aresult
11
00
319 0 ▶ $pass = ref($pass) ? undef : [$pass] if ref($pass) ne 'ARRAY';
Branch: 2 branches
BranchTrueFalseTotal
if ref $pass ne "ARRAY" 0 0 0
ref $pass ? : 0 0 0
320 0 ▶ return {authorization_not_required => 1, ip => $ip, brand => $brand, authtype => $type, exception => $exception} if $pass && !@$pass;
Branch: 1 branch
BranchTrueFalseTotal
if $pass and not @$pass 0 0 0
Condition0%0/3
$pass and not @$pass
!ll&&!rl&&r
000
MC/DC0%0/2
$pass and not @$pass
$pass not @$pass
Truth table0%0/3
A and not(B)
A= $passB= not @$pass
ABresult
0X0
100
111
321 0 ▶ die $exception if defined $exception;
Branch: 1 branch
BranchTrueFalseTotal
if defined $exception 0 0 0
322 0 ▶ throw "Missing client authorization", {server_name => $self->server_name, ip => $ip, brand => $brand, authtype => $type, uri => $uri} if !$sig && $type && $type ne 'none';
Branch: 1 branch
BranchTrueFalseTotal
if not $sig and $type and $type ne "none" 0 0 0
Condition0%0/6
not $sig and $type and $type ne "none"
!ll&&!rl&&r
000
not $sig and $type
!ll&&!rl&&r
000
MC/DC0%0/3
not $sig and $type and $type ne "none"
not $sig $type $type ne "none"
Truth table0%0/4
not(A) and B and C
A= not $sigB= $typeC= $type ne "none"
ABCresult
0XX0
10X0
1100
1111
323  
324 0 ▶ if ($pass) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pass) 0 0 0
325 0 for my $i (0 .. $#$pass) {
326 next if ($type eq 'basic') ? $pass->[$i] ne $sig
327 : ($type eq 'md5_pass') ? md5_hex($pass->[$i]) ne $sig
328 0 ▶ : ($type eq 'signed') ? do { my ($_sum, $time) = split /:/, $sig, 2; md5_hex("$pass->[$i]:$time:$uri:$req_sum") ne $_sum }
Branch: 2 branches
BranchTrueFalseTotal
$type eq 'digest' ? : 0 0 0
eval { do { $self->verify_digest($sig ||= {}, $pass->[$i], $uri, $req_sum, $meth, $brand, $ip) } } ? : 0 0 0
329 0 ▶ : ($type eq 'digest') ? (eval { $self->verify_digest($sig||={}, $pass->[$i], $uri, $req_sum, $meth, $brand, $ip) } ? 0 : do { $sig->{'verify'} = $@; 1 })
Branch: 4 branches
BranchTrueFalseTotal
if $type eq "basic" ? $pass->[$i] ne $sig : ($type eq "md5_pass" ? md5_hex($pass->[$i]) ne $sig : ($type eq "signed" ? do { () = split(/:/, $sig, 2); md5_hex("$pass->[$i]:${time}:${uri}:$req_sum") ne $_sum } : ($type eq "digest" ? eval { do { $self->verify_digest($sig ||= {}, $pass->[$i], $uri, $req_sum, $meth, $brand, $ip) } } ? 0 : do { $sig->{"verify"} = $@; 1 } : 1))) 0 0 0
$type eq 'basic' ? : 0 0 0
$type eq 'md5_pass' ? : 0 0 0
$type eq 'signed' ? : 0 0 0
Condition0%0/2
$sig ||= {}
l!l
00
MC/DC0%0/1
$sig ||= {}
$sig
Truth table0%0/2
A
A= $sig
Aresult
11
00
330 : 1;
331 0 ▶ return {authtype => $type, ip => $ip, brand => $brand, meth => $meth, i => $i, ($self->{'verify_sig_return_pass'} ? (pass => $pass->[$i]) : ()), ($type eq 'digest'?(digest=>$sig):())};
Branch: 2 branches
BranchTrueFalseTotal
$self->{'verify_sig_return_pass'} ? : 0 0 0
$type eq 'digest' ? : 0 0 0
332 }
333 }
334 0 ▶ throw "Invalid client authorization", {($type eq 'digest'?(digest=>$sig):()), server_name => $self->server_name, ip => $ip, brand => $brand, authtype => $type, uri => $uri};
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'digest' ? : 0 0 0
335 }
336  
337 my %cidr;
338 0 ▶sub get_api_pass {
Subroutine get_api_pass: not called CC=25 SCAR=64.8
Pod undocumented
339 0 my ($self, $brand, $ip, $sig, $type, $user, $except) = @_;
340 0 my $ref = $self->config(pass => undef);
341 0 ▶ return $ref if ! ref($ref) || ref($ref) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if not ref $ref or ref $ref eq "ARRAY" 0 0 0
Condition0%0/3
not ref $ref or ref $ref eq "ARRAY"
l!l&&r!l&&!r
000
MC/DC0%0/2
not ref $ref or ref $ref eq "ARRAY"
not ref $ref ref $ref eq "ARRAY"
Truth table0%0/3
not(A) or B
A= not ref $refB= ref $ref eq "ARRAY"
ABresult
1X1
011
000
342 0 ▶ if (exists $ref->{$ip}) {
Branch: 3 branches
BranchTrueFalseTotal
if (exists $ref->{$ip}) { } 0 0 0
elsif (exists $ref->{$brand}) { } 0 0 0
elsif (my $c = $ref->{'~cidr~'} || $ref->{'-cidr'}) { } 0 0 0
343 0 ▶ return $ref->{$ip} if ref($ref->{$ip}) ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $ref->{$ip} ne "HASH" 0 0 0
344 0 ▶ return $ref->{$ip}->{$brand} if exists $ref->{$ip}->{$brand};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{$ip}{$brand} 0 0 0
345 0 ▶ return $ref->{$ip}->{'~default~'} if exists $ref->{$ip}->{'~default~'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{$ip}{"~default~"} 0 0 0
346 0 ▶ return $ref->{$ip}->{'-default'} if exists $ref->{$ip}->{'-default'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{$ip}{"-default"} 0 0 0
347 } elsif (exists $ref->{$brand}) {
348 0 ▶ return $ref->{$brand} if ref($ref->{$brand}) ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $ref->{$brand} ne "HASH" 0 0 0
349 0 ▶ return $ref->{$brand}->{$ip} if exists $ref->{$brand}->{$ip};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{$brand}{$ip} 0 0 0
350 0 ▶ return $ref->{$brand}->{'~default~'} if exists $ref->{$brand}->{'~default~'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{$brand}{"~default~"} 0 0 0
351 0 ▶ return $ref->{$brand}->{'-default'} if exists $ref->{$brand}->{'-default'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{$brand}{"-default"} 0 0 0
352 ▶ } elsif (my $c = $ref->{'~cidr~'} || $ref->{'-cidr'}) {
Condition0%0/3
$ref->{'~cidr~'} || $ref->{'-cidr'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ref->{'~cidr~'} || $ref->{'-cidr'}
$ref->{'~cidr~'} $ref->{'-cidr'}
Truth table0%0/3
A || B
A= $ref->{'~cidr~'}B= $ref->{'-cidr'}
ABresult
1X1
011
000
353 0 my $n = _aton($ip);
354 0 foreach my $cidr (keys %$c) {
355 0 ▶ my $range = $cidr{$cidr} ||= _cidr($cidr);
Condition0%0/3
$cidr{$cidr} ||= _cidr($cidr)
l!l&&r!l&&!r
000
MC/DC0%0/2
$cidr{$cidr} ||= _cidr($cidr)
$cidr{$cidr} _cidr($cidr)
Truth table0%0/3
A ||= B
A= $cidr{$cidr}B= _cidr($cidr)
ABresult
1X1
011
000
356 0 ▶ next if $n < $range->[0] || $n > $range->[1];
Branch: 1 branch
BranchTrueFalseTotal
if $n < $range->[0] or $n > $range->[1] 0 0 0
Condition0%0/3
$n < $range->[0] or $n > $range->[1]
l!l&&r!l&&!r
000
MC/DC0%0/2
$n < $range->[0] or $n > $range->[1]
$n < $range->[0] $n > $range->[1]
Truth table0%0/3
A or B
A= $n < $range->[0]B= $n > $range->[1]
ABresult
1X1
011
000
357 0 my $ref = $c->{$cidr};
358 0 ▶ if (ref($ref) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref eq "HASH") 0 0 0
359 0 ▶ return $ref->{$brand} if exists $ref->{$brand};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{$brand} 0 0 0
360 0 ▶ return $ref->{'~default~'} if exists $ref->{'~default~'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{"~default~"} 0 0 0
361 0 ▶ return $ref->{'-default'} if exists $ref->{'-default'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{"-default"} 0 0 0
362 }
363 0 return $ref;
364 }
365 }
366  
367 0 ▶ return $ref->{'~default~'} if exists $ref->{'~default~'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{"~default~"} 0 0 0
368 0 ▶ return $ref->{'-default'} if exists $ref->{'-default'};
Branch: 1 branch
BranchTrueFalseTotal
if exists $ref->{"-default"} 0 0 0
369 0 throw "Not authorized - Could not find brand/ip match in pass configuration", {brand => $brand, ip => $ip, service => $self->server_name};
370 }
371 0 ▶sub _aton { my $ip = shift; return unpack "N", pack "C4", split /\./, $ip }
Subroutine _aton: not called CC=1 SCAR=6.9
372 0 ▶sub _cidr { (my $c = shift) =~ s/\s+//; my ($ip, $base) = split /\//, $c; my $i = _aton($ip); $i &= 2**32 - 2**(32-$base) if !$_[0]; return [$i, $i+2**(32-$base)-1] }
Subroutine _cidr: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] 0 0 0
373  
374 0 ▶sub allow_auth_md5_pass { shift->config(allow_auth_md5_pass => undef) }
Subroutine allow_auth_md5_pass: not called CC=1 SCAR=6.9
Pod undocumented
375 0 ▶sub allow_auth_basic { shift->config(allow_auth_basic => undef) }
Subroutine allow_auth_basic: not called CC=1 SCAR=6.9
Pod undocumented
376 0 ▶sub allow_auth_qop_auth { shift->config(allow_auth_qop_auth => undef) }
Subroutine allow_auth_qop_auth: not called CC=1 SCAR=6.9
Pod undocumented
377 0 ▶sub digest_realm { shift->config(realm => sub { my $name = shift->server_name; return $name =~ /^(\w+)_server/ ? $1 : $name }) }
Subroutine __ANON__: not called CC=2 SCAR=17.9
Subroutine digest_realm: not called CC=1 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /^(\w+)_server/ ? : 0 0 0
378  
379 0 ▶sub verify_digest {
Subroutine verify_digest: not called CC=10 SCAR=47.0
Pod undocumented
380 0 my ($self, $digest, $pass, $uri, $req_sum, $meth, $brand, $ip) = @_;
381 0 ▶ my $d = sub { my ($key, $opt) = @_; my $val = $digest->{$key}; $opt ? ($val='') : throw "Digest directive $key was missing" if !defined($val) || !length($val); $val };
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 2 branches
BranchTrueFalseTotal
unless defined $val and length $val 0 0 0
$opt ? : 0 0 0
Condition0%0/3
defined $val and length $val
!ll&&!rl&&r
000
MC/DC0%0/2
defined $val and length $val
defined $val length $val
Truth table0%0/3
A and B
A= defined $valB= length $val
ABresult
0X0
100
111
382 0 ▶ throw "Missing or invalid digest username" if $brand && $d->('username') ne $brand;
Branch: 1 branch
BranchTrueFalseTotal
if $brand and &$d("username") ne $brand 0 0 0
Condition0%0/3
$brand and &$d("username") ne $brand
!ll&&!rl&&r
000
MC/DC0%0/2
$brand and &$d("username") ne $brand
$brand &$d("username") ne $brand
Truth table0%0/3
A and B
A= $brandB= &$d("username") ne $brand
ABresult
0X0
100
111
383 0 ▶ throw "Missing or invalid digest realm", {realm => $self->digest_realm} if $d->('realm') ne $self->digest_realm;
Branch: 1 branch
BranchTrueFalseTotal
if &$d("realm") ne $self->digest_realm 0 0 0
384 0 ▶ throw "Digest URI did not match", {digest => $d->('uri'), actual => $uri} if $uri ne $d->('uri');
Branch: 1 branch
BranchTrueFalseTotal
if $uri ne &$d("uri") 0 0 0
385 0 my $ha1 = md5_hex($d->('username') .':'. $d->('realm').":$pass");
386 0 ▶ $ha1 = md5_hex("$ha1:".$d->('nonce').':'.$d->('cnonce')) if lc($d->('algorithm',1)) eq 'md5-sess';
Branch: 1 branch
BranchTrueFalseTotal
if lc &$d("algorithm", 1) eq "md5-sess" 0 0 0
387 0 ▶ my $ha2 = md5_hex($d->('method').":$uri".(($d->('qop',1) eq 'auth-int') ? ":$req_sum" : $self->allow_auth_qop_auth($brand) ? '' : throw 'Digest qop auth not allowed'));
Branch: 2 branches
BranchTrueFalseTotal
&$d('qop', 1) eq 'auth-int' ? : 0 0 0
$self->allow_auth_qop_auth($brand) ? : 0 0 0
388 0 ▶ my $sum = md5_hex("$ha1:".$d->('nonce').($d->('qop',1) ? ':'.$d->('nc').':'.$d->('cnonce').':'.$d->('qop') : '').":$ha2");
Branch: 1 branch
BranchTrueFalseTotal
&$d('qop', 1) ? : 0 0 0
389 0 ▶ throw 'Digest did not validate' if $sum ne $d->('response');
Branch: 1 branch
BranchTrueFalseTotal
if $sum ne &$d("response") 0 0 0
390 0 return 1;
391 }
392  
393 ###----------------------------------------------------------------###
394 # Net::Server::HTTP bits
395  
396 5 ▶sub server_args {
Subroutine server_args: called CC=21 SCAR=41.3
Pod undocumented
397 5 my $self = shift;
398 5 my $name = $self->server_name;
399 5 ▶ my $val = sub { my ($key, $def) = @_; $self->config($key, $def, $name) };
Subroutine __ANON__: called CC=1 SCAR=0.0
400 5 ▶ my $path = $val->(path => ($name =~ /^(\w+)_server/ ? $1 : $name));
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /^(\w+)_server/ ? : 0 5 5
401 5 my $host = $val->(host => '*');
402 5 my $port = $val->(port => 443);
403 5 my $ssl = !$val->(no_ssl => undef);
404 5 ▶ my $ad = $val->(auto_doc => ''); $ad = ($name =~ /^(\w+)_server/ ? $1 : $name).'_doc' if $ad && $ad eq '1';
Branch: 2 branches
BranchTrueFalseTotal
if $ad and $ad eq 1 0 5 5
$name =~ /^(\w+)_server/ ? : 0 0 0
Condition33%1/3
$ad and $ad eq 1
!ll&&!rl&&r
500
MC/DC0%0/2
$ad and $ad eq 1
$ad $ad eq 1
Truth table33%1/3
A and B
A= $adB= $ad eq 1
ABresult
0X0
100
111
405 5 ▶ my $is_dev = eval { defined(&config::is_dev) && config::is_dev() };
Condition33%1/3
defined &config::is_dev && config::is_dev()
!ll&&!rl&&r
500
MC/DC0%0/2
defined &config::is_dev && config::is_dev()
defined &config::is_dev config::is_dev()
Truth table33%1/3
A && B
A= defined &config::is_devB= config::is_dev()
ABresult
0X0
100
111
406 5 ▶ my $use_dev_port = $is_dev && $ssl && !$val->(no_dev_port => '');
Condition33%2/6
$is_dev && $ssl && !&$val('no_dev_port', '')
!ll&&!rl&&r
500
$is_dev and $ssl
!ll&&!rl&&r
500
MC/DC0%0/3
$is_dev && $ssl && !&$val('no_dev_port', '')
$is_dev $ssl !&$val('no_dev_port', '')
Truth table25%1/4
A and B && not(C)
A= $is_devB= $sslC= !&$val('no_dev_port', '')
ABCresult
0XX0
10X0
1100
1111
407 5 my $res = $val->(cgi_bin => undef);
408 5 ▶ my $app = !$res ? \&cgihandler : ($res ne 1) ? $res : 'cgi-bin/'.($name =~ /^(\w+)_server/ ? $1 : $name);
Branch: 3 branches
BranchTrueFalseTotal
!$res ? : 5 0 5
$res ne 1 ? : 0 0 0
$name =~ /^(\w+)_server/ ? : 0 0 0
409 5 ▶ $app = $self->rootdir_server ."/$app" if !ref($app) && $app !~ /^\//;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $app or $app =~ m[^/] 0 5 5
Condition33%1/3
ref $app or $app =~ m[^/]
l!l&&r!l&&!r
500
MC/DC0%0/2
ref $app or $app =~ m[^/]
ref $app $app =~ m[^/]
Truth table33%1/3
A or B
A= ref $appB= $app =~ m[^/]
ABresult
1X1
011
000
410 5 my $st = $val->(server_type => 'PreFork');
411 return {
412 server_type => ref($st) ? $st : [$st],
413 enable_dispatch => 1,
414 ipv => 4,
415 5 ▶ app => [[(map{$_ => $app} ref($path) ? @$path : $path),
Branch: 7 branches
BranchTrueFalseTotal
ref $st ? : 0 5 5
ref $path ? : 0 5 5
$ad ? : 0 5 5
$ssl ? : 0 5 5
$use_dev_port ? : 0 5 5
$port == 443 ? : 0 0 0
$is_dev && $ssl ? : 0 5 5
Condition33%1/3
$is_dev and $ssl
!ll&&!rl&&r
500
MC/DC0%0/2
$is_dev and $ssl
$is_dev $ssl
Truth table33%1/3
A and B
A= $is_devB= $ssl
ABresult
0X0
100
111
416 ($ad ? ($ad => \&cgidoc) : ()),
417 '' => \&http_not_found]],
418 port => [
419 {port => $port, host => $host, ($ssl ? (proto => 'SSL') : ())},
420 ($use_dev_port ? {port => ($port == 443 ? 80 : $port-1), host => $host} : ()), # allow for dev to telnet to a non-ssl
421 ],
422 serialize => ($is_dev && $ssl) ? 'flock' : 'none', # can only do if hard coded to ipv4 and host resolves to one ip
423 access_log_file => $val->(access_log_file => "/var/log/${name}/${name}.access_log"),
424 log_file => $val->(log_file => "/var/log/${name}/${name}.error_log"),
425 pid_file => $val->(pid_file => "/var/run/${name}.pid"),
426 user => $val->(user => 'readonly'),
427 group => $val->(group => 'cvs'),
428 };
429 }
430  
431 0 ▶sub rootdir_server { shift->config(rootdir_server => $config::config{'rootdir_server'} || sub { require FindBin; $FindBin::RealBin }) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine rootdir_server: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/3
$config::config{'rootdir_server'} || sub { require FindBin; $FindBin::RealBin; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$config::config{'rootdir_server'} || sub { require FindBin; $FindBin::RealBin; }
$config::config{'rootdir_server'} sub { require FindBin; $FindBin::RealBin; }
Truth table0%0/3
A || B
A= $config::config{'rootdir_server'}B= sub { require FindBin; $FindBin::RealBin; }
ABresult
1X1
011
000
432 0 ▶sub SSL_base_domain { 'example.com' }
Subroutine SSL_base_domain: not called CC=1 SCAR=6.9
Pod undocumented
433 0 ▶sub SSL_cert_file { shift->config(ssl_cert => sub { shift->rootdir_server .shift->SSL_base_domain().'.crt' }) }
Subroutine SSL_cert_file: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
Pod undocumented
434 0 ▶sub SSL_key_file { shift->config(ssl_key => sub { shift->rootdir_server .shift->SSL_base_domain().'.key' }) }
Subroutine SSL_key_file: not called CC=1 SCAR=6.9
Subroutine __ANON__: not called CC=1 SCAR=6.9
Pod undocumented
435  
436 2 ▶sub post_bind {
Subroutine post_bind: called CC=1 SCAR=0.0
Pod documented
437 2 my $self = shift;
438 2 $0 = $self->server_name;
439 2 $self->SUPER::post_bind(@_);
440 }
441  
442 0 ▶sub child_init_hook { $0 = shift->server_name ." - waiting" } # prefork server
Subroutine child_init_hook: not called CC=1 SCAR=6.9
Pod documented
443  
444 0 ▶sub run_client_connection {
Subroutine run_client_connection: not called CC=3 SCAR=24.8
Pod documented
445 0 my $self = shift;
446 0 $0 = $self->server_name . " - connected";
447 0 $self->SUPER::run_client_connection(@_);
448 0 ▶ $_->($self) for @{ $self->{'post_client_callbacks'} || [] };
Condition0%0/2
$self->{'post_client_callbacks'} || []
l!l
00
MC/DC0%0/1
$self->{'post_client_callbacks'} || []
$self->{'post_client_callbacks'}
Truth table0%0/2
A
A= $self->{'post_client_callbacks'}
Aresult
11
00
449 }
450  
451 0 ▶sub server_revision {
Subroutine server_revision: not called CC=3 SCAR=24.8
Pod documented
452 0 my $self = shift;
453 0 ▶ return $self->{'server_revision'} ||= $self->server_name.'/'.$self->revision.($self->{'nshv'} ? ' '.$self->SUPER::server_revision : '');
Branch: 1 branch
BranchTrueFalseTotal
$self->{'nshv'} ? : 0 0 0
Condition0%0/2
$self->{"server_revision"} ||= $self->server_name . '/' . $self->revision . ($self->{"nshv"} ? ' ' . $self->SUPER::server_revision : "")
l!l
00
MC/DC0%0/1
$self->{"server_revision"} ||= $self->server_name . '/' . $self->revision . ($self->{"nshv"} ? ' ' . $self->SUPER::server_revision : "")
$self->{"server_revision"}
Truth table0%0/2
A
A= $self->{"server_revision"}
Aresult
11
00
454 }
455  
456 0 ▶sub http_not_found { shift->send_status(404, "Not found", "<h1>Not Found</h1>") }
Subroutine http_not_found: not called CC=1 SCAR=6.9
Pod undocumented
457  
458 0 ▶sub post_process_request_hook { $0 = shift->server_name ." - post_request" }
Subroutine post_process_request_hook: not called CC=1 SCAR=6.9
Pod documented
459  
460 8 ▶sub default_values { {background => 1, setsid => 1} }
Subroutine default_values: called CC=1 SCAR=0.0
Pod documented
461  
462 ###----------------------------------------------------------------###
463 # Net::Server::HTTP daemonization bits
464  
465 2 ▶sub run_server { shift->SUPER::run(@_) }
Subroutine run_server: called CC=1 SCAR=0.0
Pod undocumented
466  
467 0 ▶sub run { throw "Use either run_server or run_commandline for clarity" }
Subroutine run: not called CC=1 SCAR=6.9
Pod documented
468  
469 0 ▶sub run_commandline {
Subroutine run_commandline: not called CC=13 SCAR=52.0
Pod undocumented
470 0 my $class = shift;
471 0 ▶ my $sub = $ARGV[0] && $class->can("__$ARGV[0]") ? "__$ARGV[0]" : undef;
Branch: 1 branch
BranchTrueFalseTotal
$ARGV[0] && $class->can("__$ARGV[0]") ? : 0 0 0
Condition0%0/3
$ARGV[0] and $class->can("__$ARGV[0]")
!ll&&!rl&&r
000
MC/DC0%0/2
$ARGV[0] and $class->can("__$ARGV[0]")
$ARGV[0] $class->can("__$ARGV[0]")
Truth table0%0/3
A and B
A= $ARGV[0]B= $class->can("__$ARGV[0]")
ABresult
0X0
100
111
472 0 ▶ shift(@ARGV) if $sub;
Branch: 1 branch
BranchTrueFalseTotal
if $sub 0 0 0
473  
474 0 ▶ if ($ENV{'BOUND_SOCKETS'}) { # HUP
Branch: 4 branches
BranchTrueFalseTotal
if ($ENV{'BOUND_SOCKETS'}) { } 0 0 0
elsif ($sub) { } 0 0 0
elsif ($ENV{'PLACK_ENV'}) { } 0 0 0
elsif (not @ARGV) { } 0 0 0
475 0 ▶ my $self = ref($class) ? $class : $class->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $class ? : 0 0 0
476 0 $self->run_server; # will exit
477 0 warn "Failed to re-initialize server during HUP\n";
478 0 exit 1;
479 } elsif ($sub) { # commandline server service
480 0 ▶ local $ENV{'NO_PRELOAD'} = 1 if $sub !~ /^__(?:start|restart|reload)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $sub =~ /^__(?:start|restart|reload)$/ 0 0 0
481 0 ▶ my $self = ref($class) ? $class : $class->new(@_);
Branch: 1 branch
BranchTrueFalseTotal
ref $class ? : 0 0 0
482 0 $self->$sub();
483 } elsif ($ENV{'PLACK_ENV'}) {
484 0 return $class->psgi_app(@_);
485 } elsif (!@ARGV) {
486 0 throw "$0 help|start|restart|reload|stop|status|tail_error|tail_access|ps|(or any Respite commands)";
487 } else {
488 0 ▶ my $args = ref($_[0]) ? shift : {@_};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
489 0 ▶ my $self = ref($class) ? $class : $class->new({%$args, non_daemon => 1});
Branch: 1 branch
BranchTrueFalseTotal
ref $class ? : 0 0 0
490 0 require Net::Respite::CommandLine;
491 0 Net::Respite::CommandLine->run({dispatch_factory => $self->dispatch_factory});
492 }
493  
494 0 exit 0;
495 }
496  
497 0 ▶sub psgi_app {
Subroutine psgi_app: not called CC=1 SCAR=6.9
Pod undocumented
498 0 my ($class, $args) = @_;
499 0 require IO::Socket; require Net::Server; require Net::Server::PreFork;
500 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
501 0 local *ENV = my $env = shift;
502 0 ▶ return $class->cgihandler({%{$args||{}}, non_daemon => 1, is_psgi => $env});
Condition0%0/2
$args || {}
l!l
00
MC/DC0%0/1
$args || {}
$args
Truth table0%0/2
A
A= $args
Aresult
11
00
503 0 };
504 }
505  
506 3 ▶sub _get_pid { # taken from Net::Server::Daemonize::check_pid_file - but modified
Subroutine _get_pid: called CC=5 SCAR=16.8
507 3 my $self = shift;
508 3 my $pid_file = $self->{'server'}->{'pid_file'};
509 3 ▶ return if ! -e $pid_file; # no pid_file = return success
Branch: 1 branch
BranchTrueFalseTotal
unless -e $pid_file 0 3 3
510 3 ▶ return if -z $pid_file; # empty pid_file = return success
Branch: 1 branch
BranchTrueFalseTotal
if -z $pid_file 0 3 3
511 3 ▶ open my $fh, '<', $pid_file or throw "Could not open existing pid_file", {file => $pid_file, msg => $!};
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $pid_file or throw("Could not open existing pid_file", {"file", $pid_file, "msg", $!}) 3 0 3
512 3 my $line = <$fh>;
513 3 close $fh;
514 3 ▶ return ($line =~ /^(\d{1,10})$/) ? $1 : throw "Could not find pid in existing pid_file", {line => $line};
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /^(\d{1,10})$/ ? : 3 0 3
515 }
516  
517 3 ▶sub _ok {
Subroutine _ok: called CC=2 SCAR=7.2
518 3 my ($ok, $msg) = @_;
519 3 ▶ warn "$msg\e[60G[". ($ok ? "\e[1;32m OK " : "\e[1;31mFAILED") ."\e[0;39m]\n";
Branch: 1 branch
BranchTrueFalseTotal
$ok ? : 3 0 3
520 }
521  
522 0 ▶sub __status {
Subroutine __status: not called CC=3 SCAR=24.8
523 0 my $self = shift;
524 0 my $pid = $self->_get_pid;
525 0 ▶ return _ok(0, "Process is not running - no pid") if ! $pid;
Branch: 1 branch
BranchTrueFalseTotal
unless $pid 0 0 0
526 0 ▶ return _ok(1, "Process appears to be running under pid $pid") if kill 0, $pid;
Branch: 1 branch
BranchTrueFalseTotal
if kill 0, $pid 0 0 0
527 0 return _ok(0, "Process does not appear to be running - last pid: $pid");
528 }
529  
530 0 ▶sub __start {
Subroutine __start: not called CC=8 SCAR=42.8
531 0 my $self = shift;
532 0 my $pid = $self->_get_pid;
533 0 ▶ if ($pid && kill(0, $pid)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid and kill 0, $pid) 0 0 0
Condition0%0/3
$pid and kill 0, $pid
!ll&&!rl&&r
000
MC/DC0%0/2
$pid and kill 0, $pid
$pid kill 0, $pid
Truth table0%0/3
A and B
A= $pidB= kill 0, $pid
ABresult
0X0
100
111
534 0 _ok(0, "Starting - pid already exists");
535 0 throw "Process appears to already be running under pid $pid ... aborting";
536 }
537  
538 0 my $pid_file = $self->{'server'}->{'pid_file'};
539 0 ▶ if (-e $pid_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $pid_file) 0 0 0
540 0 ▶ unlink $pid_file or throw "Failed to unlink pid file", {file => $pid_file, msg => $!};
Branch: 1 branch
BranchTrueFalseTotal
unlink $pid_file or throw("Failed to unlink pid file", {"file", $pid_file, "msg", $!}) 0 0 0
541 }
542  
543 0 require Net::Server::Daemonize;
544 0 ▶ if (! Net::Server::Daemonize::safe_fork()) {
Branch: 1 branch
BranchTrueFalseTotal
unless (Net::Server::Daemonize::safe_fork()) 0 0 0
545 # child
546 0 $self->run_server(); # will exit
547 0 _ok(0, "Server run failed - check log");
548 0 exit 1;
549 }
550  
551 0 sleep 1;
552 0 $pid = $self->_get_pid;
553 0 ▶ if (!$pid || ! kill 0, $pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid and kill 0, $pid) 0 0 0
Condition0%0/3
$pid and kill 0, $pid
!ll&&!rl&&r
000
MC/DC0%0/2
$pid and kill 0, $pid
$pid kill 0, $pid
Truth table0%0/3
A and B
A= $pidB= kill 0, $pid
ABresult
0X0
100
111
554 0 _ok(0, "Starting - new pid not started - check log for details");
555 0 warn "Log file: $self->{'server'}->{'log_file'}\n";
556 0 exit 1;
557 }
558  
559 # could attempt connection to test for open success
560  
561 0 _ok(1, "Started server");
562  
563 }
564  
565 3 ▶sub __stop {
Subroutine __stop: called CC=8 SCAR=24.9
566 3 my $self = shift;
567 3 my $pid = $self->_get_pid;
568 3 my $name = $self->server_name;
569 3 ▶ if (!$pid) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $pid) { } 0 3 3
elsif (not kill(0, $pid)) { } 0 3 3
570 0 return _ok(1, "Already Stopped $name");
571 } elsif (! kill 0, $pid) {
572 0 warn "Cannot kill 0 $pid while stopping: $!\n";
573 0 return _ok(0, "Failed to stop $name");
574 }
575 3 ▶ if (! (kill(15, $pid) || kill(9, $pid))) {
Branch: 1 branch
BranchTrueFalseTotal
unless (kill 15, $pid or kill 9, $pid) 0 3 3
Condition33%1/3
kill 15, $pid or kill 9, $pid
l!l&&r!l&&!r
300
MC/DC0%0/2
kill 15, $pid or kill 9, $pid
kill 15, $pid kill 9, $pid
Truth table33%1/3
A or B
A= kill 15, $pidB= kill 9, $pid
ABresult
1X1
011
000
576 0 warn "Failed to kill TERM or KILL pid $pid while stopping\n";
577 0 return _ok(0, "Failed to stop $name");
578 }
579 3 for (1 .. 25) {
580 22 ▶ return _ok(1, "Stopped $name") if !kill 0, $pid;
Branch: 1 branch
BranchTrueFalseTotal
unless kill 0, $pid 3 19 22
581 19 sleep 0.2;
582 19 require POSIX;
583 19 ▶ 1 while waitpid(-1, POSIX::WNOHANG()) > 0; # handle rare non-setsid uses of run and _stop
Branch: 1 branch
BranchTrueFalseTotal
waitpid(-1, 1) > 0 and do { '???' } 3 19 22
584 }
585  
586 0 _ok(0, "Stopping - pid still running");
587 0 exit 1;
588 }
589  
590 0 ▶sub __restart {
Subroutine __restart: not called CC=1 SCAR=6.9
591 0 my $self = shift;
592 0 $self->__stop;
593 0 $self->__start;
594 }
595  
596 0 ▶sub __reload {
Subroutine __reload: not called CC=5 SCAR=34.0
597 0 my $self = shift;
598 0 my $pid = $self->_get_pid;
599 0 ▶ if (!$pid) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $pid) { } 0 0 0
elsif (not kill(0, $pid)) { } 0 0 0
600 0 _ok(1, "Process appears to be stopped already - attempting start");
601 0 return $self->__start;
602 } elsif (! kill 0, $pid) {
603 0 _ok(1, "Process appears to be stopped (kill 0) - attempting start");
604 0 return $self->__start;
605 }
606 0 ▶ if (! kill 1, $pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless (kill 1, $pid) 0 0 0
607 0 _ok(0, "Reload failed: $!");
608 0 exit 1;
609 }
610  
611 0 sleep 1;
612  
613 0 ▶ if (kill 0, $pid) {
Branch: 1 branch
BranchTrueFalseTotal
if (kill 0, $pid) { } 0 0 0
614 0 _ok(1, "Reloaded server");
615 } else {
616 0 _ok(0, "Sent HUP - but server is gone away - attempting start");
617 0 $self->__start;
618 }
619 }
620  
621 0 ▶sub __size_access { shift->__size_error('access_log_file') }
Subroutine __size_access: not called CC=1 SCAR=6.9
622  
623 0 ▶sub __size_error {
Subroutine __size_error: not called CC=3 SCAR=24.8
624 0 my ($self, $file) = @_;
625 0 ▶ $file = $self->{'server'}->{$file || 'log_file'} || throw "No log_file to size";
Condition0%0/5
$self->{'server'}{$file or 'log_file'} || throw('No log_file to size')
l!l&&r!l&&!r
000
$file || 'log_file'
l!l
00
MC/DC0%0/2
$self->{'server'}{$file or 'log_file'} || throw('No log_file to size')
$self->{'server'}{$file or 'log_file'} throw('No log_file to size')
MC/DC0%0/1
$file || 'log_file'
$file
Truth table0%0/3
A || B
A= $self->{'server'}{$file or 'log_file'}B= throw('No log_file to size')
ABresult
1X1
011
000
Truth table0%0/2
A
A= $file
Aresult
11
00
626 0 return -s $file;
627 }
628  
629 3 ▶sub __tail_access { shift->__tail_error(shift(), 'access_log_file') }
Subroutine __tail_access: called CC=1 SCAR=0.0
630  
631 6 ▶sub __tail_error {
Subroutine __tail_error: called CC=7 SCAR=21.8
632 6 my ($self, $how, $file) = @_;
633 6 ▶ $how = quotemeta($how || shift(@ARGV) || 'f');
Condition40%2/5
$how || shift @ARGV || 'f'
l!l
60
$how or shift @ARGV
l!l&&r!l&&!r
600
MC/DC0%0/2
$how || shift @ARGV || 'f'
$how shift @ARGV
Truth table33%1/3
A or B
A= $howB= shift @ARGV
ABresult
1X1
011
000
634 6 ▶ $file = quotemeta($self->{'server'}->{$file || 'log_file'} || throw "No log_file to tail");
Condition60%3/5
$self->{'server'}{$file or 'log_file'} || throw('No log_file to tail')
l!l&&r!l&&!r
600
$file || 'log_file'
l!l
33
MC/DC0%0/2
$self->{'server'}{$file or 'log_file'} || throw('No log_file to tail')
$self->{'server'}{$file or 'log_file'} throw('No log_file to tail')
MC/DC100%1/1
$file || 'log_file'
$file
Truth table33%1/3
A || B
A= $self->{'server'}{$file or 'log_file'}B= throw('No log_file to tail')
ABresult
1X1
011
000
Truth table100%2/2
A
A= $file
Aresult
11
00
635 6 my $cmd = "tail -$how $file";
636 6 warn "$cmd\n";
637 6 ▶ exec $cmd if $how eq 'f';
Branch: 1 branch
BranchTrueFalseTotal
if $how eq "f" 0 6 6
638 6 ▶ warn `$cmd` || "No error log\n";
Condition50%1/2
`$cmd` || "No error log\n"
l!l
60
MC/DC0%0/1
`$cmd` || "No error log\n"
`$cmd`
Truth table50%1/2
A
A= `$cmd`
Aresult
11
00
639 }
640  
641 3 ▶sub __ps {
Subroutine __ps: called CC=3 SCAR=11.3
642 3 my $name = shift->server_name;
643 3 ▶ my $out = join '', grep {$_ =~ $name && $_ !~ /\b(?:watch|ps)\b/} `ps auwx`;
Condition66%2/3
$_ =~ /$name/ && !($_ =~ /\b(?:watch|ps)\b/)
!ll&&!rl&&r
33013
MC/DC50%1/2
$_ =~ /$name/ && !($_ =~ /\b(?:watch|ps)\b/)
$_ =~ /$name/ !($_ =~ /\b(?:watch|ps)\b/)
Truth table66%2/3
A && not(B)
A= $_ =~ /$name/B= !($_ =~ /\b(?:watch|ps)\b/)
ABresult
0X0
100
111
644 3 ▶ warn $out || "No processes found\n";
Condition50%1/2
$out || "No processes found\n"
l!l
30
MC/DC0%0/1
$out || "No processes found\n"
$out
Truth table50%1/2
A
A= $out
Aresult
11
00
645 }
646  
647 ###----------------------------------------------------------------###
648  
649 0 ▶sub cgidoc_brand {
Subroutine cgidoc_brand: not called CC=2 SCAR=17.9
Pod undocumented
650 0 my $self = shift;
651 0 ▶ return $self->config(no_brand => 0) ? undef : $self->config(brand => sub { eval { config::provider() } || $self->_configs->{'provider'} || do { warn "Missing brand"; '-' } });
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
BranchTrueFalseTotal
$self->config('no_brand', 0) ? : 0 0 0
eval { do { config::provider() } } or $self->_configs->{"provider"} or do { warn "Missing brand"; "-" } 0 0 0
Condition0%0/3
eval { do { config::provider() } } or $self->_configs->{"provider"}
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { config::provider() } } or $self->_configs->{"provider"}
eval { do { config::provider() } } $self->_configs->{"provider"}
Truth table0%0/3
A or B
A= eval { do { config::provider() } }B= $self->_configs->{"provider"}
ABresult
1X1
011
000
652 }
653  
654 0 ▶sub cgidoc {
Subroutine cgidoc: not called CC=4 SCAR=30.0
Pod undocumented
655 0 my $self = shift;
656 0 ▶ eval { CGI::initialize_globals() } or warn "Failed to initialize globals: $@" if $INC{'CGI.pm'}; # CGI.pm caches query parameters
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"CGI.pm"} 0 0 0
Condition0%0/5
$INC{'CGI.pm'} && (eval { do { CGI::initialize_globals() } } || warn("Failed to initialize globals: $@"))
!ll&&!rl&&r
000
eval { do { CGI::initialize_globals() } } or warn "Failed to initialize globals: $@"
l!l
00
MC/DC0%0/2
$INC{'CGI.pm'} && (eval { do { CGI::initialize_globals() } } || warn("Failed to initialize globals: $@"))
$INC{'CGI.pm'} eval { do { CGI::initialize_globals() } }
Truth table0%0/3
A && B
A= $INC{'CGI.pm'}B= eval { do { CGI::initialize_globals() } }
ABresult
0X0
100
111
657  
658 0 my $name = $self->server_name;
659 my $disp = $self->dispatch_factory->({
660 is_server => "$name/doc",
661 api_ip => $ENV{'REMOTE_ADDR'},
662 api_brand => $self->cgidoc_brand,
663 0 remote_ip => $ENV{'REMOTE_ADDR'},
664 remote_user => '-auto-doc-',
665 # token and remote_user will be updated by auto_doc_class if it is based on App::_Admin
666 dbh_cache => {},
667 transport => 'form-doc',
668 });
669  
670 0 my $class = $self->config(auto_doc_class => 'Net::Respite::AutoDoc');
671 0 (my $file = "$class.pm") =~ s|::|/|g;
672 0 require $file;
673 0 ▶ $class->new({
Branch: 1 branch
BranchTrueFalseTotal
$name =~ /^(\w+)_server/ ? : 0 0 0
674 service => (($name =~ /^(\w+)_server/) ? $1 : $name),
675 server => $self,
676 api_obj => $disp,
677 })->navigate;
678 }
679  
680 ###----------------------------------------------------------------###
681  
682 4 1;
« Respite/Validate.pm ↑ Summary Respite/CommandLine.pm »