Branch Coverage

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

line%coveragebranch
254100TFif (defined $class) { }
256100TFunless ($is_valid)
26250TFif (defined $params and keys %{$params;})
269100TFif (&Scalar::Util::blessed($class))
274100TFif (defined $params->{'logger'})
2750TFunless (&Scalar::Util::blessed($params->{'logger'}) and $params->{'logger'}->can("warn") and $params->{'logger'}->can("info") and $params->{'logger'}->can("error"))
281100TFif (defined $params->{'expect'})
28350TFif $logger
29750TFif (defined $params->{'logger'})
29850TFunless (&Scalar::Util::blessed($params->{'logger'}) and $params->{'logger'}->can("warn") and $params->{'logger'}->can("info") and $params->{'logger'}->can("error"))
303100TFif (defined $params->{'expect'})
30850TFif (my $logger = $params->{'logger'})
356100TFunless ($self->{'script_name'})
3670TFunless "File::Basename"->can("basename")
3760TFif (my $script_path = $self->_get_env('SCRIPT_FILENAME')) { }
0TFelsif ($script_name = $self->_get_env('SCRIPT_NAME')) { }
0TFelsif ('File::Spec'->file_name_is_absolute($0)) { }
3790TFif (my $document_root = $self->_get_env('DOCUMENT_ROOT')) { }
3870TFif ('File::Spec'->file_name_is_absolute($script_name) and -r $script_name) { }
3910TFunless "Cwd"->can("abs_path")
3930TFif ($script_name =~ m[^/(.+)])
436100TFunless ($self->{'script_path'})
463100TFunless ref $self
466100TFunless $self->{'script_path'}
47050TF$^O eq 'MSWin32' ? :
47250TF$self->{'script_path'} =~ /$dir_regex/ ? :
499100TFunless ($self->{'site'})
560100TFunless (ref $self)
563100TFif $self->{'domain'}
56750TFif (my $site = $self->{'site'})
568100TF$site =~ /^www\.(.+)/ ? :
583100TFunless ($self->{'cgi_site'})
752100TFif (defined $self->{'paramref'} and !defined($params->{'allow'}) || defined $self->{'allow'} && $params->{'allow'} eq $self->{'allow'})
756100TFif (defined $params->{'allow'})
759100TFif (defined $params->{'upload_dir'})
762100TFif (defined $params->{'logger'})
771100TFif (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') { }
775100TFif (@ARGV) { }
50TFelsif ($stdin_data) { }
77750TFif (defined $pairs[0])
778100TFif ($pairs[0] eq '--robot') { }
100TFelsif ($pairs[0] eq '--mobile') { }
100TFelsif ($pairs[0] eq '--search-engine') { }
100TFelsif ($pairs[0] eq '--tablet') { }
797100TFif (my $query = $ENV{'QUERY_STRING'}) { }
798100TFif (defined $content_type and $content_type =~ m[multipart/form-data]i)
799100TFif ($ENV{'REMOTE_ADDR'}) { }
814100TFif (not defined $content_length or $content_length =~ /\D/)
818100TFif ($self->{'max_upload_size'} >= 0 and $content_length > $self->{'max_upload_size'})
826100TFif (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) { }
828100TFif ($stdin_data) { }
831100TFif (&CGI::Info::read("STDIN", \$buffer, $content_length) != $content_length)
843100TFunless (defined $self->{'upload_dir'})
844100TFif ($ENV{'REMOTE_ADDR'}) { }
859100TFunless ("File::Spec"->file_name_is_absolute($self->{'upload_dir'}))
867100TFunless (-d $self->{'upload_dir'})
875100TFunless (-w $self->{'upload_dir'})
885100TFunless ($self->{'upload_dir'} =~ /^\Q$tmpdir\E/)
89350TFif ($content_type =~ /boundary=(\S+)$/)
901100TFif ($stdin_data) { }
90450TFif (&CGI::Info::read("STDIN", \$buffer, $content_length) != $content_length)
91850TFunless "JSON::MaybeXS"->can("parse_json")
924100TFif ($stdin_data) { }
92750TFif (&CGI::Info::read("STDIN", \$buffer, $content_length) != $content_length)
942100TFif ($stdin_data) { }
94550TFif (&CGI::Info::read("STDIN", \$buffer, $content_length) != $content_length)
972100TFunless (scalar @pairs)
984100TFunless $key
990100TFif (defined $value) { }
1003100TFif ($self->{'allow'})
1005100TFunless (exists $self->{'allow'}{$key})
1012100TFif (defined(my $schema = $self->{'allow'}{$key}))
1013100TFif (not ref $schema) { }
100TFelsif (ref $schema eq 'Regexp') { }
100TFelsif (ref $schema eq 'CODE') { }
1015100TFif ($value ne $schema)
1021100TFunless ($value =~ /$schema/)
1028100TFunless (&$schema($key, $value, $self))
1042100TFif ($@)
104750TFif (scalar keys %{$value;}) { }
1085100TFif ($has_quote or $has_hash or $has_equals and $has_dash)
10860TFif ($orig_value =~ /(?:%27|'|%23|#)/i 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)
1096100TFif ($ENV{'REMOTE_ADDR'}) { }
1112100TFif ($has_select and $orig_value =~ /\bselect\b.{1,500}?\bfrom\b/is or $has_and and $orig_value =~ /\sAND\s1=1/xi or $has_or and $orig_value =~ /\bOR\s+\d+\s*=\s*\d+/i or $has_or and $has_and and $orig_value =~ /\sOR\s.{1,500}?\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+]++[sx]p\w+/xi)
1126100TFif ($ENV{'REMOTE_ADDR'}) { }
1134100TFif (my $agent = $ENV{'HTTP_USER_AGENT'})
113750TFif ($agent =~ /\bSELECT\b.{1,500}?\bAND\b/i or $agent =~ /\bORDER\s+BY\b/i or $agent =~ /\bOR\s+NOT\b/i or $agent =~ /\bAND\b\s+\d+=\d+/ or $agent =~ /\bTHEN\b.{1,300}?\bELSE\b.{1,300}?\bEND\b/i or $agent =~ /\bAND\b.{1,500}?\bSELECT\b/i or $agent =~ /\sAND\s.{1,500}?\sAND\s/)
1139100TFif ($ENV{'REMOTE_ADDR'}) { }
1154100TFif ($value =~ m[(?:%3C|<)(?:%2F|/)*[a-z0-9%]+(?:%3E|>)]xi or $value =~ /(?:%3C|<)[^>]+(?:%3E|>)/i or $orig_value =~ m[(?:%3C|<)(?:%2F|/)*[a-z0-9%]+(?:%3E|>)]xi or $orig_value =~ /(?:%3C|<)[^>]+(?:%3E|>)/i)
1165100TFif ($orig_value =~ /\bjavascript\s*:/i)
1171100TFif ($value =~ m[mustleak\.com/])
1177100TFif ($value =~ m[\.\./])
1183100TFif (length $value > 0)
1185100TFif ($FORM{$key} and $FORM{$key} ne $value) { }
1193100TFunless (%FORM)
119750TFif ($self->{'logger'})
1261100TFunless (defined $field)
1265100TFif ($self->{'allow'} and not exists $self->{'allow'}{$field})
127450TFif ($self->{'in_param'} and $self->{'allow'})
1282100TFif $allow
1284100TFif ($params)
1469100TFif (defined $self->{'is_mobile'})
1473100TFif ($ENV{'IS_MOBILE'})
1478100TFif (my $ch_ua_mobile = $ENV{'HTTP_SEC_CH_UA_MOBILE'})
1479100TFif ($ch_ua_mobile eq "?1")
1485100TFif ($ENV{'HTTP_X_WAP_PROFILE'})
1492100TFif (my $agent = $ENV{'HTTP_USER_AGENT'})
1495100TFif ($agent =~ /\b(?:Android|iPhone)\b/)
1501100TFif ($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)
1508100TFif (defined $remote and $self->{'cache'})
150950TFif (my $type = $self->{'cache'}->get("$remote/$agent"))
1514100TFunless ($self->{'browser_detect'})
151550TFif (eval {         do {         require HTTP::BrowserDetect } })
152150TFif ($self->{'browser_detect'})
1524100TFdefined $device && $device =~ /blackberry|webos|iphone|ipod|ipad|android/i ? :
152550TFif ($is_mobile and $self->{'cache'} and defined $remote)
1544100TFif (defined $self->{'is_tablet'})
1549100TFif ($ENV{'HTTP_USER_AGENT'} and $ENV{'HTTP_USER_AGENT'} =~ /\b(?:iPad|TabletPC)\b/) { }
1606100TFif ($args->{'raw'}) { }
1642100TFif ref $self and exists $self->{'protocol'}
1647100TFif ($ENV{'SCRIPT_URI'} and $ENV{'SCRIPT_URI'} =~ m[^([a-zA-Z][a-zA-Z0-9+\-.]*)://]) { }
100TFelsif ($ENV{'SERVER_PROTOCOL'} and $ENV{'SERVER_PROTOCOL'} =~ m[^HTTP/]) { }
100TFelsif (my $port = $ENV{'SERVER_PORT'}) { }
1652100TFif (defined(my $name = getservbyport($port, 'tcp'))) { }
50TFelsif ($port == 80) { }
50TFelsif ($port == 443) { }
1653100TFif ($name =~ /^https?$/) { }
50TFelsif ($name eq 'www') { }
1668100TFif (not defined $result and $ENV{'REMOTE_ADDR'})
1671100TFif ref $self
170650TFif ($^O eq "MSWin32")
1712100TFunless (ref $self)
1717100TFif ($ENV{'C_DOCUMENT_ROOT'} and -d $ENV{'C_DOCUMENT_ROOT'})
1719100TFif (-d $dir and -w $dir)
172350TFif (-d $dir and -w $dir)
1727100TFif ($ENV{'DOCUMENT_ROOT'} and -d $ENV{'DOCUMENT_ROOT'})
1729100TFif (-d $dir and -w $dir)
1733100TFif ($params->{'default'} and ref $params->{'default'})
1736100TF$params->{'default'} ? :
1754100TFif ($ENV{'C_DOCUMENT_ROOT'} and -d $ENV{'C_DOCUMENT_ROOT'}) { }
100TFelsif ($ENV{'DOCUMENT_ROOT'} and -d $ENV{'DOCUMENT_ROOT'}) { }
176350TFunless defined $script_name
176550TFunless ("File::Spec"->file_name_is_absolute($script_name))
176850TFif ($script_name =~ m([/\\]cgi-bin))
177150TFif (-f $script_name)
177250TFif ($^O eq 'MSWin32') { }
17730TFif ($script_name =~ /(.+)\\.+?$/)
177750TFif ($script_name =~ m[(.+)/.+?$])
1793100TFif ($_[0] and ref $_[0])
1809100TFif ($_[0] and ref $_[0])
1835100TFunless (ref $self)
1839100TFif ($dir)
1840100TFif (length $dir and -d $dir and -w $dir)
1848100TFif (defined $rc and length $rc and -d $rc and -w $rc)
185350TFif not defined $dir or length $dir == 0
1879100TFif (defined $self->{'is_robot'})
1886100TFunless ($remote and $agent)
189750TFif ($agent =~ /\bSELECT\b.{1,500}?\bAND\b/i or $agent =~ /\bORDER\s+BY\b/i or $agent =~ /\bOR\s+NOT\b/i or $agent =~ /\bAND\b\s+\d+=\d+/ or $agent =~ /\bTHEN\b.{1,300}?\bELSE\b.{1,300}?\bEND\b/i or $agent =~ /\bAND\b.{1,500}?\bSELECT\b/i or $agent =~ /\sAND\s.{1,500}?\sAND\s/)
190650TFif ($ENV{'REMOTE_ADDR'}) { }
1917100TFif ($self->is_ai)
1922100TFif ($agent =~ m[\bbot\b|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)
1937100TFif ($self->{'cache'})
193850TFif (my $type = $self->{'cache'}->get($key))
1943100TFif (my $referrer = $ENV{'HTTP_REFERER'})
1948100TFif ($referrer =~ /\)/ or $referrer =~ /$CRAWLER_REFERER_RE/)
195050TFif ($self->{'cache'})
1960100TFif ($agent =~ /www\.majestic12\.co\.uk|facebookexternal/)
196250TFif ($self->{'cache'})
1968100TFunless ($self->{'browser_detect'})
196950TFif (eval {         do {         require HTTP::BrowserDetect } })
197450TFif ($self->{'browser_detect'})
1976100TFif (defined $is_robot)
1979100TFdefined $is_robot && $is_robot ? :
1982100TFif ($is_robot)
198350TFif ($self->{'cache'})
199150TFif ($self->{'cache'})
2016100TFif (defined $self->{'is_search_engine'})
2020100TFif ($ENV{'IS_SEARCH_ENGINE'})
2027100TFunless ($remote and $agent)
2035100TFif ($self->{'cache'})
203650TFif (my $type = $self->{'cache'}->get($key))
2046100TFif ($agent =~ /www\.majestic12\.co\.uk|facebookexternal/)
204850TFif ($self->{'cache'})
2054100TFunless ($self->{'browser_detect'})
205550TFif (eval {         do {         require HTTP::BrowserDetect } })
206050TFif (my $browser = $self->{'browser_detect'})
2062100TFunless ($is_search)
2063100TFif ($agent =~ m[SeznamBot/] or $agent =~ m[Google-InspectionTool/] or $agent =~ m[Googlebot/])
206950TFif ($is_search and $self->{'cache'})
20790TFunless (defined $safe_remote)
20900TFif (defined $hostname and $hostname =~ /\b(?:google|msnbot|bingbot|amazonbot|GPTBot)\b/i and not $hostname =~ /^google-proxy/i or Net::CIDR::cidrlookup($remote, @cidr_blocks))
20920TFif ($self->{'cache'})
2187100TFif (defined $self->{'is_ai'})
2192100TFif (defined(my $override = $ENV{'IS_AI'}))
2193100TF$override ? :
2199100TFunless ($remote and $agent)
2224100TFif ($agent =~ /ClaudeBot|Claude-Web|anthropic-ai|GPTBot|ChatGPT-User|OAI-SearchBot|Google-Extended|meta-externalagent|FacebookBot|Applebot-Extended|PerplexityBot|Amazonbot|YouBot|Diffbot|cohere-ai|CCBot|Bytespider|AI2Bot|TimpiBot/i)
2274100TFif ($self->is_mobile)
2277100TFif ($self->is_ai)
2280100TFif ($self->is_search_engine)
2283100TFif ($self->is_robot)
2377100TFunless (defined $field)
238250TFif (ref $field)
2389100TFunless ($self->{'jar'})
2390100TFif (defined $ENV{'HTTP_COOKIE'})
2437100TFif defined $status
2440100TFunless (defined $self->{'status'})
2443100TFif $method and $method eq 'OPTIONS' || $method eq 'DELETE'
2444100TFif $method and ($method eq "POST" and not defined $ENV{'CONTENT_LENGTH'})
2484100TFif (scalar $self->{'messages'})
2517100TFif ($cache)
2518100TFunless &Scalar::Util::blessed($cache)
2519100TFunless $cache->can("get")
2520100TFunless $cache->can("set")
2540100TFif (my $logger = $params->{'logger'}) { }
2541100TFif (&Scalar::Util::blessed($logger)) { }
2638100TFunless ($class eq __PACKAGE__)
265050TFunless my $self = shift()
2652100TFunless defined $AUTOLOAD
2658100TFif $method eq "DESTROY"
2660100TFunless ref $self
2663100TFif exists $self->{'auto_load'} and &boolean($self->{'auto_load'})->isFalse
266650TFunless ref $self eq __PACKAGE__ or UNIVERSAL::isa((&CORE::GLOBAL::caller())[0], __PACKAGE__)
267150TFunless $method =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/