Branch Coverage

File:blib/lib/CGI/Info.pm
Coverage:82.6%

line%coveragebranch
156100TFif (not defined $class) { }
100TFelsif (&Scalar::Util::blessed($class)) { }
157100TFif (defined $params)
17450TFif (defined $params->{'logger'})
17550TFunless (&Scalar::Util::blessed($params->{'logger'}) and $params->{'logger'}->can("warn") and $params->{'logger'}->can("info") and $params->{'logger'}->can("error"))
180100TFif (defined $params->{'expect'})
18550TFif (my $logger = $params->{'logger'})
233100TFunless ($self->{'script_name'})
24250TFunless (UNIVERSAL::isa((&CORE::GLOBAL::caller())[0], __PACKAGE__))
24850TFunless "File::Basename"->can("basename")
257100TFif (my $script_path = $self->_get_env('SCRIPT_FILENAME')) { }
100TFelsif ($script_name = $self->_get_env('SCRIPT_NAME')) { }
100TFelsif ('File::Spec'->file_name_is_absolute($0)) { }
260100TFif (my $document_root = $self->_get_env('DOCUMENT_ROOT')) { }
268100TFif ('File::Spec'->file_name_is_absolute($script_name) and -r $script_name) { }
27250TFunless "Cwd"->can("abs_path")
274100TFif ($script_name =~ m[^/(.+)])
317100TFunless ($self->{'script_path'})
344100TFunless ref $self
347100TFunless $self->{'script_path'}
35150TF$^O eq 'MSWin32' ? :
35350TF$self->{'script_path'} =~ /$dir_regex/ ? :
380100TFunless ($self->{'site'})
39450TFif $self->{'site'} and $self->{'cgi_site'}
397100TFif (my $host = $ENV{'HTTP_HOST'} || $ENV{'SERVER_NAME'} || $ENV{'SSL_TLS_SNI'}) { }
399100TFunless "URI::Heuristic"->can("uf_uristr")
406100TFif ($ENV{'SERVER_NAME'} and $host eq $ENV{'SERVER_NAME'} and my $protocol = $self->protocol and $self->protocol ne "http")
41150TFunless "Sys::Hostname"->can("hostname")
421100TFunless $self->{'cgi_site'} =~ m[^https?://]
42450TFunless $self->{'site'} and $self->{'cgi_site'}
442100TFunless (ref $self)
445100TFif $self->{'domain'}
44950TFif (my $site = $self->{'site'})
450100TF$site =~ /^www\.(.+)/ ? :
465100TFunless ($self->{'cgi_site'})
634100TFif (defined $self->{'paramref'} and !defined($params->{'allow'}) || defined $self->{'allow'} && $params->{'allow'} eq $self->{'allow'})
638100TFif (defined $params->{'allow'})
649100TFif (defined $params->{'upload_dir'})
652100TFif (defined $params->{'logger'})
661100TFif (not $ENV{'GATEWAY_INTERFACE'} && $ENV{'REQUEST_METHOD'}) { }
100TFelsif ($ENV{'REQUEST_METHOD'} eq 'GET' or $ENV{'REQUEST_METHOD'} eq 'HEAD') { }
100TFelsif ($ENV{'REQUEST_METHOD'} eq 'POST') { }
100TFelsif ($ENV{'REQUEST_METHOD'} eq 'OPTIONS') { }
100TFelsif ($ENV{'REQUEST_METHOD'} eq 'DELETE') { }
665100TFif (@ARGV) { }
50TFelsif ($stdin_data) { }
66750TFif (defined $pairs[0])
668100TFif ($pairs[0] eq '--robot') { }
100TFelsif ($pairs[0] eq '--mobile') { }
100TFelsif ($pairs[0] eq '--search-engine') { }
100TFelsif ($pairs[0] eq '--tablet') { }
705100TFif (my $query = $ENV{'QUERY_STRING'}) { }
706100TFif (defined $content_type and $content_type =~ m[multipart/form-data]i)
707100TFif ($ENV{'REMOTE_ADDR'}) { }
722100TFif (not defined $content_length or $content_length =~ /\D/)
726100TFif ($self->{'max_upload_size'} >= 0 and $content_length > $self->{'max_upload_size'})
734100TFif (not defined $content_type or $content_type =~ m[application/x-www-form-urlencoded]) { }
100TFelsif ($content_type =~ m[multipart/form-data]i) { }
100TFelsif ($content_type =~ m[text/xml]i) { }
100TFelsif ($content_type =~ m[application/json]i) { }
736100TFif ($stdin_data) { }
739100TFif (read(STDIN, $buffer, $content_length) != $content_length)
751100TFunless (defined $self->{'upload_dir'})
752100TFif ($ENV{'REMOTE_ADDR'}) { }
767100TFunless ("File::Spec"->file_name_is_absolute($self->{'upload_dir'}))
775100TFunless (-d $self->{'upload_dir'})
783100TFunless (-w $self->{'upload_dir'})
793100TFunless ($self->{'upload_dir'} =~ /^\Q$tmpdir\E/)
80150TFif ($content_type =~ /boundary=(\S+)$/)
809100TFif ($stdin_data) { }
81250TFif (read(STDIN, $buffer, $content_length) != $content_length)
82650TFunless "JSON::MaybeXS"->can("parse_json")
832100TFif ($stdin_data) { }
83550TFif (read(STDIN, $buffer, $content_length) != $content_length)
850100TFif ($stdin_data) { }
85350TFif (read(STDIN, $buffer, $content_length) != $content_length)
880100TFunless (scalar @pairs)
892100TFunless $key
898100TFif (defined $value) { }
910100TFif ($self->{'allow'})
912100TFunless (exists $self->{'allow'}{$key})
919100TFif (defined(my $schema = $self->{'allow'}{$key}))
920100TFif (not ref $schema) { }
100TFelsif (ref $schema eq 'Regexp') { }
100TFelsif (ref $schema eq 'CODE') { }
922100TFif ($value ne $schema)
928100TFunless ($value =~ /$schema/)
935100TFunless (&$schema($key, $value, $self))
949100TFif ($@)
95450TFif (scalar keys %{$value;}) { }
970100TFif (not defined $ENV{'REQUEST_METHOD'} or $ENV{'REQUEST_METHOD'} eq "GET")
989100TFif ($has_quote or $has_hash or $has_equals and $has_dash)
9900TFif ($orig_value =~ /(\%27)|(\')|(\%23)|(\#)/xi or $has_equals and $has_quote || $has_semi || $has_dash and $orig_value =~ /((\%3D)|(=))[^-]*+((\%27)|(\')|(\-\-)|(\%3B)|(;))/i or $has_quote and $orig_value =~ /\w*((\%27)|(\'))((\%6F)|o|(\%4F))((\%72)|r|(\%52))\s*(OR|AND|UNION|SELECT|--)/xi or $has_quote and $orig_value =~ /((\%27)|(\'))union/xi)
998100TFif ($ENV{'REMOTE_ADDR'}) { }
1014100TFif ($has_select and $orig_value =~ /select[[a-z]\s\*]from/xi or $has_and and $orig_value =~ /\sAND\s1=1/xi or $has_or and $has_and and $orig_value =~ /\sOR\s.*\sAND\s/ or $has_slash and $orig_value =~ m[/\*\*/ORDER/\*\*/BY/\*\*]xi or $has_dump and $orig_value =~ /var_dump[^m]*+md5/ or $has_slash and $has_select and $orig_value =~ m[/AND/[^(]*+\(SELECT/] or $has_exec and $orig_value =~ /exec(\s|\+)++(s|x)p\w+/xi)
102250TFif ($ENV{'REMOTE_ADDR'}) { }
1030100TFif (my $agent = $ENV{'HTTP_USER_AGENT'})
103150TFif ($agent =~ /SELECT.+AND.+/ or $agent =~ /ORDER BY / or $agent =~ / OR NOT / or $agent =~ / AND \d+=\d+/ or $agent =~ /THEN.+ELSE.+END/ or $agent =~ /.+AND.+SELECT.+/ or $agent =~ /\sAND\s.+\sAND\s/)
103350TFif ($ENV{'REMOTE_ADDR'}) { }
1042100TFif ($value =~ m[((\%3C)|<)((\%2F)|/)*[a-z0-9\%]+((\%3E)|>)]xi or $value =~ /((\%3C)|<)[^\n]+((\%3E)|>)/i or $orig_value =~ m[((\%3C)|<)((\%2F)|/)*[a-z0-9\%]+((\%3E)|>)]xi or $orig_value =~ /((\%3C)|<)[^\n]+((\%3E)|>)/i)
1051100TFif ($value =~ m[mustleak\.com/])
1057100TFif ($value =~ m[\.\./])
1063100TFif (length $value > 0)
1065100TFif ($FORM{$key} and $FORM{$key} ne $value) { }
1073100TFunless (%FORM)
107750TFif ($self->{'logger'})
1125100TFunless (defined $field)
1129100TFif ($self->{'allow'} and not exists $self->{'allow'}{$field})
113850TFif ($self->{'in_param'} and $self->{'allow'})
1146100TFif $allow
1148100TFif ($params)
115650TFunless defined $arg
118150TFif ($total_bytes == 0)
118550TFunless ($stdin_data)
119150TFunless ($stdin_data)
1206100TFif ($line =~ /^--\Q$boundary\E--$/)
1209100TFif ($line =~ /^--\Q$boundary\E$/) { }
100TFelsif ($in_header) { }
121050TFif ($writing_file) { }
100TFelsif (defined $key) { }
1219100TFif (length $line == 0) { }
100TFelsif ($line =~ /^Content-Disposition: (.+)/i) { }
122350TFif ($field =~ /name="(.+?)"/)
1226100TFif ($field =~ /filename="(.+)?"/)
1228100TFdo {         $filename =~ m[[\\/\|]] } ? :
50TFdefined $filename ? :
124150TFunless (open $fout, ">", $full_path)
1251100TFif ($writing_file) { }
125950TFif ($writing_file)
127750TF$counter ? :
128850TFif ($args->{'filename'} =~ m<(^[\w\+_\040\#\(\)\{\}\[\]/\-\^,\.:;&%\@\\~]+\$?$)>)
1307100TFif (defined $self->{'is_mobile'})
1311100TFif ($ENV{'IS_MOBILE'})
1316100TFif (my $ch_ua_mobile = $ENV{'HTTP_SEC_CH_UA_MOBILE'})
1317100TFif ($ch_ua_mobile eq "?1")
1323100TFif ($ENV{'HTTP_X_WAP_PROFILE'})
1330100TFif (my $agent = $ENV{'HTTP_USER_AGENT'})
1331100TFif ($agent =~ /.+(Android|iPhone).+/)
1337100TFif ($agent =~ m[(android|bb\d+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino]i or substr($ENV{'HTTP_USER_AGENT'}, 0, 4) =~ m[1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-]i)
1344100TFif (defined $remote and $self->{'cache'})
134550TFif (my $type = $self->{'cache'}->get("$remote/$agent"))
1350100TFunless ($self->{'browser_detect'})
135150TFif (eval {         do {         require HTTP::BrowserDetect } })
135750TFif ($self->{'browser_detect'})
1360100TFdefined $device && $device =~ /blackberry|webos|iphone|ipod|ipad|android/i ? :
136150TFif ($is_mobile and $self->{'cache'} and defined $remote)
1380100TFif (defined $self->{'is_tablet'})
1384100TFif ($ENV{'HTTP_USER_AGENT'} and $ENV{'HTTP_USER_AGENT'} =~ /.+(iPad|TabletPC).+/) { }
1441100TFif ($args->{'raw'}) { }
1474100TFif ($ENV{'SCRIPT_URI'} and $ENV{'SCRIPT_URI'} =~ m[^(.+)://.+])
1477100TFif ($ENV{'SERVER_PROTOCOL'} and $ENV{'SERVER_PROTOCOL'} =~ m[^HTTP/])
1481100TFif (my $port = $ENV{'SERVER_PORT'})
1482100TFif (defined(my $name = getservbyport($port, 'tcp'))) { }
50TFelsif ($port == 80) { }
50TFelsif ($port == 443) { }
1483100TFif ($name =~ /https?/) { }
50TFelsif ($name eq 'www') { }
1498100TFif ($ENV{'REMOTE_ADDR'})
153550TFif ($^O eq "MSWin32")
1541100TFunless (ref $self)
1546100TFif ($ENV{'C_DOCUMENT_ROOT'} and -d $ENV{'C_DOCUMENT_ROOT'})
1548100TFif (-d $dir and -w $dir)
155250TFif (-d $dir and -w $dir)
1556100TFif ($ENV{'DOCUMENT_ROOT'} and -d $ENV{'DOCUMENT_ROOT'})
1558100TFif (-d $dir and -w $dir)
1562100TFif ($params->{'default'} and ref $params->{'default'})
1565100TF$params->{'default'} ? :
1583100TFif ($ENV{'C_DOCUMENT_ROOT'} and -d $ENV{'C_DOCUMENT_ROOT'}) { }
100TFelsif ($ENV{'DOCUMENT_ROOT'} and -d $ENV{'DOCUMENT_ROOT'}) { }
159050TFunless ("File::Spec"->file_name_is_absolute($script_name))
159350TFif ($script_name =~ /.cgi\-bin.*/)
159650TFif (-f $script_name)
159750TFif ($^O eq 'MSWin32') { }
15980TFif ($script_name =~ /(.+)\\.+?$/)
160250TFif ($script_name =~ m[(.+)/.+?$])
1618100TFif ($_[0] and ref $_[0])
1634100TFif ($_[0] and ref $_[0])
1660100TFunless (ref $self)
1664100TFif ($dir)
1665100TFif (length $dir and -d $dir and -w $dir)
1673100TFif (defined $rc and length $rc and -d $rc and -w $rc)
167850TFif not defined $dir or length $dir == 0
1704100TFif (defined $self->{'is_robot'})
1711100TFunless ($remote and $agent)
171750TFif ($agent =~ /SELECT.+AND.+/ or $agent =~ /ORDER BY / or $agent =~ / OR NOT / or $agent =~ / AND \d+=\d+/ or $agent =~ /THEN.+ELSE.+END/ or $agent =~ /.+AND.+SELECT.+/ or $agent =~ /\sAND\s.+\sAND\s/)
172050TFif ($ENV{'REMOTE_ADDR'}) { }
1727100TFif ($agent =~ m[.+bot|axios/1\.6\.7|bidswitchbot|bytespider|ClaudeBot|Clickagy.Intelligence.Bot|msnptc|CriteoBot|is_archiver|backstreet|fuzz faster|linkfluence\.com|spider|scoutjet|gingersoftware|heritrix|dodnetdotcom|yandex|nutch|ezooms|plukkie|nova\.6scan\.com|Twitterbot|adscanner|Go-http-client|python-requests|Mediatoolkitbot|NetcraftSurveyAgent|Expanse|serpstatbot|DreamHost SiteMonitor|techiaith.cymru|trendictionbot|ias_crawler|WPsec|Yak/1\.0|ZoominfoBot]i)
1738100TFif (my $referrer = $ENV{'HTTP_REFERER'})
178050TFif ($referrer =~ /\)/ or &List::Util::any(sub {         $_ =~ /^$referrer/; } , @crawler_lists))
178350TFif ($self->{'cache'})
1791100TFif (defined $remote and $self->{'cache'})
179250TFif (my $type = $self->{'cache'}->get("$remote/$agent"))
1799100TFif ($agent =~ /www\.majestic12\.co\.uk|facebookexternal/)
180150TFif ($self->{'cache'})
1807100TFunless ($self->{'browser_detect'})
180850TFif (eval {         do {         require HTTP::BrowserDetect } })
181350TFif ($self->{'browser_detect'})
1815100TFif (defined $is_robot)
1818100TFdefined $is_robot && $is_robot ? :
1821100TFif ($is_robot)
182250TFif ($self->{'cache'})
183050TFif ($self->{'cache'})
1855100TFif (defined $self->{'is_search_engine'})
1859100TFif ($ENV{'IS_SEARCH_ENGINE'})
1866100TFunless ($remote and $agent)
1873100TFif ($self->{'cache'})
187550TFif (defined $remote and $self->{'cache'})
187650TFif (my $type = $self->{'cache'}->get("$remote/$agent"))
1884100TFif ($agent =~ /www\.majestic12\.co\.uk|facebookexternal/)
188650TFif ($self->{'cache'})
1892100TFunless ($self->{'browser_detect'})
189350TFif (eval {         do {         require HTTP::BrowserDetect } })
189850TFif (my $browser = $self->{'browser_detect'})
1900100TFunless ($is_search)
1901100TFif ($agent =~ m[SeznamBot/] or $agent =~ m[Google-InspectionTool/] or $agent =~ m[Googlebot/])
190750TFif ($is_search and $self->{'cache'})
19180TFif (defined $hostname and $hostname =~ /google|msnbot|bingbot|amazonbot|GPTBot/ and not $hostname =~ /^google-proxy/ or Net::CIDR::cidrlookup($remote, @cidr_blocks))
19200TFif ($self->{'cache'})
1958100TFif ($self->is_mobile)
1961100TFif ($self->is_search_engine)
1964100TFif ($self->is_robot)
2056100TFunless (defined $field)
206150TFif (ref $field)
2068100TFunless ($self->{'jar'})
2069100TFif (defined $ENV{'HTTP_COOKIE'})
2109100TFif defined $status
2112100TFunless (defined $self->{'status'})
2115100TFif $method and $method eq 'OPTIONS' || $method eq 'DELETE'
2116100TFif $method and ($method eq "POST" and not defined $ENV{'CONTENT_LENGTH'})
2156100TFif (scalar $self->{'messages'})
2189100TFif ($cache)
2190100TFunless &Scalar::Util::blessed($cache)
219150TFunless $cache->can("get")
219250TFunless $cache->can("set")
221250TFif (my $logger = $params->{'logger'}) { }
2213100TFif (&Scalar::Util::blessed($logger)) { }
222950TFif (scalar @messages)
223550TFif (scalar @messages and my $logger = $self->{'logger'})
226750TFif (not defined $self->{'logger'})
227850TFif (not defined $self->{'logger'})
2289100TFunless defined $ENV{$var}
2292100TFif ($ENV{$var} =~ m(^[\w\.\-/:\\]+$))
2311100TFunless ($class eq __PACKAGE__)
232350TFunless my $self = shift()
2325100TFunless defined $AUTOLOAD
2331100TFif $method eq "DESTROY"
233350TFunless ref $self
2336100TFif exists $self->{'auto_load'} and &boolean($self->{'auto_load'})->isFalse
233950TFunless ref $self eq __PACKAGE__ or UNIVERSAL::isa((&CORE::GLOBAL::caller())[0], __PACKAGE__)
234250TFunless $method =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/