| 1 | package File::KDBX::Loader::KDB; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Read KDB files | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Encode qw(encode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use File::KDBX::Constants qw(:header :cipher :random_stream :icon); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use File::KDBX::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use File::KDBX::Util qw(:class :empty :io :uuid load_optional); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use File::KDBX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Ref::Util qw(is_arrayref is_hashref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Scalar::Util qw(looks_like_number); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Time::Piece 1.33; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 2 | extends 'File::KDBX::Loader'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | our $VERSION = '0.905'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | my $DEFAULT_EXPIRATION = Time::Piece->strptime('2999-12-31 23:59:59', '%Y-%m-%d %H:%M:%S'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub _read_headers { '' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_headers: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | sub _read_body { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_body: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $fh = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $buf = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | load_optional('File::KeePass'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $buf .= do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $key = $self->kdbx->composite_key($key, keep_primitive => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $k = eval { File::KeePass->new->parse_db(\$buf, _convert_kdbx_to_keepass_master_key($key)) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | throw 'Failed to parse KDB file', error => $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | $k->unlock; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | $self->kdbx->key($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | return convert_keepass_to_kdbx($k, $self->kdbx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # This is also used by File::KDBX::Dumper::KDB. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | sub _convert_kdbx_to_keepass_master_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my $key = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_kdbx_to_keepass_master_key: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my @keys = @{$key->keys}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if (@keys == 1 && !$keys[0]->can('filepath')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
@keys == 1 and not $keys[0]->can("filepath")
MC/DC0%0/2
@keys == 1 and not $keys[0]->can("filepath")
@keys == 1
not $keys[0]->can("filepath")
Truth table0%0/3
A and not(B)
A= @keys == 1B= not $keys[0]->can("filepath")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | return [encode('CP-1252', $keys[0]->{primitive})]; # just a password | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | elsif (@keys == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return [undef, \$keys[0]->raw_key]; # just a keyfile | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | ▶ | elsif (@keys == 2 && !$keys[0]->can('filepath') && $keys[1]->can('filepath')) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
@keys == 2 and not $keys[0]->can("filepath") and $keys[1]->can("filepath")
@keys == 2 and not $keys[0]->can("filepath")
MC/DC0%0/3
@keys == 2 and not $keys[0]->can("filepath") and $keys[1]->can("filepath")
@keys == 2
not $keys[0]->can("filepath")
$keys[1]->can("filepath")
Truth table0%0/4
A and not(B) and C
A= @keys == 2B= not $keys[0]->can("filepath")C= $keys[1]->can("filepath")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | return [encode('CP-1252', $keys[0]->{primitive}), \$keys[1]->raw_key]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | throw 'Cannot use this key to load a KDB file', key => $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | sub convert_keepass_to_kdbx { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my $k = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
convert_keepass_to_kdbx: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | my $kdbx = shift // File::KDBX->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
shift() // "File::KDBX"->new
MC/DC0%0/2
shift() // "File::KDBX"->new
shift()
"File::KDBX"->new
Truth table0%0/3
A // B
A= shift()B= "File::KDBX"->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | $kdbx->{headers} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$kdbx->{"headers"} //= {}
MC/DC0%0/1
$kdbx->{"headers"} //= {}
$kdbx->{"headers"}
Truth table0%0/2
A
A= $kdbx->{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | _convert_keepass_to_kdbx_headers($k->{header}, $kdbx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | my @groups = @{$k->{groups} || []}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if (@groups == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $kdbx->{root} = _convert_keepass_to_kdbx_group($k->{groups}[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | elsif (1 < @groups) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $root = $kdbx->{root} = {%{File::KDBX->_implicit_root}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | for my $group (@groups) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | push @{$root->{groups} //= []}, _convert_keepass_to_kdbx_group($group); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$root->{"groups"} //= []
MC/DC0%0/1
$root->{"groups"} //= []
$root->{"groups"}
Truth table0%0/2
A
A= $root->{"groups"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | $kdbx->entries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ->grep({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | title => 'Meta-Info', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | username => 'SYSTEM', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | url => '$', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | icon_id => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | -nonempty => 'notes', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ->each(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | _read_meta_stream($kdbx, $_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $_->remove(signal => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return $kdbx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | sub _read_meta_stream { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | my $kdbx = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_meta_stream: not called CC=23 SCAR=63.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $entry = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $type = $entry->notes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $data = $entry->binary_value('bin-stream'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | open(my $fh, '<', \$data) or throw "Failed to open memory buffer for reading: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ($type eq 'KPX_GROUP_TREE_STATE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | read_all $fh, my $buf, 4 or goto PARSE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | my ($num) = unpack('L<', $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | $num * 5 + 4 == length($data) or goto PARSE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | for (my $i = 0; $i < $num; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | read_all $fh, $buf, 5 or goto PARSE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | my ($group_id, $expanded) = unpack('L< C', $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | my $uuid = _decode_uuid($group_id) // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_decode_uuid($group_id) // (next)
MC/DC0%0/1
_decode_uuid($group_id) // (next)
_decode_uuid($group_id)
Truth table0%0/2
A
A= _decode_uuid($group_id)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $group = $kdbx->groups->grep({uuid => $uuid})->next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $group->is_expanded($expanded) if $group; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | elsif ($type eq 'KPX_CUSTOM_ICONS_4') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | read_all $fh, my $buf, 12 or goto PARSE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my ($num_icons, $num_entries, $num_groups) = unpack('L<3', $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my @icons; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | for (my $i = 0; $i < $num_icons; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | read_all $fh, $buf, 4 or goto PARSE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my ($icon_size) = unpack('L<', $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | read_all $fh, $buf, $icon_size or goto PARSE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $uuid = $kdbx->add_custom_icon($buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | push @icons, $uuid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | for (my $i = 0; $i < $num_entries; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | read_all $fh, $buf, 20 or goto PARSE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | my ($uuid, $icon_index) = unpack('a16 L<', $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | next if !$icons[$icon_index]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my $entry = $kdbx->entries->grep({uuid => $uuid})->next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | $entry->custom_icon_uuid($icons[$icon_index]) if $entry; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | for (my $i = 0; $i < $num_groups; ++$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | read_all $fh, $buf, 8 or goto PARSE_ERROR; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my ($group_id, $icon_index) = unpack('L<2', $buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | next if !$icons[$icon_index]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | my $uuid = _decode_uuid($group_id) // next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
_decode_uuid($group_id) // (next)
MC/DC0%0/1
_decode_uuid($group_id) // (next)
_decode_uuid($group_id)
Truth table0%0/2
A
A= _decode_uuid($group_id)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $group = $kdbx->groups->grep({uuid => $uuid})->next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $group->custom_icon_uuid($icons[$icon_index]) if $group; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | alert "Ignoring unknown meta stream: $type\n", type => $type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | PARSE_ERROR: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | alert "Ignoring unparsable meta stream: $type\n", type => $type; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub _convert_keepass_to_kdbx_headers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | my $from = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_keepass_to_kdbx_headers: not called CC=20 SCAR=60.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my $kdbx = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | my $headers = $kdbx->{headers} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$kdbx->{"headers"} //= {}
MC/DC0%0/1
$kdbx->{"headers"} //= {}
$kdbx->{"headers"}
Truth table0%0/2
A
A= $kdbx->{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | my $meta = $kdbx->{meta} //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$kdbx->{"meta"} //= {}
MC/DC0%0/1
$kdbx->{"meta"} //= {}
$kdbx->{"meta"}
Truth table0%0/2
A
A= $kdbx->{"meta"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $kdbx->{sig1} = $from->{sig1}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $kdbx->{sig2} = $from->{sig2}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $kdbx->{version} = $from->{vers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my %enc_type = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | rijndael => CIPHER_UUID_AES256, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | aes => CIPHER_UUID_AES256, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | twofish => CIPHER_UUID_TWOFISH, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | chacha20 => CIPHER_UUID_CHACHA20, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | salsa20 => CIPHER_UUID_SALSA20, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | serpent => CIPHER_UUID_SERPENT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | my $cipher_uuid = $enc_type{$from->{cipher} || ''} // $enc_type{$from->{enc_type} || ''}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/7
$enc_type{$from->{"cipher"} or ""} // $enc_type{$from->{"enc_type"} or ""}
$from->{'cipher'} || ''
$from->{'enc_type'} || ''
MC/DC0%0/2
$enc_type{$from->{"cipher"} or ""} // $enc_type{$from->{"enc_type"} or ""}
$enc_type{$from->{"cipher"} or ""}
$enc_type{$from->{"enc_type"} or ""}
MC/DC0%0/1
$from->{'cipher'} || ''
$from->{'cipher'}
MC/DC0%0/1
$from->{'enc_type'} || ''
$from->{'enc_type'}
Truth table0%0/3
A // B
A= $enc_type{$from->{"cipher"} or ""}B= $enc_type{$from->{"enc_type"} or ""}
Truth table0%0/2
A
A= $from->{'cipher'}
Truth table0%0/2
A
A= $from->{'enc_type'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my %protected_stream = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | rc4 => STREAM_ID_RC4_VARIANT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | salsa20 => STREAM_ID_SALSA20, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | chacha20 => STREAM_ID_CHACHA20, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | my $protected_stream_id = $protected_stream{$from->{protected_stream} || ''} || STREAM_ID_SALSA20; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$protected_stream{$from->{'protected_stream'} or ''} || 2
$from->{'protected_stream'} || ''
MC/DC0%0/1
$protected_stream{$from->{'protected_stream'} or ''} || 2
$protected_stream{$from->{'protected_stream'} or ''}
MC/DC0%0/1
$from->{'protected_stream'} || ''
$from->{'protected_stream'}
Truth table0%0/2
A
A= $protected_stream{$from->{'protected_stream'} or ''}
Truth table0%0/2
A
A= $from->{'protected_stream'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $headers->{+HEADER_COMMENT} = $from->{comment}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | $headers->{+HEADER_CIPHER_ID} = $cipher_uuid if $cipher_uuid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $headers->{+HEADER_MASTER_SEED} = $from->{seed_rand}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | $headers->{+HEADER_COMPRESSION_FLAGS} = $from->{compression} // 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"compression"} // 0
MC/DC0%0/1
$from->{"compression"} // 0
$from->{"compression"}
Truth table0%0/2
A
A= $from->{"compression"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $headers->{+HEADER_TRANSFORM_SEED} = $from->{seed_key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $headers->{+HEADER_TRANSFORM_ROUNDS} = $from->{rounds}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $headers->{+HEADER_ENCRYPTION_IV} = $from->{enc_iv}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $headers->{+HEADER_INNER_RANDOM_STREAM_ID} = $protected_stream_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $headers->{+HEADER_INNER_RANDOM_STREAM_KEY} = $from->{protected_stream_key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | $headers->{+HEADER_STREAM_START_BYTES} = $from->{start_bytes} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"start_bytes"} // ""
MC/DC0%0/1
$from->{"start_bytes"} // ""
$from->{"start_bytes"}
Truth table0%0/2
A
A= $from->{"start_bytes"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # TODO for KeePass 1 files these are all not available. Leave undefined or set default values? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $meta->{memory_protection}{protect_notes} = boolean($from->{protect_notes}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $meta->{memory_protection}{protect_password} = boolean($from->{protect_password}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $meta->{memory_protection}{protect_username} = boolean($from->{protect_username}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $meta->{memory_protection}{protect_url} = boolean($from->{protect_url}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | $meta->{memory_protection}{protect_title} = boolean($from->{protect_title}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | $meta->{generator} = $from->{generator} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"generator"} // ""
MC/DC0%0/1
$from->{"generator"} // ""
$from->{"generator"}
Truth table0%0/2
A
A= $from->{"generator"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $meta->{header_hash} = $from->{header_hash}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | $meta->{database_name} = $from->{database_name} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"database_name"} // ""
MC/DC0%0/1
$from->{"database_name"} // ""
$from->{"database_name"}
Truth table0%0/2
A
A= $from->{"database_name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $meta->{database_name_changed} = _decode_datetime($from->{database_name_changed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $meta->{database_description} = $from->{database_description} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"database_description"} // ""
MC/DC0%0/1
$from->{"database_description"} // ""
$from->{"database_description"}
Truth table0%0/2
A
A= $from->{"database_description"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $meta->{database_description_changed} = _decode_datetime($from->{database_description_changed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | $meta->{default_username} = $from->{default_user_name} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"default_user_name"} // ""
MC/DC0%0/1
$from->{"default_user_name"} // ""
$from->{"default_user_name"}
Truth table0%0/2
A
A= $from->{"default_user_name"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $meta->{default_username_changed} = _decode_datetime($from->{default_user_name_changed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | $meta->{maintenance_history_days} = $from->{maintenance_history_days}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $meta->{color} = $from->{color}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $meta->{master_key_changed} = _decode_datetime($from->{master_key_changed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $meta->{master_key_change_rec} = $from->{master_key_change_rec}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $meta->{master_key_change_force} = $from->{master_key_change_force}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $meta->{recycle_bin_enabled} = boolean($from->{recycle_bin_enabled}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $meta->{recycle_bin_uuid} = $from->{recycle_bin_uuid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $meta->{recycle_bin_changed} = _decode_datetime($from->{recycle_bin_changed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $meta->{entry_templates_group} = $from->{entry_templates_group}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $meta->{entry_templates_group_changed} = _decode_datetime($from->{entry_templates_group_changed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $meta->{last_selected_group} = $from->{last_selected_group}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $meta->{last_top_visible_group} = $from->{last_top_visible_group}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $meta->{history_max_items} = $from->{history_max_items}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $meta->{history_max_size} = $from->{history_max_size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $meta->{settings_changed} = _decode_datetime($from->{settings_changed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | while (my ($key, $value) = each %{$from->{custom_icons} || {}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | push @{$meta->{custom_icons} //= []}, {uuid => $key, data => $value}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$meta->{"custom_icons"} //= []
MC/DC0%0/1
$meta->{"custom_icons"} //= []
$meta->{"custom_icons"}
Truth table0%0/2
A
A= $meta->{"custom_icons"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | while (my ($key, $value) = each %{$from->{custom_data} || {}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $meta->{custom_data}{$key} = {value => $value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | return $kdbx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | sub _convert_keepass_to_kdbx_group { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | my $from = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_keepass_to_kdbx_group: not called CC=13 SCAR=52.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $to = shift // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // {}
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $to->{times}{last_access_time} = _decode_datetime($from->{accessed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | $to->{times}{usage_count} = $from->{usage_count} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{'usage_count'} || 0
MC/DC0%0/1
$from->{'usage_count'} || 0
$from->{'usage_count'}
Truth table0%0/2
A
A= $from->{'usage_count'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $to->{times}{expiry_time} = _decode_datetime($from->{expires}, $DEFAULT_EXPIRATION); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | $to->{times}{expires} = defined $from->{expires_enabled} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ? boolean($from->{expires_enabled}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | : boolean($to->{times}{expiry_time} <= gmtime); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $to->{times}{creation_time} = _decode_datetime($from->{created}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $to->{times}{last_modification_time} = _decode_datetime($from->{modified}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $to->{times}{location_changed} = _decode_datetime($from->{location_changed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | $to->{notes} = $from->{notes} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"notes"} // ""
MC/DC0%0/1
$from->{"notes"} // ""
$from->{"notes"}
Truth table0%0/2
A
A= $from->{"notes"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $to->{uuid} = _decode_uuid($from->{id}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $to->{is_expanded} = boolean($from->{expanded}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | $to->{icon_id} = $from->{icon} // ICON_FOLDER; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"icon"} // "Folder"
MC/DC0%0/1
$from->{"icon"} // "Folder"
$from->{"icon"}
Truth table0%0/2
A
A= $from->{"icon"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | $to->{name} = $from->{title} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"title"} // ""
MC/DC0%0/1
$from->{"title"} // ""
$from->{"title"}
Truth table0%0/2
A
A= $from->{"title"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | $to->{default_auto_type_sequence} = $from->{auto_type_default} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"auto_type_default"} // ""
MC/DC0%0/1
$from->{"auto_type_default"} // ""
$from->{"auto_type_default"}
Truth table0%0/2
A
A= $from->{"auto_type_default"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $to->{enable_auto_type} = _decode_tristate($from->{auto_type_enabled}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | $to->{enable_searching} = _decode_tristate($from->{enable_searching}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $to->{groups} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $to->{entries} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if (!$args{shallow}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | for my $group (@{$from->{groups} || []}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | push @{$to->{groups}}, _convert_keepass_to_kdbx_group($group); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | for my $entry (@{$from->{entries} || []}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | push @{$to->{entries}}, _convert_keepass_to_kdbx_entry($entry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | return $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | sub _convert_keepass_to_kdbx_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | my $from = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_keepass_to_kdbx_entry: not called CC=40 SCAR=74.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | my $to = shift // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() // {}
MC/DC0%0/1
shift() // {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $to->{times}{last_access_time} = _decode_datetime($from->{accessed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | $to->{times}{usage_count} = $from->{usage_count} || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{'usage_count'} || 0
MC/DC0%0/1
$from->{'usage_count'} || 0
$from->{'usage_count'}
Truth table0%0/2
A
A= $from->{'usage_count'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | $to->{times}{expiry_time} = _decode_datetime($from->{expires}, $DEFAULT_EXPIRATION); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | $to->{times}{expires} = defined $from->{expires_enabled} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | ? boolean($from->{expires_enabled}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | : boolean($to->{times}{expiry_time} <= gmtime); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $to->{times}{creation_time} = _decode_datetime($from->{created}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | $to->{times}{last_modification_time} = _decode_datetime($from->{modified}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $to->{times}{location_changed} = _decode_datetime($from->{location_changed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | $to->{auto_type}{data_transfer_obfuscation} = $from->{auto_type_munge} || false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$from->{'auto_type_munge'} || &false()
MC/DC0%0/2
$from->{'auto_type_munge'} || &false()
$from->{'auto_type_munge'}
&false()
Truth table0%0/3
A || B
A= $from->{'auto_type_munge'}B= &false()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | $to->{auto_type}{enabled} = boolean($from->{auto_type_enabled} // 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"auto_type_enabled"} // 1
MC/DC0%0/1
$from->{"auto_type_enabled"} // 1
$from->{"auto_type_enabled"}
Truth table0%0/2
A
A= $from->{"auto_type_enabled"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | my $comment = $from->{comment}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | my @auto_type = is_arrayref($from->{auto_type}) ? @{$from->{auto_type}} : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if (!@auto_type && nonempty $from->{auto_type} && nonempty $from->{auto_type_window} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
not @auto_type and nonempty($from->{"auto_type"} && nonempty($from->{"auto_type_window"} && !Ref::Util::XS::is_hashref($from->{"auto_type"})))
$from->{'auto_type'} && nonempty($from->{'auto_type_window'} && !Ref::Util::XS::is_hashref($from->{'auto_type'}))
$from->{'auto_type_window'} && !Ref::Util::XS::is_hashref($from->{'auto_type'})
MC/DC0%0/2
not @auto_type and nonempty($from->{"auto_type"} && nonempty($from->{"auto_type_window"} && !Ref::Util::XS::is_hashref($from->{"auto_type"})))
not @auto_type
nonempty($from->{"auto_type"} && nonempty($from->{"auto_type_window"} && !Ref::Util::XS::is_hashref($from->{"auto_type"})))
MC/DC0%0/2
$from->{'auto_type'} && nonempty($from->{'auto_type_window'} && !Ref::Util::XS::is_hashref($from->{'auto_type'}))
$from->{'auto_type'}
nonempty($from->{'auto_type_window'} && !Ref::Util::XS::is_hashref($from->{'auto_type'}))
MC/DC0%0/2
$from->{'auto_type_window'} && !Ref::Util::XS::is_hashref($from->{'auto_type'})
$from->{'auto_type_window'}
!Ref::Util::XS::is_hashref($from->{'auto_type'})
Truth table0%0/3
not(A) and B
A= not @auto_typeB= nonempty($from->{"auto_type"} && nonempty($from->{"auto_type_window"} && !Ref::Util::XS::is_hashref($from->{"auto_type"})))
Truth table0%0/3
A && B
A= $from->{'auto_type'}B= nonempty($from->{'auto_type_window'} && !Ref::Util::XS::is_hashref($from->{'auto_type'}))
Truth table0%0/3
A && not(B)
A= $from->{'auto_type_window'}B= !Ref::Util::XS::is_hashref($from->{'auto_type'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | && !is_hashref($from->{auto_type})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | @auto_type = ({window => $from->{auto_type_window}, keys => $from->{auto_type}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | if (nonempty $comment) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my @AT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my %atw = my @atw = $comment =~ m{ ^Auto-Type-Window((?:-?\d+)?): [\t ]* (.*?) [\t ]*$ }mxg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my %atk = my @atk = $comment =~ m{ ^Auto-Type((?:-?\d+)?): [\t ]* (.*?) [\t ]*$ }mxg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $comment =~ s{ ^Auto-Type(?:-Window)?(?:-?\d+)?: .* \n? }{}mxg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | while (@atw) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my ($n, $w) = (shift(@atw), shift(@atw)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | push @AT, {window => $w, keys => exists($atk{$n}) ? $atk{$n} : $atk{''}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | while (@atk) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my ($n, $k) = (shift(@atk), shift(@atk)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | push @AT, {keys => $k, window => exists($atw{$n}) ? $atw{$n} : $atw{''}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | for (@AT) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $_->{'window'} //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->{"window"} //= ""
MC/DC0%0/1
$_->{"window"} //= ""
$_->{"window"}
Truth table0%0/2
A
A= $_->{"window"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | $_->{'keys'} //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$_->{"keys"} //= ""
MC/DC0%0/1
$_->{"keys"} //= ""
$_->{"keys"}
Truth table0%0/2
A
A= $_->{"keys"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | my %uniq; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | @AT = grep {!$uniq{"$_->{'window'}\e$_->{'keys'}"}++} @AT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | push @auto_type, @AT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | $to->{auto_type}{associations} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | map { +{window => $_->{window}, keystroke_sequence => $_->{keys}} } @auto_type, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $to->{strings}{Notes}{value} = $comment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $to->{strings}{UserName}{value} = $from->{username}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $to->{strings}{Password}{value} = $from->{password}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $to->{strings}{URL}{value} = $from->{url}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $to->{strings}{Title}{value} = $from->{title}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | $to->{strings}{Notes}{protect} = true if defined $from->{protected}{comment}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | $to->{strings}{UserName}{protect} = true if defined $from->{protected}{username}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | $to->{strings}{Password}{protect} = true if $from->{protected}{password} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$from->{"protected"}{"password"} // 1
MC/DC0%0/1
$from->{"protected"}{"password"} // 1
$from->{"protected"}{"password"}
Truth table0%0/2
A
A= $from->{"protected"}{"password"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | $to->{strings}{URL}{protect} = true if defined $from->{protected}{url}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | $to->{strings}{Title}{protect} = true if defined $from->{protected}{title}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # other strings | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | while (my ($key, $value) = each %{$from->{strings} || {}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | $to->{strings}{$key} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | value => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | $from->{protected}{$key} ? (protect => true) : (), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $to->{override_url} = $from->{override_url}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | $to->{tags} = $from->{tags} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"tags"} // ""
MC/DC0%0/1
$from->{"tags"} // ""
$from->{"tags"}
Truth table0%0/2
A
A= $from->{"tags"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | $to->{icon_id} = $from->{icon} // ICON_PASSWORD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"icon"} // "Password"
MC/DC0%0/1
$from->{"icon"} // "Password"
$from->{"icon"}
Truth table0%0/2
A
A= $from->{"icon"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $to->{uuid} = _decode_uuid($from->{id}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | $to->{foreground_color} = $from->{foreground_color} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"foreground_color"} // ""
MC/DC0%0/1
$from->{"foreground_color"} // ""
$from->{"foreground_color"}
Truth table0%0/2
A
A= $from->{"foreground_color"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | $to->{background_color} = $from->{background_color} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$from->{"background_color"} // ""
MC/DC0%0/1
$from->{"background_color"} // ""
$from->{"background_color"}
Truth table0%0/2
A
A= $from->{"background_color"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $to->{custom_icon_uuid} = $from->{custom_icon_uuid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $to->{history} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | local $from->{binary} = {$from->{binary_name} => $from->{binary}} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if nonempty $from->{binary} && nonempty $from->{binary_name} && !is_hashref($from->{binary}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$from->{'binary'} && nonempty($from->{'binary_name'} && !Ref::Util::XS::is_hashref($from->{'binary'}))
$from->{'binary_name'} && !Ref::Util::XS::is_hashref($from->{'binary'})
MC/DC0%0/2
$from->{'binary'} && nonempty($from->{'binary_name'} && !Ref::Util::XS::is_hashref($from->{'binary'}))
$from->{'binary'}
nonempty($from->{'binary_name'} && !Ref::Util::XS::is_hashref($from->{'binary'}))
MC/DC0%0/2
$from->{'binary_name'} && !Ref::Util::XS::is_hashref($from->{'binary'})
$from->{'binary_name'}
!Ref::Util::XS::is_hashref($from->{'binary'})
Truth table0%0/3
A && B
A= $from->{'binary'}B= nonempty($from->{'binary_name'} && !Ref::Util::XS::is_hashref($from->{'binary'}))
Truth table0%0/3
A && not(B)
A= $from->{'binary_name'}B= !Ref::Util::XS::is_hashref($from->{'binary'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | while (my ($key, $value) = each %{$from->{binary} || {}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $to->{binaries}{$key} = {value => $value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | if (!$args{shallow}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | for my $entry (@{$from->{history} || []}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $new_entry = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | push @{$to->{entries}}, _convert_keepass_to_kdbx_entry($entry, $new_entry); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | return $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | sub _decode_datetime { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | local $_ = shift // return shift // gmtime; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_datetime: not called CC=3 SCAR=24.8
Condition0%0/5
shift() // (return shift() // File::KDBX::Loader::KDB::gmtime())
shift() // File::KDBX::Loader::KDB::gmtime()
MC/DC0%0/1
shift() // (return shift() // File::KDBX::Loader::KDB::gmtime())
shift()
MC/DC0%0/2
shift() // File::KDBX::Loader::KDB::gmtime()
shift()
File::KDBX::Loader::KDB::gmtime()
Truth table0%0/2
A
A= shift()
Truth table0%0/3
A // B
A= shift()B= File::KDBX::Loader::KDB::gmtime()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | return Time::Piece->strptime($_, '%Y-%m-%d %H:%M:%S'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | sub _decode_uuid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | local $_ = shift // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_uuid: not called CC=4 SCAR=30.0
Condition0%0/2
shift() // (return)
MC/DC0%0/1
shift() // (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # Group IDs in KDB files are 32-bit integers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | return sprintf('%016x', $_) if length($_) != 16 && looks_like_number($_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
length $_ != 16 and &looks_like_number($_)
MC/DC0%0/2
length $_ != 16 and &looks_like_number($_)
length $_ != 16
&looks_like_number($_)
Truth table0%0/3
A and B
A= length $_ != 16B= &looks_like_number($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | return $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | sub _decode_tristate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | local $_ = shift // return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_tristate: not called CC=2 SCAR=17.9
Condition0%0/2
shift() // (return)
MC/DC0%0/1
shift() // (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | return boolean($_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||