Branch Coverage

blib/lib/File/KeePass.pm
Criterion Covered Total %
branch 245 684 35.8


line true false branch
30 0 5 ref $_[0] ? :
36 3 6 if @_
40 4 83 unless (shift())->{'groups'}
58 1 4 unless $file
60 4 0 $file =~ /\.kdb$/i ? :
0 4 $file =~ /\.kdbx$/i ? :
68 0 3 unless open my $fh, '>', $tmp
72 0 3 if (-s $tmp ne length $buf)
77 1 2 if (-e $bak)
78 0 1 unless unlink $bak or unlink $tmp
80 2 1 if (-e $file)
81 0 2 unless rename $file, $bak or unlink $tmp
83 0 3 unless rename $tmp, $file
84 1 2 if (not $$self{'keep_backup'} and -e $bak)
85 0 1 unless unlink $bak
93 6 0 if $$self{'groups'}
103 0 6 unless ref $self
104 0 6 if ref $buffer
107 0 6 if $$head{'version'} == 2
110 5 1 if $$self{'groups'}
112 0 0 $$head{'version'} == 2 ? :
6 0 $$head{'version'} == 1 ? :
117 1 5 if exists $$args{'auto_lock'}
119 4 2 if $self->auto_lock
126 0 6 if $sig1 != 2594363651
127 6 0 if $sig2 eq 3041655653
128 0 0 if $sig2 eq 3041655655
135 0 6 if $size < 124
140 0 6 if $h{'ver'} & 1 & 4294967040
141 0 0 $h{'flags'} & 8 ? :
6 0 $h{'flags'} & 2 ? :
151 0 0 if $h{'ver'} & 1 & 4294901760
158 0 0 unless ($type)
164 0 0 if ($type == 1) { }
0 0 elsif ($type == 2) { }
0 0 elsif ($type == 3) { }
0 0 elsif ($type == 4) { }
0 0 elsif ($type == 5) { }
0 0 elsif ($type == 6) { }
0 0 elsif ($type == 7) { }
0 0 elsif ($type == 8) { }
0 0 elsif ($type == 9) { }
0 0 elsif ($type == 10) { }
167 0 0 if $val ne "1\301\362\346\277qCP\276X\cE!j\374Z\377"
171 0 0 if $val > 1
174 0 0 if length $val != 32
177 0 0 if length $val != 32
182 0 0 if length $val != 16
185 0 0 if length $val != 32
188 0 0 if length $val != 32
191 0 0 if unpack('V', $val) != 2
204 0 6 if $$head{'enc_type'} ne 'rijndael'
208 0 6 if length $buffer > 4294967295 or not length $buffer and $$head{'n_groups'}
210 0 6 if $$head{'checksum'} ne sha256($buffer)
222 0 0 if substr($buffer, 0, 32, '') ne $$head{'start_bytes'}
225 0 0 if ($$head{'compression'} || '') eq '1'
226 0 0 if $$self{'keep_xml'} or $$head{'keep_xml'}
230 0 0 if ($id)
232 0 0 if $id eq "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
233 0 0 if $id =~ /^\d{16}$/
239 0 0 'false' eq lc $_[0] ? :
0 0 'true' eq lc $_[0] ? :
0 0 !defined($_[0]) ? :
252 0 0 if $META
257 0 0 if $key eq 'Binaries'
259 0 0 $copy =~ /_changed$/i ? :
263 0 0 if $$META{'header_hash'} and $$head{'raw'} and $$META{'header_hash'} ne $self->encode_base64(sha256($$head{'raw'}))
268 0 0 if ($parent_tag eq 'Binaries') { }
0 0 elsif ($parent_tag eq 'Entry') { }
270 0 0 unless defined $content
271 0 0 if length $content
272 0 0 if ($comp and $comp eq 'True' and length $content)
273 0 0 unless eval { do { $content = $self->decompress($content) } }
275 0 0 if exists $BIN{$id}
279 0 0 unless defined $key
280 0 0 if $$parent{'__binary__'}{$key}
286 0 0 unless $$node{'Item'}
313 0 0 if ($parent_tag eq 'Group') { }
322 0 0 unless $$node{'String'}
324 0 0 $$s{'Key'} =~ /^(Password|UserName|URL|Notes|Title)$/i ? :
0 0 if $$s{'__protected__'}
326 0 0 $$node{'AutoType'}{'DataTransferObfuscation'} ? :
351 0 0 if defined $$node{'History'}
352 0 0 if defined $$node{'CustomIconUUID'}
353 0 0 if scalar keys %str
354 0 0 if $$node{'__binary__'}
360 0 0 if (ref $val eq 'HASH' and $$val{'Protected'} and $$val{'Protected'} eq 'True')
362 0 0 defined $val && length $val ? :
380 0 0 if $GROUPS[0] and $$node{'UUID'} and $$node{'DeletionTime'}
389 0 0 unless $$g{'groups'}
391 0 0 unless $$g{'entries'}
0 0 if @GROUPS == 1 and $g and $$g{'notes'} and $$g{'notes'} eq 'Added as a top group by File::KeePass' and @{[] unless $$g{'groups'};} and not @{[] unless $$g{'entries'};} and not $$g{'auto_type_default'}
406 0 189 if $pos >= length $buffer
410 0 189 if $pos + $size > length $buffer
412 21 168 if ($type == 1) { }
21 147 elsif ($type == 2) { }
21 126 elsif ($type == 3) { }
21 105 elsif ($type == 4) { }
21 84 elsif ($type == 5) { }
21 63 elsif ($type == 6) { }
21 42 elsif ($type == 7) { }
21 21 elsif ($type == 8) { }
21 0 elsif ($type == 65535) { }
433 3 18 if (@gref > $level + 1) { }
8 10 elsif (@gref < $level + 1) { }
456 0 150 if $pos >= length $buffer
460 0 150 if $pos + $size > length $buffer
462 10 140 if ($type == 1) { }
10 130 elsif ($type == 2) { }
10 120 elsif ($type == 3) { }
10 110 elsif ($type == 4) { }
10 100 elsif ($type == 5) { }
10 90 elsif ($type == 6) { }
10 80 elsif ($type == 7) { }
10 70 elsif ($type == 8) { }
10 60 elsif ($type == 9) { }
10 50 elsif ($type == 10) { }
10 40 elsif ($type == 11) { }
10 30 elsif ($type == 12) { }
10 20 elsif ($type == 13) { }
10 10 elsif ($type == 14) { }
10 0 elsif ($type == 65535) { }
495 0 10 unless ($ref)
497 0 0 unless ($$gmap{$gid})
503 3 7 if ($$entry{'comment'} and $$entry{'comment'} eq 'KPX_GROUP_TREE_STATE')
504 0 3 if (not defined $$entry{'binary'} or length $$entry{'binary'} < 4) { }
508 0 3 if ($n * 5 != length($$entry{'binary'}) - 4) { }
535 3 10 if (ref $$e{'binary'} eq 'HASH')
541 2 8 if (defined $bin and length $bin or defined $bname and length $bname)
549 0 13 if ref $$e{'auto_type'} eq 'HASH'
550 1 12 if (ref $$e{'auto_type'} eq 'ARRAY')
557 1 11 if (defined $key and length $key or defined $win and length $win)
560 8 4 unless $$e{'comment'}
566 4 0 exists $atk{$n} ? :
570 3 0 exists $atw{$n} ? :
572 0 8 unless defined $$_{'window'}
0 8 unless defined $$_{'keys'}
575 2 2 if @AT
592 0 0 $date && $date =~ /$qr_date/ ? :
598 0 13 if ref $pass eq 'ARRAY'
599 13 0 if defined $pass and length $pass
600 0 13 if ($file)
601 0 0 ref $file ? :
602 0 0 if (length $file == 64) { }
0 0 elsif (length $file != 32) { }
609 13 0 $pass ? :
0 13 $pass && $file ? :
0 13 $$head{'version'} && $$head{'version'} eq '2' ? :
0 13 !($pass || $file) ? :
612 0 4 $$head{'version'} && $$head{'version'} eq '2' ? :
629 0 9 if exists $$head{'keep_xml'}
635 9 0 if ($reuse)
640 0 9 if $reuse and $reuse < 0
642 2 7 unless defined $pass
643 0 7 if $self->is_locked($groups)
645 7 0 unless $$self{'no_srand'}
646 0 7 if ($v eq '2') { }
655 0 7 if ($$head{'sig2'} and $$head{'sig2'} eq 3041655655)
656 0 0 if $$head{'seed_rand'} and length $$head{'seed_rand'} == 32
665 0 0 /^([a-f0-9]{16})/i ? :
23 0 /^\d+$/ && $_ < 4294967296 ? :
674 4 3 if (grep {$$_{'expanded'};} @g)
676 4 4 $$_{'expanded'} ? :
699 0 0 if /^\d+$/
700 23 0 unless $$g{'unknown'}
702 14 9 unless $$g{'entries'}
705 0 13 if (ref $bins ne 'HASH')
707 0 13 if @bkeys > 1
708 5 8 @bkeys ? :
709 8 5 unless defined $bin
711 0 13 if (ref $at ne 'ARRAY')
714 6 0 defined $_ ? :
715 2 1 unless grep {$_ eq $k;} @AT
720 1 1 $i > 1 ? :
721 1 2 $i > 1 ? :
723 13 0 defined $$e{'comment'} ? :
739 0 0 if /^\d+$/
740 13 0 unless $$e{'unknown'}
766 0 7 if length $header != 124
772 0 144 unless $date
773 144 0 $date =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$/ ? :
785 0 0 if ($$head{'sig2'} and $$head{'sig2'} eq 3041655653)
786 0 0 if $$head{'seed_rand'} and length $$head{'seed_rand'} == 16
788 0 0 unless defined $$head{'compression'}
795 0 0 !$_[0] ? :
0 0 !(defined $_[0] || $_[1]) ? :
797 0 0 defined $_[0] && $_[0] eq '0' ? :
810 0 0 if not defined $$META{$k} or $r and not $$META{$k} =~ /$r/
811 0 0 if $k =~ /Changed$/
832 0 0 exists $$META{'RecycleBinEnabled'} ? :
837 0 0 exists $$META{$key} ? :
0 0 (exists $$META{$key} ? delete $$META{$key} : $key eq 'protect_password') ? :
840 0 0 if ref $cd eq 'HASH' and scalar keys %$cd
857 0 0 exists $$e{'auto_type_enabled'} ? :
0 0 $$e{'auto_type_munge'} ? :
881 0 0 unless $$e{'strings'}
882 0 0 $key =~ /^(Password|Title|URL|UserName)$/ ? :
0 0 $key eq 'Notes' ? :
883 0 0 unless defined $val
888 0 0 $key =~ /^(Password|UserName|URL|Notes|Title)$/ ? :
0 0 if (($$META{'MemoryProtection'}{"Protect$key"} || '') eq 'True' or $$e{'protected'}{$key =~ /^(Password|UserName|URL|Notes|Title)$/ ? lc $key : $key})
891 0 0 if length $$s{'Value'}{'content'}
894 0 0 unless $$e{'auto_type'}
900 0 0 if ref $bin ne 'HASH'
901 0 0 if scalar keys %$bin
903 0 0 defined $$bin{$key} ? :
908 0 0 length $$b{'content'} < 100 || $$self{'no_binary_compress'} ? :
909 0 0 if ($$b{'Compressed'} eq 'True')
910 0 0 unless eval { do { $$b{'content'} = $self->compress($$b{'content'}) } }
915 0 0 unless $$e{'history'}
922 0 0 if ref $group ne 'HASH'
923 0 0 exists $$group{'auto_type_enabled'} ? :
0 0 exists $$group{'enable_searching'} ? :
945 0 0 if $$group{'custom_icon_uuid'}
946 0 0 unless $$group{'entries'}
0 0 if @{[] unless $$group{'entries'};}
947 0 0 unless $$group{'entries'}
950 0 0 unless $$group{'groups'}
0 0 if @{[] unless $$group{'groups'};}
951 0 0 unless $$group{'groups'}
953 0 0 if @$groups > 1
956 0 0 if (@$groups and $$groups[0]{'deleted_objects'})
982 0 0 if $$self{'keep_xml'} or $$head{'keep_xml'}
984 0 0 if $$head{'compression'} eq '1'
994 0 0 if not $date or $date =~ /^\d+$/
995 0 0 $date =~ /$qr_date/ ? :
1004 0 0 unless defined $$head{'comment'}
1005 0 0 !defined($$head{'compression'}) || $$head{'compression'} eq '1' ? :
1008 0 0 unless $$head{'start_bytes'}
1010 0 0 if length $$head{'enc_iv'} != 16
1015 0 0 if defined $$head{'comment'} and length $$head{'comment'}
1017 0 0 $$head{'compression'} ? :
1033 0 1 unless open my $fh, '<', $file
1038 0 1 if length $buffer != $size
1069 0 0 if ($size == 0)
1070 0 0 if $hash ne "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
1075 0 0 if $hash ne sha256($chunk)
1100 0 0 unless eval { do { require Compress::Raw::Zlib } }
1102 0 0 if $status != Compress::Raw::Zlib::Z_OK()
1104 0 0 if $status != Compress::Raw::Zlib::Z_STREAM_END()
1110 0 0 unless eval { do { require Compress::Raw::Zlib } }
1112 0 0 if $status != Compress::Raw::Zlib::Z_OK()
1114 0 0 if $status != Compress::Raw::Zlib::Z_OK()
1116 0 0 if $status != Compress::Raw::Zlib::Z_OK()
1122 0 0 unless eval { do { require MIME::Base64 } }
1128 0 4 unless eval { do { require MIME::Base64 } }
1135 0 0 unless eval { do { require XML::Parser } }
1146 0 0 unless defined $top
1147 0 0 if ($tag eq $top) { }
0 0 elsif (exists $$prev_ptr{$tag} or $$force_array{$tag} and $$prev_ptr{$tag} ||= []) { }
1148 0 0 if $ptr or $data
1151 0 0 if 'ARRAY' ne ref $$prev_ptr{$tag}
1157 0 0 if $_ = $$s_handlers{$tag} || $$s_handlers{'__any__'}
1164 0 0 if $tag ne delete $$cur_ptr{'__tag__'}
1166 0 0 if (not $n_keys) { }
0 0 elsif (exists $$cur_ptr{'content'}) { }
1169 0 0 if ($n_keys == 1) { }
0 0 elsif (not $$cur_ptr{'content'} =~ /\S/) { }
1170 0 0 if ($$ptr{$tag} eq 'ARRAY') { }
1179 0 0 if $_ = $$e_handlers{$tag} || $$e_handlers{'__any__'}
1181 0 0 if (defined $$ptr{'content'}) { }
1189 0 0 $$args{'indent'} eq '1' ? :
0 0 !$$args{'indent'} ? :
1193 0 0 if $xml and $indent
1201 0 0 unless exists $$ref{$key}
1202 0 0 ref $$ref{$key} eq 'ARRAY' ? :
1204 0 0 if $indent
1205 0 0 unless (ref $node)
1206 0 0 !(defined $node && length $node) ? :
1209 0 0 if ($$node{'__attr__'} or exists $$node{'content'}) { }
1210 0 0 unless $$node{'__attr__'}
1214 0 0 if (exists $$node{'content'})
1215 0 0 if (defined $$node{'content'} and length $$node{'content'}) { }
1222 0 0 if (&$rec($node, $key)) { }
1223 0 0 if $indent
1234 0 0 if $indent
1236 0 0 if $indent and not $$args{'no_trailing_newline'}
1243 0 0 unless defined $_
1254 3 16 unless defined $id and length $id
1256 0 19 if (length $id != 16)
1257 0 0 if not $id =~ /^\d+$/ or $id > 4294967295
1258 0 0 if $id ne '0'
1272 0 0 if /^(group_(.+))$/
1275 3 29 $$g{'expanded'} ? :
1287 11 10 if (defined $parent_group)
1288 1 10 unless ref $parent_group
1289 11 0 if $parent_group
1304 0 265 unless $args
1305 1 67 unless defined $$args{$key}
1306 67 0 $key =~ / ^ (\w+) \s* (|!|=|!~|=~|gt|lt) $ /x ? :
1307 89 0 if defined $_[0]{$field}
1308 2 0 unless not defined $_[0]{$field}
1309 2 0 if defined $_[0]{$field}
1311 4 0 if defined $_[0]{$field}
1312 2 0 if defined $_[0]{$field}
1313 2 0 $op eq 'lt' ? :
3 2 $op eq 'gt' ? :
2 5 $op eq '!~' ? :
2 7 $op eq '=~' ? :
2 9 $op eq '!' ? :
56 11 !$op || $op eq '=' ? :
1326 2 257 unless defined $$g{'title'}
1328 0 259 if ($$self{'force_v2_gid'}) { }
1334 234 25 unless (@tests and grep {not &$_($g);} @tests)
1336 7 227 if $$self{'__group_groups'}
1338 86 173 if $$g{'groups'}
1345 6 16 if wantarray
1347 1 21 if @g > 1
1348 5 16 wantarray ? :
1354 0 4 unless $g and $c
1356 4 4 if $$c[$i] ne $g
1368 0 6 if $self->is_locked($groups)
1371 0 6 unless (ref $group)
1377 3 5 unless $$g{'entries'}
1394 1 57 if $$args{'active'}
1398 56 45 unless $$g{'entries'}
1401 27 16 unless (@tests and grep {not &$_($e);} @tests)
1403 5 22 if $$self{'__entry_groups'}
1412 4 6 if wantarray
1414 1 9 if @e > 1
1415 3 6 wantarray ? :
1421 0 1 unless $e and $g
1422 0 1 unless $$g{'entries'}
1423 0 1 if $$g{'entries'}[$i] ne $e
1436 26 0 unless (shift())->{'default_exp'}
1443 2 15 $locker{"$groups"} ? :
1449 0 5 if $locker{"$groups"}
1456 0 6 unless defined $pass
1466 8 5 unless $locker{"$groups"}
1470 4 0 if $pass
1471 0 4 unless defined $pass
1483 0 1 unless ref $entry
1484 0 1 unless $entry
1486 1 0 if $pass
1487 0 1 unless defined $pass
1515 0 0 if (32 == length $key) { }
0 0 elsif (16 == length $key) { }
1524 0 0 if length $iv != 8
1525 0 0 unless grep {$rounds != $_;} 8, 12, 20
1578 0 0 if $state[8] == 0
1584 0 0 unless exists $$args{'data'}
1585 0 0 defined $$args{'data'} ? :