KDBX.pm

filter: Statementstmt 80.4% 619 / 769 Branchbran 54.9% 221 / 402 Conditioncond 52.2% 178 / 341 MC/DCmcdc 13.3% 26 / 195 Subroutinesub 71.1% 155 / 218 Podpod 97.1% 101 / 104 totaltotal 64.0% 1300 / 2029 SCAR 83.3
CC
331
Cov
67%
custom_icon
110.0
custom_data
28.6
public_custom_data
16.5
CRAP 4152.0
« KDBX/Loader/KDB.pm ↑ Summary KDBX/Util.pm »
1 package File::KDBX;
2 # ABSTRACT: Encrypted database to store secret text and files
3  
4 25 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 25 ▶use Crypt::Digest qw(digest_data);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 25 ▶use Crypt::PRNG qw(random_bytes);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 25 ▶use Devel::GlobalDestruction;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 25 ▶use File::KDBX::Constants qw(:all :icon);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 25 ▶use File::KDBX::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 25 ▶use File::KDBX::Safe;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 25 ▶use File::KDBX::Util qw(:class :coercion :empty :search :uuid erase simple_expression_query snakify);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 25 ▶use Hash::Util::FieldHash qw(fieldhashes);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 25 ▶use List::Util qw(any first);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 25 ▶use Ref::Util qw(is_ref is_arrayref is_plain_hashref);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 25 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
19 25 ▶use Time::Piece 1.33;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 25 ▶use boolean;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 25 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 25 our $VERSION = '0.904'; # VERSION
24 25 our $WARNINGS = 1;
25  
26 25 fieldhashes \my (%SAFE, %KEYS);
27  
28  
29 sub new {
30 59 ▶ my $class = shift;
Subroutine new: called CC=5 SCAR=18.4
Pod documented
31  
32 # copy constructor
33 59 ▶ return $_[0]->clone if @_ == 1 && blessed $_[0] && $_[0]->isa($class);
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 and builtin::blessed($_[0]) and $_[0]->isa($class) 0 59 59
Condition33%2/6
@_ == 1 and builtin::blessed($_[0]) and $_[0]->isa($class)
!ll&&!rl&&r
5900
@_ == 1 and builtin::blessed($_[0])
!ll&&!rl&&r
5900
MC/DC0%0/3
@_ == 1 and builtin::blessed($_[0]) and $_[0]->isa($class)
@_ == 1 builtin::blessed($_[0]) $_[0]->isa($class)
Truth table25%1/4
A and B and C
A= @_ == 1B= builtin::blessed($_[0])C= $_[0]->isa($class)
ABCresult
0XX0
10X0
1100
1111
34  
35 59 my $self = bless {}, $class;
36 59 $self->init(@_);
37 59 ▶ $self->_set_nonlazy_attributes if empty $self;
Branch: 1 branch
BranchTrueFalseTotal
if empty($self) 59 0 59
38 59 return $self;
39 }
40  
41 60 ▶sub DESTROY { local ($., $@, $!, $^E, $?); !in_global_destruction and $_[0]->reset }
Subroutine DESTROY: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
not &in_global_destruction() and $_[0]->reset 60 0 60
42  
43  
44 sub init {
45 59 ▶ my $self = shift;
Subroutine init: called CC=1 SCAR=0.0
Pod documented
46 59 my %args = @_;
47  
48 59 @$self{keys %args} = values %args;
49  
50 59 return $self;
51 }
52  
53  
54 sub reset {
55 90 ▶ my $self = shift;
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
56 90 erase $self->headers->{+HEADER_INNER_RANDOM_STREAM_KEY};
57 90 erase $self->inner_headers->{+INNER_HEADER_INNER_RANDOM_STREAM_KEY};
58 90 erase $self->{raw};
59 90 %$self = ();
60 90 $self->_remove_safe;
61 90 return $self;
62 }
63  
64  
65 sub clone {
66 1 ▶ my $self = shift;
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
67 1 require Storable;
68 1 return Storable::dclone($self);
69 }
70  
71 sub STORABLE_freeze {
72 1 ▶ my $self = shift;
Subroutine STORABLE_freeze: called CC=3 SCAR=12.7
Pod undocumented
73 1 my $cloning = shift;
74  
75 1 my $copy = {%$self};
76  
77 1 ▶ return '', $copy, $KEYS{$self} // (), $SAFE{$self} // ();
Condition33%2/6
$KEYS{$self} // ()
l!l&&r!l&&!r
010
$SAFE{$self} // ()
l!l&&r!l&&!r
010
MC/DC0%0/2
$KEYS{$self} // ()
$KEYS{$self} ()
MC/DC0%0/2
$SAFE{$self} // ()
$SAFE{$self} ()
Truth table33%1/3
A // B
A= $KEYS{$self}B= ()
ABresult
1X1
011
000
Truth table33%1/3
A // B
A= $SAFE{$self}B= ()
ABresult
1X1
011
000
78 }
79  
80 sub STORABLE_thaw {
81 1 ▶ my $self = shift;
Subroutine STORABLE_thaw: called CC=1 SCAR=0.0
Pod undocumented
82 1 my $cloning = shift;
83 1 shift;
84 1 my $clone = shift;
85 1 my $key = shift;
86 1 my $safe = shift;
87  
88 1 @$self{keys %$clone} = values %$clone;
89 1 $KEYS{$self} = $key;
90 1 $SAFE{$self} = $safe;
91  
92 # Dualvars aren't cloned as dualvars, so coerce the compression flags.
93 1 $self->compression_flags($self->compression_flags);
94  
95 1 ▶ $self->objects(history => 1)->each(sub { $_->kdbx($self) });
Subroutine __ANON__: called CC=1 SCAR=0.0
96 }
97  
98 ##############################################################################
99  
100  
101 9 ▶sub load { shift->_loader->load(@_) }
Subroutine load: called CC=1 SCAR=0.0
Pod documented
102 21 ▶sub load_string { shift->_loader->load_string(@_) }
Subroutine load_string: called CC=1 SCAR=0.0
Pod documented
103 0 ▶sub load_file { shift->_loader->load_file(@_) }
Subroutine load_file: not called CC=1 SCAR=6.9
Pod documented
104 0 ▶sub load_handle { shift->_loader->load_handle(@_) }
Subroutine load_handle: not called CC=1 SCAR=6.9
Pod documented
105  
106 sub _loader {
107 30 ▶ my $self = shift;
Subroutine _loader: called CC=2 SCAR=7.0
108 30 ▶ $self = $self->new if !ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 30 0 30
109 30 require File::KDBX::Loader;
110 30 File::KDBX::Loader->new(kdbx => $self);
111 }
112  
113  
114 2 ▶sub dump { shift->_dumper->dump(@_) }
Subroutine dump: called CC=1 SCAR=0.0
Pod documented
115 13 ▶sub dump_string { shift->_dumper->dump_string(@_) }
Subroutine dump_string: called CC=1 SCAR=0.0
Pod documented
116 0 ▶sub dump_file { shift->_dumper->dump_file(@_) }
Subroutine dump_file: not called CC=1 SCAR=6.9
Pod documented
117 0 ▶sub dump_handle { shift->_dumper->dump_handle(@_) }
Subroutine dump_handle: not called CC=1 SCAR=6.9
Pod documented
118  
119 sub _dumper {
120 15 ▶ my $self = shift;
Subroutine _dumper: called CC=2 SCAR=7.0
121 15 ▶ $self = $self->new if !ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 15 15
122 15 require File::KDBX::Dumper;
123 15 File::KDBX::Dumper->new(kdbx => $self);
124 }
125  
126 ##############################################################################
127  
128  
129 sub user_agent_string {
130 15 ▶ require Config;
Subroutine user_agent_string: called CC=1 SCAR=0.1
Pod documented
131 sprintf('%s/%s (%s/%s; %s/%s; %s)',
132 15 ▶ __PACKAGE__, $VERSION, @Config::Config{qw(package version osname osvers archname)});
Subroutine sig1: called CC=4 SCAR=14.2
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_[0]) 0 156 156
133 156 ▶}
Subroutine sig2: called CC=4 SCAR=14.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 30 126 156
unless builtin::blessed($_[0]) 0 177 177
134 156 ▶ 
Subroutine version: called CC=4 SCAR=14.3
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 30 147 177
unless builtin::blessed($_[0]) 0 605 605
Condition66%2/3
$_[0]{"sig1"} //= $default
l!l&&r!l&&!r
97590
MC/DC0%0/2
$_[0]{"sig1"} //= $default
$_[0]{"sig1"} $default
Truth table66%2/3
A //= B
A= $_[0]{"sig1"}B= $default
ABresult
1X1
011
000
135 177 ▶has sig1 => KDBX_SIG1, coerce => \&to_number;
Subroutine headers: called CC=4 SCAR=14.3
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 38 567 605
unless builtin::blessed($_[0]) 0 1982 1982
Condition66%2/3
$_[0]{"sig2"} //= $default
l!l&&r!l&&!r
118590
MC/DC0%0/2
$_[0]{"sig2"} //= $default
$_[0]{"sig2"} $default
Truth table66%2/3
A //= B
A= $_[0]{"sig2"}B= $default
ABresult
1X1
011
000
136 605 ▶has sig2 => KDBX_SIG2_2, coerce => \&to_number;
Subroutine inner_headers: called CC=4 SCAR=14.3
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 1982 1982
unless builtin::blessed($_[0]) 0 416 416
Condition66%2/3
$_[0]{"version"} //= $default
l!l&&r!l&&!r
546590
MC/DC0%0/2
$_[0]{"version"} //= $default
$_[0]{"version"} $default
Truth table66%2/3
A //= B
A= $_[0]{"version"}B= $default
ABresult
1X1
011
000
137 1982 ▶has version => KDBX_VERSION_3_1, coerce => \&to_number;
Subroutine meta: called CC=4 SCAR=14.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 416 416
unless builtin::blessed($_[0]) 0 1870 1870
Condition100%2/2
$_[0]{"headers"} //= scalar &$default($_[0])
l!l
189389
MC/DC100%1/1
$_[0]{"headers"} //= scalar &$default($_[0])
$_[0]{"headers"}
Truth table100%2/2
A
A= $_[0]{"headers"}
Aresult
11
00
138 416 ▶has headers => {};
Subroutine binaries: called CC=4 SCAR=14.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 1870 1870
unless builtin::blessed($_[0]) 0 106 106
Condition100%2/2
$_[0]{"inner_headers"} //= scalar &$default($_[0])
l!l
32789
MC/DC100%1/1
$_[0]{"inner_headers"} //= scalar &$default($_[0])
$_[0]{"inner_headers"}
Truth table100%2/2
A
A= $_[0]{"inner_headers"}
Aresult
11
00
139 1870 ▶has inner_headers => {};
Subroutine deleted_objects: called CC=4 SCAR=13.9
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 12 94 106
unless builtin::blessed($_[0]) 0 154 154
Condition100%2/2
$_[0]{"meta"} //= scalar &$default($_[0])
l!l
179080
MC/DC100%1/1
$_[0]{"meta"} //= scalar &$default($_[0])
$_[0]{"meta"}
Truth table100%2/2
A
A= $_[0]{"meta"}
Aresult
11
00
140 106 ▶has meta => {};
Subroutine raw: called CC=4 SCAR=14.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 21 133 154
unless builtin::blessed($_[0]) 0 59 59
Condition100%2/2
$_[0]{"binaries"} //= scalar &$default($_[0])
l!l
2680
MC/DC100%1/1
$_[0]{"binaries"} //= scalar &$default($_[0])
$_[0]{"binaries"}
Truth table100%2/2
A
A= $_[0]{"binaries"}
Aresult
11
00
141 154 ▶has binaries => {};
Branch: 1 branch
BranchTrueFalseTotal
if $#_ 0 59 59
Condition100%2/2
$_[0]{"deleted_objects"} //= scalar &$default($_[0])
l!l
9559
MC/DC100%1/1
$_[0]{"deleted_objects"} //= scalar &$default($_[0])
$_[0]{"deleted_objects"}
Truth table100%2/2
A
A= $_[0]{"deleted_objects"}
Aresult
11
00
142 59 ▶has deleted_objects => {};
Condition50%1/2
$_[0]{"raw"} //= undef
l!l
059
MC/DC0%0/1
$_[0]{"raw"} //= undef
$_[0]{"raw"}
Truth table50%1/2
A
A= $_[0]{"raw"}
Aresult
11
00
143 59 ▶has raw => coerce => \&to_string;
Subroutine comment: called CC=4 SCAR=15.4
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_[0]) 0 59 59
144 59 ▶ 
Subroutine cipher_id: called CC=4 SCAR=15.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
145 59 ▶# HEADERS
Subroutine compression_flags: called CC=4 SCAR=14.7
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 61 61
Condition33%1/3
$_[0]->headers->{"comment"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->headers->{"comment"} //= $default
$_[0]->headers->{"comment"} $default
Truth table33%1/3
A //= B
A= $_[0]->headers->{"comment"}B= $default
ABresult
1X1
011
000
146 59 ▶has 'headers.comment' => '', coerce => \&to_string;
Subroutine master_seed: called CC=4 SCAR=14.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 1 60 61
unless builtin::blessed($_[0]) 0 73 73
Condition33%1/3
$_[0]->headers->{"cipher_id"} //= $default
l!l&&r!l&&!r
0590
MC/DC0%0/2
$_[0]->headers->{"cipher_id"} //= $default
$_[0]->headers->{"cipher_id"} $default
Truth table33%1/3
A //= B
A= $_[0]->headers->{"cipher_id"}B= $default
ABresult
1X1
011
000
147 61 ▶has 'headers.cipher_id' => CIPHER_UUID_CHACHA20, coerce => \&to_uuid;
Subroutine encryption_iv: called CC=4 SCAR=13.9
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 14 59 73
unless builtin::blessed($_[0]) 0 73 73
Condition66%2/3
$_[0]->headers->{"compression_flags"} //= $default
l!l&&r!l&&!r
2590
MC/DC0%0/2
$_[0]->headers->{"compression_flags"} //= $default
$_[0]->headers->{"compression_flags"} $default
Truth table66%2/3
A //= B
A= $_[0]->headers->{"compression_flags"}B= $default
ABresult
1X1
011
000
148 73 ▶has 'headers.compression_flags' => COMPRESSION_GZIP, coerce => \&to_compression_constant;
Subroutine stream_start_bytes: called CC=4 SCAR=13.9
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 14 59 73
unless builtin::blessed($_[0]) 0 73 73
Condition100%2/2
$_[0]->headers->{"master_seed"} //= scalar &$default($_[0])
l!l
1459
MC/DC100%1/1
$_[0]->headers->{"master_seed"} //= scalar &$default($_[0])
$_[0]->headers->{"master_seed"}
Truth table100%2/2
A
A= $_[0]->headers->{"master_seed"}
Aresult
11
00
149 73 ▶has 'headers.master_seed' => sub { random_bytes(32) }, coerce => \&to_string;
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if $#_ 14 59 73
Condition100%2/2
$_[0]->headers->{"encryption_iv"} //= scalar &$default($_[0])
l!l
1459
MC/DC100%1/1
$_[0]->headers->{"encryption_iv"} //= scalar &$default($_[0])
$_[0]->headers->{"encryption_iv"}
Truth table100%2/2
A
A= $_[0]->headers->{"encryption_iv"}
Aresult
11
00
150 73 ▶has 'headers.encryption_iv' => sub { random_bytes(16) }, coerce => \&to_string;
Subroutine __ANON__: called CC=1 SCAR=0.0
Condition100%2/2
$_[0]->headers->{"stream_start_bytes"} //= scalar &$default($_[0])
l!l
1459
MC/DC100%1/1
$_[0]->headers->{"stream_start_bytes"} //= scalar &$default($_[0])
$_[0]->headers->{"stream_start_bytes"}
Truth table100%2/2
A
A= $_[0]->headers->{"stream_start_bytes"}
Aresult
11
00
151 59 ▶has 'headers.stream_start_bytes' => sub { random_bytes(32) }, coerce => \&to_string;
Subroutine __ANON__: called CC=1 SCAR=0.0
152 has 'headers.kdf_parameters' => sub {
153 +{
154 KDF_PARAM_UUID() => KDF_UUID_AES,
155 265 ▶ KDF_PARAM_AES_ROUNDS() => $_[0]->headers->{+HEADER_TRANSFORM_ROUNDS} // KDF_DEFAULT_AES_ROUNDS,
Subroutine kdf_parameters: called CC=4 SCAR=14.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_[0]) 0 265 265
156 265 ▶ KDF_PARAM_AES_SEED() => $_[0]->headers->{+HEADER_TRANSFORM_SEED} // random_bytes(32),
Subroutine __ANON__: called CC=3 SCAR=12.0
Branch: 1 branch
BranchTrueFalseTotal
if $#_ 29 236 265
Condition40%2/5
$_[0]->headers->{"transform_rounds"} // 100000
l!l
059
$_[0]->headers->{"transform_seed"} // &random_bytes(32)
l!l&&r!l&&!r
0590
MC/DC0%0/1
$_[0]->headers->{"transform_rounds"} // 100000
$_[0]->headers->{"transform_rounds"}
MC/DC0%0/2
$_[0]->headers->{"transform_seed"} // &random_bytes(32)
$_[0]->headers->{"transform_seed"} &random_bytes(32)
Truth table50%1/2
A
A= $_[0]->headers->{"transform_rounds"}
Aresult
11
00
Truth table33%1/3
A // B
A= $_[0]->headers->{"transform_seed"}B= &random_bytes(32)
ABresult
1X1
011
000
157 265 ▶ };
Condition100%2/2
$_[0]->headers->{"kdf_parameters"} //= scalar &$default($_[0])
l!l
20659
MC/DC100%1/1
$_[0]->headers->{"kdf_parameters"} //= scalar &$default($_[0])
$_[0]->headers->{"kdf_parameters"}
Truth table100%2/2
A
A= $_[0]->headers->{"kdf_parameters"}
Aresult
11
00
158 25 };
159 # has 'headers.transform_seed' => sub { random_bytes(32) };
160 # has 'headers.transform_rounds' => 100_000;
161 # has 'headers.inner_random_stream_key' => sub { random_bytes(32) }; # 64 ?
162 # has 'headers.inner_random_stream_id' => STREAM_ID_CHACHA20;
163 59 ▶# has 'headers.public_custom_data' => {};
Subroutine generator: called CC=4 SCAR=15.7
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_[0]) 0 59 59
164 59 ▶ 
Subroutine header_hash: called CC=4 SCAR=15.7
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
165 59 ▶# META
Subroutine database_name: called CC=4 SCAR=15.8
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->meta->{"generator"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->meta->{"generator"} //= $default
$_[0]->meta->{"generator"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"generator"}B= $default
ABresult
1X1
011
000
166 59 ▶has 'meta.generator' => '', coerce => \&to_string;
Subroutine database_name_changed: called CC=4 SCAR=15.4
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->meta->{"header_hash"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->meta->{"header_hash"} //= $default
$_[0]->meta->{"header_hash"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"header_hash"}B= $default
ABresult
1X1
011
000
167 59 ▶has 'meta.header_hash' => '', coerce => \&to_string;
Subroutine database_description: called CC=4 SCAR=15.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->meta->{"database_name"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->meta->{"database_name"} //= $default
$_[0]->meta->{"database_name"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"database_name"}B= $default
ABresult
1X1
011
000
168 59 ▶has 'meta.database_name' => '', coerce => \&to_string;
Subroutine database_description_changed: called CC=4 SCAR=15.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition50%1/2
$_[0]->meta->{"database_name_changed"} //= scalar &$default($_[0])
l!l
059
MC/DC0%0/1
$_[0]->meta->{"database_name_changed"} //= scalar &$default($_[0])
$_[0]->meta->{"database_name_changed"}
Truth table50%1/2
A
A= $_[0]->meta->{"database_name_changed"}
Aresult
11
00
169 59 ▶has 'meta.database_name_changed' => sub { gmtime }, coerce => \&to_time;
Subroutine __ANON__: called CC=1 SCAR=0.4
Subroutine default_username: called CC=4 SCAR=15.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->meta->{"database_description"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->meta->{"database_description"} //= $default
$_[0]->meta->{"database_description"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"database_description"}B= $default
ABresult
1X1
011
000
170 59 ▶has 'meta.database_description' => '', coerce => \&to_string;
Subroutine default_username_changed: called CC=4 SCAR=15.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition50%1/2
$_[0]->meta->{"database_description_changed"} //= scalar &$default($_[0])
l!l
059
MC/DC0%0/1
$_[0]->meta->{"database_description_changed"} //= scalar &$default($_[0])
$_[0]->meta->{"database_description_changed"}
Truth table50%1/2
A
A= $_[0]->meta->{"database_description_changed"}
Aresult
11
00
171 59 ▶has 'meta.database_description_changed' => sub { gmtime }, coerce => \&to_time;
Subroutine __ANON__: called CC=1 SCAR=0.4
Subroutine maintenance_history_days: called CC=4 SCAR=15.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->meta->{"default_username"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->meta->{"default_username"} //= $default
$_[0]->meta->{"default_username"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"default_username"}B= $default
ABresult
1X1
011
000
172 59 ▶has 'meta.default_username' => '', coerce => \&to_string;
Subroutine color: called CC=4 SCAR=15.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition50%1/2
$_[0]->meta->{"default_username_changed"} //= scalar &$default($_[0])
l!l
059
MC/DC0%0/1
$_[0]->meta->{"default_username_changed"} //= scalar &$default($_[0])
$_[0]->meta->{"default_username_changed"}
Truth table50%1/2
A
A= $_[0]->meta->{"default_username_changed"}
Aresult
11
00
173 59 ▶has 'meta.default_username_changed' => sub { gmtime }, coerce => \&to_time;
Subroutine __ANON__: called CC=1 SCAR=0.4
Subroutine master_key_changed: called CC=4 SCAR=15.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->meta->{"maintenance_history_days"} //= $default
l!l&&r!l&&!r
0590
MC/DC0%0/2
$_[0]->meta->{"maintenance_history_days"} //= $default
$_[0]->meta->{"maintenance_history_days"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"maintenance_history_days"}B= $default
ABresult
1X1
011
000
174 59 ▶has 'meta.maintenance_history_days' => HISTORY_DEFAULT_MAX_AGE, coerce => \&to_number;
Subroutine master_key_change_rec: called CC=4 SCAR=15.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->meta->{"color"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->meta->{"color"} //= $default
$_[0]->meta->{"color"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"color"}B= $default
ABresult
1X1
011
000
175 59 ▶has 'meta.color' => '', coerce => \&to_string;
Subroutine master_key_change_force: called CC=4 SCAR=15.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition50%1/2
$_[0]->meta->{"master_key_changed"} //= scalar &$default($_[0])
l!l
059
MC/DC0%0/1
$_[0]->meta->{"master_key_changed"} //= scalar &$default($_[0])
$_[0]->meta->{"master_key_changed"}
Truth table50%1/2
A
A= $_[0]->meta->{"master_key_changed"}
Aresult
11
00
176 59 ▶has 'meta.master_key_changed' => sub { gmtime }, coerce => \&to_time;
Subroutine __ANON__: called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
if $#_ 0 59 59
Condition33%1/3
$_[0]->meta->{"master_key_change_rec"} //= $default
l!l&&r!l&&!r
0590
MC/DC0%0/2
$_[0]->meta->{"master_key_change_rec"} //= $default
$_[0]->meta->{"master_key_change_rec"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"master_key_change_rec"}B= $default
ABresult
1X1
011
000
177 59 ▶has 'meta.master_key_change_rec' => -1, coerce => \&to_number;
Subroutine custom_icons: called CC=4 SCAR=14.5
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_[0]) 0 220 220
Condition33%1/3
$_[0]->meta->{"master_key_change_force"} //= $default
l!l&&r!l&&!r
0590
MC/DC0%0/2
$_[0]->meta->{"master_key_change_force"} //= $default
$_[0]->meta->{"master_key_change_force"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"master_key_change_force"}B= $default
ABresult
1X1
011
000
178 220 ▶has 'meta.master_key_change_force' => -1, coerce => \&to_number;
Subroutine recycle_bin_enabled: called CC=4 SCAR=14.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 220 220
unless builtin::blessed($_[0]) 0 66 66
179 220 ▶# has 'meta.memory_protection' => {};
Subroutine recycle_bin_uuid: called CC=4 SCAR=14.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 2 64 66
unless builtin::blessed($_[0]) 0 66 66
Condition100%2/2
$_[0]->meta->{"custom_icons"} //= scalar &$default($_[0])
l!l
16060
MC/DC100%1/1
$_[0]->meta->{"custom_icons"} //= scalar &$default($_[0])
$_[0]->meta->{"custom_icons"}
Truth table100%2/2
A
A= $_[0]->meta->{"custom_icons"}
Aresult
11
00
180 66 ▶has 'meta.custom_icons' => [];
Subroutine recycle_bin_changed: called CC=4 SCAR=14.5
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 1 65 66
unless builtin::blessed($_[0]) 0 59 59
Condition66%2/3
$_[0]->meta->{"recycle_bin_enabled"} //= $default
l!l&&r!l&&!r
7590
MC/DC0%0/2
$_[0]->meta->{"recycle_bin_enabled"} //= $default
$_[0]->meta->{"recycle_bin_enabled"} $default
Truth table66%2/3
A //= B
A= $_[0]->meta->{"recycle_bin_enabled"}B= $default
ABresult
1X1
011
000
181 66 ▶has 'meta.recycle_bin_enabled' => true, coerce => \&to_bool;
Subroutine entry_templates_group: called CC=4 SCAR=14.9
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition66%2/3
$_[0]->meta->{"recycle_bin_uuid"} //= $default
l!l&&r!l&&!r
7590
MC/DC0%0/2
$_[0]->meta->{"recycle_bin_uuid"} //= $default
$_[0]->meta->{"recycle_bin_uuid"} $default
Truth table66%2/3
A //= B
A= $_[0]->meta->{"recycle_bin_uuid"}B= $default
ABresult
1X1
011
000
182 59 ▶has 'meta.recycle_bin_uuid' => UUID_NULL, coerce => \&to_uuid;
Subroutine entry_templates_group_changed: called CC=4 SCAR=15.0
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition50%1/2
$_[0]->meta->{"recycle_bin_changed"} //= scalar &$default($_[0])
l!l
059
MC/DC0%0/1
$_[0]->meta->{"recycle_bin_changed"} //= scalar &$default($_[0])
$_[0]->meta->{"recycle_bin_changed"}
Truth table50%1/2
A
A= $_[0]->meta->{"recycle_bin_changed"}
Aresult
11
00
183 59 ▶has 'meta.recycle_bin_changed' => sub { gmtime }, coerce => \&to_time;
Subroutine __ANON__: called CC=1 SCAR=0.4
Subroutine last_selected_group: called CC=4 SCAR=15.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->meta->{"entry_templates_group"} //= $default
l!l&&r!l&&!r
0590
MC/DC0%0/2
$_[0]->meta->{"entry_templates_group"} //= $default
$_[0]->meta->{"entry_templates_group"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"entry_templates_group"}B= $default
ABresult
1X1
011
000
184 59 ▶has 'meta.entry_templates_group' => UUID_NULL, coerce => \&to_uuid;
Subroutine last_top_visible_group: called CC=4 SCAR=15.2
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition50%1/2
$_[0]->meta->{"entry_templates_group_changed"} //= scalar &$default($_[0])
l!l
059
MC/DC0%0/1
$_[0]->meta->{"entry_templates_group_changed"} //= scalar &$default($_[0])
$_[0]->meta->{"entry_templates_group_changed"}
Truth table50%1/2
A
A= $_[0]->meta->{"entry_templates_group_changed"}
Aresult
11
00
185 59 ▶has 'meta.entry_templates_group_changed' => sub { gmtime }, coerce => \&to_time;
Subroutine __ANON__: called CC=1 SCAR=0.4
Subroutine history_max_items: called CC=4 SCAR=15.1
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 61 61
Condition33%1/3
$_[0]->meta->{"last_selected_group"} //= $default
l!l&&r!l&&!r
0590
MC/DC0%0/2
$_[0]->meta->{"last_selected_group"} //= $default
$_[0]->meta->{"last_selected_group"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"last_selected_group"}B= $default
ABresult
1X1
011
000
186 59 ▶has 'meta.last_selected_group' => UUID_NULL, coerce => \&to_uuid;
Subroutine history_max_size: called CC=4 SCAR=14.9
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 61 61
unless builtin::blessed($_[0]) 0 61 61
Condition33%1/3
$_[0]->meta->{"last_top_visible_group"} //= $default
l!l&&r!l&&!r
0590
MC/DC0%0/2
$_[0]->meta->{"last_top_visible_group"} //= $default
$_[0]->meta->{"last_top_visible_group"} $default
Truth table33%1/3
A //= B
A= $_[0]->meta->{"last_top_visible_group"}B= $default
ABresult
1X1
011
000
187 61 ▶has 'meta.last_top_visible_group' => UUID_NULL, coerce => \&to_uuid;
Subroutine settings_changed: called CC=4 SCAR=14.5
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 61 61
unless builtin::blessed($_[0]) 0 59 59
Condition66%2/3
$_[0]->meta->{"history_max_items"} //= $default
l!l&&r!l&&!r
2590
MC/DC0%0/2
$_[0]->meta->{"history_max_items"} //= $default
$_[0]->meta->{"history_max_items"} $default
Truth table66%2/3
A //= B
A= $_[0]->meta->{"history_max_items"}B= $default
ABresult
1X1
011
000
188 61 ▶has 'meta.history_max_items' => HISTORY_DEFAULT_MAX_ITEMS, coerce => \&to_number;
Branch: 1 branch
BranchTrueFalseTotal
if $#_ 0 59 59
Condition66%2/3
$_[0]->meta->{"history_max_size"} //= $default
l!l&&r!l&&!r
2590
MC/DC0%0/2
$_[0]->meta->{"history_max_size"} //= $default
$_[0]->meta->{"history_max_size"} $default
Truth table66%2/3
A //= B
A= $_[0]->meta->{"history_max_size"}B= $default
ABresult
1X1
011
000
189 59 ▶has 'meta.history_max_size' => HISTORY_DEFAULT_MAX_SIZE, coerce => \&to_number;
Condition50%1/2
$_[0]->meta->{"settings_changed"} //= scalar &$default($_[0])
l!l
059
MC/DC0%0/1
$_[0]->meta->{"settings_changed"} //= scalar &$default($_[0])
$_[0]->meta->{"settings_changed"}
Truth table50%1/2
A
A= $_[0]->meta->{"settings_changed"}
Aresult
11
00
190 59 ▶has 'meta.settings_changed' => sub { gmtime }, coerce => \&to_time;
Subroutine __ANON__: called CC=1 SCAR=0.0
191 59 ▶# has 'meta.binaries' => {};
Subroutine protect_title: called CC=4 SCAR=15.7
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($_[0]) 0 59 59
192 59 ▶# has 'meta.custom_data' => {};
Subroutine protect_username: called CC=4 SCAR=15.7
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
193 59 ▶ 
Subroutine protect_password: called CC=4 SCAR=15.8
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->memory_protection->{"protect_title"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->memory_protection->{"protect_title"} //= $default
$_[0]->memory_protection->{"protect_title"} $default
Truth table33%1/3
A //= B
A= $_[0]->memory_protection->{"protect_title"}B= $default
ABresult
1X1
011
000
194 59 ▶has 'memory_protection.protect_title' => false, coerce => \&to_bool;
Subroutine protect_url: called CC=4 SCAR=15.7
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->memory_protection->{"protect_username"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->memory_protection->{"protect_username"} //= $default
$_[0]->memory_protection->{"protect_username"} $default
Truth table33%1/3
A //= B
A= $_[0]->memory_protection->{"protect_username"}B= $default
ABresult
1X1
011
000
195 59 ▶has 'memory_protection.protect_username' => false, coerce => \&to_bool;
Subroutine protect_notes: called CC=4 SCAR=15.8
Pod documented
Branch: 2 branches
BranchTrueFalseTotal
if $#_ 0 59 59
unless builtin::blessed($_[0]) 0 59 59
Condition33%1/3
$_[0]->memory_protection->{"protect_password"} //= $default
l!l&&r!l&&!r
0590
MC/DC0%0/2
$_[0]->memory_protection->{"protect_password"} //= $default
$_[0]->memory_protection->{"protect_password"} $default
Truth table33%1/3
A //= B
A= $_[0]->memory_protection->{"protect_password"}B= $default
ABresult
1X1
011
000
196 59 ▶has 'memory_protection.protect_password' => true, coerce => \&to_bool;
Branch: 1 branch
BranchTrueFalseTotal
if $#_ 0 59 59
Condition33%1/3
$_[0]->memory_protection->{"protect_url"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->memory_protection->{"protect_url"} //= $default
$_[0]->memory_protection->{"protect_url"} $default
Truth table33%1/3
A //= B
A= $_[0]->memory_protection->{"protect_url"}B= $default
ABresult
1X1
011
000
197 59 ▶has 'memory_protection.protect_url' => false, coerce => \&to_bool;
Condition33%1/3
$_[0]->memory_protection->{"protect_notes"} //= $default
l!l&&r!l&&!r
0059
MC/DC0%0/2
$_[0]->memory_protection->{"protect_notes"} //= $default
$_[0]->memory_protection->{"protect_notes"} $default
Truth table33%1/3
A //= B
A= $_[0]->memory_protection->{"protect_notes"}B= $default
ABresult
1X1
011
000
198 25 has 'memory_protection.protect_notes' => false, coerce => \&to_bool;
199 # has 'memory_protection.auto_enable_visual_hiding' => false;
200  
201 25 my @ATTRS = (
202 HEADER_TRANSFORM_SEED,
203 HEADER_TRANSFORM_ROUNDS,
204 HEADER_INNER_RANDOM_STREAM_KEY,
205 HEADER_INNER_RANDOM_STREAM_ID,
206 HEADER_PUBLIC_CUSTOM_DATA,
207 );
208 sub _set_nonlazy_attributes {
209 59 ▶ my $self = shift;
Subroutine _set_nonlazy_attributes: called CC=2 SCAR=6.9
210 59 $self->$_ for list_attributes(ref $self), @ATTRS;
211 }
212  
213  
214 sub memory_protection {
215 384 ▶ my $self = shift;
Subroutine memory_protection: called CC=6 SCAR=18.2
Pod documented
216 384 ▶ $self->{meta}{memory_protection} = shift if @_ == 1 && is_plain_hashref($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 and Ref::Util::XS::is_plain_hashref($_[0]) 0 384 384
Condition66%2/3
@_ == 1 and Ref::Util::XS::is_plain_hashref($_[0])
!ll&&!rl&&r
295890
MC/DC0%0/2
@_ == 1 and Ref::Util::XS::is_plain_hashref($_[0])
@_ == 1 Ref::Util::XS::is_plain_hashref($_[0])
Truth table66%2/3
A and B
A= @_ == 1B= Ref::Util::XS::is_plain_hashref($_[0])
ABresult
0X0
100
111
217 384 ▶ return $self->{meta}{memory_protection} //= {} if !@_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 295 89 384
Condition100%2/2
$self->{"meta"}{"memory_protection"} //= {}
l!l
23659
MC/DC100%1/1
$self->{"meta"}{"memory_protection"} //= {}
$self->{"meta"}{"memory_protection"}
Truth table100%2/2
A
A= $self->{"meta"}{"memory_protection"}
Aresult
11
00
218  
219 89 my $string_key = shift;
220 89 my $key = 'protect_' . lc($string_key);
221  
222 89 ▶ $self->meta->{memory_protection}{$key} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 89 89
223 89 $self->meta->{memory_protection}{$key};
224 }
225  
226  
227 sub minimum_version {
228 119 ▶ my $self = shift;
Subroutine minimum_version: called CC=8 SCAR=20.8
Pod documented
229  
230 return KDBX_VERSION_4_1 if any {
231 nonempty $_->{last_modification_time}
232 119 ▶ } values %{$self->custom_data};
Subroutine __ANON__: called CC=1 SCAR=0.1
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { nonempty($_->{"last_modification_time"}); } , values %{$self->custom_data;}) 0 119 119
233  
234 return KDBX_VERSION_4_1 if any {
235 nonempty $_->{name} || nonempty $_->{last_modification_time}
236 119 ▶ } @{$self->custom_icons};
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { nonempty($_->{"name"} || nonempty($_->{"last_modification_time"})); } , @{$self->custom_icons;}) 2 117 119
Condition100%3/3
$_->{'name'} || nonempty($_->{'last_modification_time'})
l!l&&r!l&&!r
119
MC/DC100%2/2
$_->{'name'} || nonempty($_->{'last_modification_time'})
$_->{'name'} nonempty($_->{'last_modification_time'})
Truth table100%3/3
A || B
A= $_->{'name'}B= nonempty($_->{'last_modification_time'})
ABresult
1X1
011
000
237  
238 return KDBX_VERSION_4_1 if $self->groups->next(sub {
239 nonempty $_->previous_parent_group ||
240 nonempty $_->tags ||
241 141 ▶ (any { nonempty $_->{last_modification_time} } values %{$_->custom_data})
Subroutine __ANON__: called CC=1 SCAR=0.0
Condition100%6/6
$_->previous_parent_group || nonempty($_->tags || &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;}))
l!l&&r!l&&!r
12153
$_->tags || &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;})
l!l&&r!l&&!r
11153
MC/DC100%2/2
$_->previous_parent_group || nonempty($_->tags || &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;}))
$_->previous_parent_group nonempty($_->tags || &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;}))
MC/DC50%1/2
$_->tags || &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;})
$_->tags &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;})
Truth table100%3/3
A || B
A= $_->previous_parent_groupB= nonempty($_->tags || &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;}))
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= $_->tagsB= &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;})
ABresult
1X1
011
000
242 117 ▶ });
Branch: 1 branch
BranchTrueFalseTotal
if $self->groups->next(sub { nonempty($_->previous_parent_group || nonempty($_->tags || &any(sub { nonempty($_->{"last_modification_time"}); } , values %{$_->custom_data;}))); } ) 3 114 117
243  
244 return KDBX_VERSION_4_1 if $self->entries(history => 1)->next(sub {
245 nonempty $_->previous_parent_group ||
246 (defined $_->quality_check && !$_->quality_check) ||
247 22 ▶ (any { nonempty $_->{last_modification_time} } values %{$_->custom_data})
Subroutine __ANON__: called CC=1 SCAR=0.0
Condition88%8/9
$_->previous_parent_group || defined $_->quality_check && !$_->quality_check || &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;})
l!l&&r!l&&!r
2124
$_->previous_parent_group or defined $_->quality_check and not $_->quality_check
l!l&&r!l&&!r
1125
defined $_->quality_check and not $_->quality_check
!ll&&!rl&&r
0251
MC/DC50%2/4
$_->previous_parent_group || defined $_->quality_check && !$_->quality_check || &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;})
$_->previous_parent_group defined $_->quality_check not $_->quality_check &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;})
Truth table50%3/6
A or B and not(C) || D
A= $_->previous_parent_groupB= defined $_->quality_checkC= not $_->quality_checkD= &any(sub { nonempty($_->{'last_modification_time'}); } , values %{$_->custom_data;})
ABCDresult
1XXX1
011X1
00X11
01011
00X00
01000
248 114 ▶ });
Branch: 1 branch
BranchTrueFalseTotal
if $self->entries("history", 1)->next(sub { nonempty($_->previous_parent_group || defined $_->quality_check && !$_->quality_check || &any(sub { nonempty($_->{"last_modification_time"}); } , values %{$_->custom_data;})); } ) 3 111 114
249  
250 111 ▶ return KDBX_VERSION_4_0 if $self->kdf->uuid ne KDF_UUID_AES;
Branch: 1 branch
BranchTrueFalseTotal
if $self->kdf->uuid ne "\311\331\363\232b\212D`\277t\r\b\301\212O\352" 10 101 111
251  
252 101 ▶ return KDBX_VERSION_4_0 if nonempty $self->public_custom_data;
Branch: 1 branch
BranchTrueFalseTotal
if nonempty($self->public_custom_data) 4 97 101
253  
254 return KDBX_VERSION_4_0 if $self->objects->next(sub {
255 146 ▶ nonempty $_->custom_data
Subroutine __ANON__: called CC=1 SCAR=0.0
256 97 ▶ });
Branch: 1 branch
BranchTrueFalseTotal
if $self->objects->next(sub { nonempty($_->custom_data); } ) 11 86 97
257  
258 86 return KDBX_VERSION_3_1;
259 }
260  
261 ##############################################################################
262  
263  
264 sub root {
265 664 ▶ my $self = shift;
Subroutine root: called CC=3 SCAR=11.0
Pod documented
266 664 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 21 643 664
267 21 $self->{root} = $self->_wrap_group(@_);
268 21 $self->{root}->kdbx($self);
269 }
270 664 ▶ $self->{root} //= $self->_implicit_root;
Condition66%2/3
$self->{"root"} //= $self->_implicit_root
l!l&&r!l&&!r
605590
MC/DC0%0/2
$self->{"root"} //= $self->_implicit_root
$self->{"root"} $self->_implicit_root
Truth table66%2/3
A //= B
A= $self->{"root"}B= $self->_implicit_root
ABresult
1X1
011
000
271 664 return $self->_wrap_group($self->{root});
272 }
273  
274 # Called by File::KeePass::KDBX so that a File::KDBX an be treated as a File::KDBX::Group in that both types
275 # can have subgroups. File::KDBX already has a `groups' method that does something different from the
276 # File::KDBX::Groups `groups' method.
277 sub _kpx_groups {
278 0 ▶ my $self = shift;
Subroutine _kpx_groups: not called CC=3 SCAR=24.8
279 0 ▶ return [] if !$self->{root};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"root"} 0 0 0
280 0 ▶ return $self->_has_implicit_root ? $self->root->groups : [$self->root];
Branch: 1 branch
BranchTrueFalseTotal
$self->_has_implicit_root ? : 0 0 0
281 }
282  
283 sub _has_implicit_root {
284 3 ▶ my $self = shift;
Subroutine _has_implicit_root: called CC=11 SCAR=27.4
285 3 my $root = $self->root;
286 3 my $temp = __PACKAGE__->_implicit_root;
287 # If an implicit root group has been changed in any significant way, it is no longer implicit.
288 return $root->name eq $temp->name &&
289 $root->is_expanded ^ $temp->is_expanded &&
290 $root->notes eq $temp->notes &&
291 3 !@{$root->entries} &&
292 !defined $root->custom_icon_uuid &&
293 3 ▶ !keys %{$root->custom_data} &&
Condition60%18/30
$root->name eq $temp->name && $root->is_expanded ^ $temp->is_expanded && $root->notes eq $temp->notes && !@{$root->entries;} && !defined($root->custom_icon_uuid) && !keys(%{$root->custom_data;}) && $root->icon_id == $temp->icon_id && $root->expires ^ $temp->expires && $root->default_auto_type_sequence eq $temp->default_auto_type_sequence && !defined($root->enable_auto_type) && !defined($root->enable_searching)
!ll&&!rl&&r
102
$root->name eq $temp->name and $root->is_expanded ^ $temp->is_expanded and $root->notes eq $temp->notes and not @{$root->entries;} and not defined $root->custom_icon_uuid and not keys %{$root->custom_data;} and $root->icon_id == $temp->icon_id and $root->expires ^ $temp->expires and $root->default_auto_type_sequence eq $temp->default_auto_type_sequence and not defined $root->enable_auto_type
!ll&&!rl&&r
102
$root->name eq $temp->name and $root->is_expanded ^ $temp->is_expanded and $root->notes eq $temp->notes and not @{$root->entries;} and not defined $root->custom_icon_uuid and not keys %{$root->custom_data;} and $root->icon_id == $temp->icon_id and $root->expires ^ $temp->expires and $root->default_auto_type_sequence eq $temp->default_auto_type_sequence
!ll&&!rl&&r
102
$root->name eq $temp->name and $root->is_expanded ^ $temp->is_expanded and $root->notes eq $temp->notes and not @{$root->entries;} and not defined $root->custom_icon_uuid and not keys %{$root->custom_data;} and $root->icon_id == $temp->icon_id and $root->expires ^ $temp->expires
!ll&&!rl&&r
102
$root->name eq $temp->name and $root->is_expanded ^ $temp->is_expanded and $root->notes eq $temp->notes and not @{$root->entries;} and not defined $root->custom_icon_uuid and not keys %{$root->custom_data;} and $root->icon_id == $temp->icon_id
!ll&&!rl&&r
102
$root->name eq $temp->name and $root->is_expanded ^ $temp->is_expanded and $root->notes eq $temp->notes and not @{$root->entries;} and not defined $root->custom_icon_uuid and not keys %{$root->custom_data;}
!ll&&!rl&&r
102
$root->name eq $temp->name and $root->is_expanded ^ $temp->is_expanded and $root->notes eq $temp->notes and not @{$root->entries;} and not defined $root->custom_icon_uuid
!ll&&!rl&&r
102
$root->name eq $temp->name and $root->is_expanded ^ $temp->is_expanded and $root->notes eq $temp->notes and not @{$root->entries;}
!ll&&!rl&&r
012
$root->name eq $temp->name and $root->is_expanded ^ $temp->is_expanded and $root->notes eq $temp->notes
!ll&&!rl&&r
003
$root->name eq $temp->name and $root->is_expanded ^ $temp->is_expanded
!ll&&!rl&&r
003
MC/DC9%1/11
$root->name eq $temp->name && $root->is_expanded ^ $temp->is_expanded && $root->notes eq $temp->notes && !@{$root->entries;} && !defined($root->custom_icon_uuid) && !keys(%{$root->custom_data;}) && $root->icon_id == $temp->icon_id && $root->expires ^ $temp->expires && $root->default_auto_type_sequence eq $temp->default_auto_type_sequence && !defined($root->enable_auto_type) && !defined($root->enable_searching)
$root->name eq $temp->name $root->is_expanded ^ $temp->is_expanded $root->notes eq $temp->notes not @{$root->entries;} not defined $root->custom_icon_uuid not keys %{$root->custom_data;} $root->icon_id == $temp->icon_id $root->expires ^ $temp->expires $root->default_auto_type_sequence eq $temp->default_auto_type_sequence not defined $root->enable_auto_type !defined($root->enable_searching)
Truth table16%2/12
A and B and C and not(D) and not(E) and not(F) and G and H and I and not(J) && not(K)
A= $root->name eq $temp->nameB= $root->is_expanded ^ $temp->is_expandedC= $root->notes eq $temp->notesD= not @{$root->entries;}E= not defined $root->custom_icon_uuidF= not keys %{$root->custom_data;}G= $root->icon_id == $temp->icon_idH= $root->expires ^ $temp->expiresI= $root->default_auto_type_sequence eq $temp->default_auto_type_sequenceJ= not defined $root->enable_auto_typeK= !defined($root->enable_searching)
ABCDEFGHIJKresult
0XXXXXXXXXX0
10XXXXXXXXX0
110XXXXXXXX0
1110XXXXXXX0
11110XXXXXX0
111110XXXXX0
1111110XXXX0
11111110XXX0
111111110XX0
1111111110X0
111111111100
111111111111
294 $root->icon_id == $temp->icon_id &&
295 $root->expires ^ $temp->expires &&
296 $root->default_auto_type_sequence eq $temp->default_auto_type_sequence &&
297 !defined $root->enable_auto_type &&
298 !defined $root->enable_searching;
299 }
300  
301 sub _implicit_root {
302 62 ▶ my $self = shift;
Subroutine _implicit_root: called CC=2 SCAR=6.9
303 62 require File::KDBX::Group;
304 62 ▶ return File::KDBX::Group->new(
Branch: 1 branch
BranchTrueFalseTotal
ref $self ? : 59 3 62
305 name => 'Root',
306 is_expanded => true,
307 notes => 'Added as an implicit root group by '.__PACKAGE__.'.',
308 ref $self ? (kdbx => $self) : (),
309 );
310 }
311  
312  
313 sub trace_lineage {
314 0 ▶ my $self = shift;
Subroutine trace_lineage: not called CC=1 SCAR=6.9
Pod documented
315 0 my $object = shift;
316 0 return $object->lineage(@_);
317 }
318  
319 sub _trace_lineage {
320 213 ▶ my $self = shift;
Subroutine _trace_lineage: called CC=6 SCAR=18.0
321 213 my $object = shift;
322 213 my @lineage = @_;
323  
324 213 ▶ push @lineage, $self->root if !@lineage;
Branch: 1 branch
BranchTrueFalseTotal
unless @lineage 123 90 213
325 213 ▶ my $base = $lineage[-1] or return [];
Branch: 1 branch
BranchTrueFalseTotal
my $base = $lineage[-1] or return [] 0 213 213
326  
327 213 my $uuid = $object->uuid;
328 213 ▶ return \@lineage if any { $_->uuid eq $uuid } @{$base->groups}, @{$base->entries};
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if &any(sub { $_->uuid eq $uuid; } , @{$base->groups;}, @{$base->entries;}) 1 212 213
329  
330 212 for my $subgroup (@{$base->groups}) {
331 90 my $result = $self->_trace_lineage($object, @lineage, $subgroup);
332 90 ▶ return $result if $result;
Branch: 1 branch
BranchTrueFalseTotal
if $result 0 90 90
333 }
334 }
335  
336  
337 sub recycle_bin {
338 6 ▶ my $self = shift;
Subroutine recycle_bin: called CC=5 SCAR=16.5
Pod documented
339 6 ▶ if (my $group = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $group = shift()) 0 6 6
340 0 $self->recycle_bin_uuid($group->uuid);
341 0 return $group;
342 }
343 6 my $group;
344 6 my $uuid = $self->recycle_bin_uuid;
345 6 ▶ $group = $self->groups->grep(uuid => $uuid)->next if $uuid ne UUID_NULL;
Branch: 1 branch
BranchTrueFalseTotal
if $uuid ne "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 5 1 6
346 6 ▶ if (!$group && $self->recycle_bin_enabled) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $group and $self->recycle_bin_enabled) 1 5 6
Condition66%2/3
not $group and $self->recycle_bin_enabled
!ll&&!rl&&r
501
MC/DC50%1/2
not $group and $self->recycle_bin_enabled
not $group $self->recycle_bin_enabled
Truth table66%2/3
not(A) and B
A= not $groupB= $self->recycle_bin_enabled
ABresult
0X0
100
111
347 1 $group = $self->add_group(
348 name => 'Recycle Bin',
349 icon_id => ICON_TRASHCAN_FULL,
350 enable_auto_type => false,
351 enable_searching => false,
352 );
353 1 $self->recycle_bin_uuid($group->uuid);
354 }
355 6 return $group;
356 }
357  
358  
359 sub entry_templates {
360 0 ▶ my $self = shift;
Subroutine entry_templates: not called CC=3 SCAR=24.8
Pod documented
361 0 ▶ if (my $group = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $group = shift()) 0 0 0
362 0 $self->entry_templates_group($group->uuid);
363 0 return $group;
364 }
365 0 my $uuid = $self->entry_templates_group;
366 0 ▶ return if $uuid eq UUID_NULL;
Branch: 1 branch
BranchTrueFalseTotal
if $uuid eq "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 0 0 0
367 0 return $self->groups->grep(uuid => $uuid)->next;
368 }
369  
370  
371 sub last_selected {
372 0 ▶ my $self = shift;
Subroutine last_selected: not called CC=3 SCAR=24.8
Pod documented
373 0 ▶ if (my $group = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $group = shift()) 0 0 0
374 0 $self->last_selected_group($group->uuid);
375 0 return $group;
376 }
377 0 my $uuid = $self->last_selected_group;
378 0 ▶ return if $uuid eq UUID_NULL;
Branch: 1 branch
BranchTrueFalseTotal
if $uuid eq "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 0 0 0
379 0 return $self->groups->grep(uuid => $uuid)->next;
380 }
381  
382  
383 sub last_top_visible {
384 0 ▶ my $self = shift;
Subroutine last_top_visible: not called CC=3 SCAR=24.8
Pod documented
385 0 ▶ if (my $group = shift) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $group = shift()) 0 0 0
386 0 $self->last_top_visible_group($group->uuid);
387 0 return $group;
388 }
389 0 my $uuid = $self->last_top_visible_group;
390 0 ▶ return if $uuid eq UUID_NULL;
Branch: 1 branch
BranchTrueFalseTotal
if $uuid eq "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" 0 0 0
391 0 return $self->groups->grep(uuid => $uuid)->next;
392 }
393  
394 ##############################################################################
395  
396  
397 sub add_group {
398 15 ▶ my $self = shift;
Subroutine add_group: called CC=6 SCAR=19.9
Pod documented
399 15 ▶ my $group = @_ % 2 == 1 ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 1 ? : 0 15 15
400 15 my %args = @_;
401  
402 # find the right group to add the group to
403 15 ▶ my $parent = delete $args{group} // $self->root;
Condition33%1/3
delete $args{"group"} // $self->root
l!l&&r!l&&!r
0150
MC/DC0%0/2
delete $args{"group"} // $self->root
delete $args{"group"} $self->root
Truth table33%1/3
A // B
A= delete $args{"group"}B= $self->root
ABresult
1X1
011
000
404 15 ▶ $parent = $self->groups->grep({uuid => $parent})->next if !ref $parent;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $parent 0 15 15
405 15 ▶ $parent or throw 'Invalid group';
Branch: 1 branch
BranchTrueFalseTotal
$parent or throw("Invalid group") 0 15 15
406  
407 15 ▶ return $parent->add_group(defined $group ? $group : (), %args, kdbx => $self);
Branch: 1 branch
BranchTrueFalseTotal
defined $group ? : 0 15 15
408 }
409  
410 sub _wrap_group {
411 685 ▶ my $self = shift;
Subroutine _wrap_group: called CC=1 SCAR=0.0
412 685 my $group = shift;
413 685 require File::KDBX::Group;
414 685 return File::KDBX::Group->wrap($group, $self);
415 }
416  
417  
418 sub groups {
419 133 ▶ my $self = shift;
Subroutine groups: called CC=3 SCAR=12.0
Pod documented
420 133 ▶ my %args = @_ % 2 == 0 ? @_ : (base => shift, @_);
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 0 ? : 133 0 133
421 133 ▶ my $base = delete $args{base} // $self->root;
Condition33%1/3
delete $args{"base"} // $self->root
l!l&&r!l&&!r
01330
MC/DC0%0/2
delete $args{"base"} // $self->root
delete $args{"base"} $self->root
Truth table33%1/3
A // B
A= delete $args{"base"}B= $self->root
ABresult
1X1
011
000
422  
423 133 return $base->all_groups(%args);
424 }
425  
426 ##############################################################################
427  
428  
429 sub add_entry {
430 20 ▶ my $self = shift;
Subroutine add_entry: called CC=6 SCAR=18.6
Pod documented
431 20 ▶ my $entry = @_ % 2 == 1 ? shift : undef;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 1 ? : 1 19 20
432 20 my %args = @_;
433  
434 # find the right group to add the entry to
435 20 ▶ my $parent = delete $args{group} // $self->root;
Condition33%1/3
delete $args{"group"} // $self->root
l!l&&r!l&&!r
0200
MC/DC0%0/2
delete $args{"group"} // $self->root
delete $args{"group"} $self->root
Truth table33%1/3
A // B
A= delete $args{"group"}B= $self->root
ABresult
1X1
011
000
436 20 ▶ $parent = $self->groups->grep({uuid => $parent})->next if !ref $parent;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $parent 0 20 20
437 20 ▶ $parent or throw 'Invalid group';
Branch: 1 branch
BranchTrueFalseTotal
$parent or throw("Invalid group") 0 20 20
438  
439 20 ▶ return $parent->add_entry(defined $entry ? $entry : (), %args, kdbx => $self);
Branch: 1 branch
BranchTrueFalseTotal
defined $entry ? : 1 19 20
440 }
441  
442 sub _wrap_entry {
443 0 ▶ my $self = shift;
Subroutine _wrap_entry: not called CC=1 SCAR=6.9
444 0 my $entry = shift;
445 0 require File::KDBX::Entry;
446 0 return File::KDBX::Entry->wrap($entry, $self);
447 }
448  
449  
450 sub entries {
451 204 ▶ my $self = shift;
Subroutine entries: called CC=3 SCAR=12.0
Pod documented
452 204 ▶ my %args = @_ % 2 == 0 ? @_ : (base => shift, @_);
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 0 ? : 204 0 204
453 204 ▶ my $base = delete $args{base} // $self->root;
Condition33%1/3
delete $args{"base"} // $self->root
l!l&&r!l&&!r
02040
MC/DC0%0/2
delete $args{"base"} // $self->root
delete $args{"base"} $self->root
Truth table33%1/3
A // B
A= delete $args{"base"}B= $self->root
ABresult
1X1
011
000
454  
455 204 return $base->all_entries(%args);
456 }
457  
458 ##############################################################################
459  
460  
461 sub objects {
462 106 ▶ my $self = shift;
Subroutine objects: called CC=3 SCAR=12.0
Pod documented
463 106 ▶ my %args = @_ % 2 == 0 ? @_ : (base => shift, @_);
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 0 ? : 106 0 106
464 106 ▶ my $base = delete $args{base} // $self->root;
Condition33%1/3
delete $args{"base"} // $self->root
l!l&&r!l&&!r
01060
MC/DC0%0/2
delete $args{"base"} // $self->root
delete $args{"base"} $self->root
Truth table33%1/3
A // B
A= delete $args{"base"}B= $self->root
ABresult
1X1
011
000
465  
466 106 return $base->all_objects(%args);
467 }
468  
469 0 ▶sub __iter__ { $_[0]->objects }
Subroutine __iter__: not called CC=1 SCAR=6.9
470  
471 ##############################################################################
472  
473  
474 sub custom_icon {
475 0 ▶ my $self = shift;
Subroutine custom_icon: not called CC=10 SCAR=47.0
Pod documented
476 0 ▶ my %args = @_ == 2 ? (uuid => shift, data => shift)
Branch: 2 branches
BranchTrueFalseTotal
@_ == 2 ? : 0 0 0
@_ % 2 == 1 ? : 0 0 0
477 : @_ % 2 == 1 ? (uuid => shift, @_) : @_;
478  
479 0 ▶ if (!$args{uuid} && !$args{data}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"uuid"} or $args{"data"}) 0 0 0
Condition0%0/3
$args{"uuid"} or $args{"data"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"uuid"} or $args{"data"}
$args{"uuid"} $args{"data"}
Truth table0%0/3
A or B
A= $args{"uuid"}B= $args{"data"}
ABresult
1X1
011
000
480 0 my %standard = (uuid => 1, data => 1, name => 1, last_modification_time => 1);
481 0 my @other_keys = grep { !$standard{$_} } keys %args;
482 0 ▶ if (@other_keys == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@other_keys == 1) 0 0 0
483 0 my $key = $args{key} = $other_keys[0];
484 0 $args{data} = delete $args{$key};
485 }
486 }
487  
488 0 ▶ my $uuid = $args{uuid} or throw 'Must provide a custom icon UUID to access';
Branch: 1 branch
BranchTrueFalseTotal
my $uuid = $args{"uuid"} or throw("Must provide a custom icon UUID to access") 0 0 0
489 0 ▶ my $icon = (first { $_->{uuid} eq $uuid } @{$self->custom_icons}) // do {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
&first(sub { $_->{"uuid"} eq $uuid; } , @{$self->custom_icons;}) // do { push @{$self->custom_icons;}, my $i = {"uuid", $uuid}; $i }
l!l&&r!l&&!r
000
MC/DC0%0/2
&first(sub { $_->{"uuid"} eq $uuid; } , @{$self->custom_icons;}) // do { push @{$self->custom_icons;}, my $i = {"uuid", $uuid}; $i }
&first(sub { $_->{"uuid"} eq $uuid; } , @{$self->custom_icons;}) do { push @{$self->custom_icons;}, my $i = {"uuid", $uuid}; $i }
Truth table0%0/3
A // B
A= &first(sub { $_->{"uuid"} eq $uuid; } , @{$self->custom_icons;})B= do { push @{$self->custom_icons;}, my $i = {"uuid", $uuid}; $i }
ABresult
1X1
011
000
490 0 push @{$self->custom_icons}, my $i = { uuid => $uuid };
491 0 $i;
492 };
493  
494 0 my $fields = \%args;
495 0 ▶ $fields = $args{data} if is_plain_hashref($args{data});
Branch: 1 branch
BranchTrueFalseTotal
if Ref::Util::XS::is_plain_hashref($args{"data"}) 0 0 0
496  
497 0 ▶ while (my ($field, $value) = each %$fields) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$fields) 0 0 0
498 0 $icon->{$field} = $value;
499 }
500 0 return $icon;
501 }
502  
503  
504 sub custom_icon_data {
505 5 ▶ my $self = shift;
Subroutine custom_icon_data: called CC=3 SCAR=11.0
Pod documented
506 5 ▶ my $uuid = shift // return;
Condition100%2/2
shift() // (return)
l!l
41
MC/DC100%1/1
shift() // (return)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
507 4 ▶ my $icon = first { $_->{uuid} eq $uuid } @{$self->custom_icons} or return;
Subroutine __ANON__: called CC=1 SCAR=0.1
Branch: 1 branch
BranchTrueFalseTotal
my $icon = &first(sub { $_->{"uuid"} eq $uuid; } , @{$self->custom_icons;}) or return 0 4 4
508 4 return $icon->{data};
509 }
510  
511  
512 sub add_custom_icon {
513 9 ▶ my $self = shift;
Subroutine add_custom_icon: called CC=4 SCAR=14.8
Pod documented
514 9 ▶ my %args = @_ % 2 == 1 ? (data => shift, @_) : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 1 ? : 9 0 9
515  
516 9 ▶ defined $args{data} or throw 'Must provide image data';
Branch: 1 branch
BranchTrueFalseTotal
defined $args{"data"} or throw("Must provide image data") 0 9 9
517  
518 9 ▶ my $uuid = $args{uuid} // generate_uuid;
Condition33%1/3
$args{"uuid"} // generate_uuid()
l!l&&r!l&&!r
090
MC/DC0%0/2
$args{"uuid"} // generate_uuid()
$args{"uuid"} generate_uuid()
Truth table33%1/3
A // B
A= $args{"uuid"}B= generate_uuid()
ABresult
1X1
011
000
519 9 push @{$self->custom_icons}, {
520 @_,
521 uuid => $uuid,
522 data => $args{data},
523 9 };
524 9 return $uuid;
525 }
526  
527  
528 sub remove_custom_icon {
529 5 ▶ my $self = shift;
Subroutine remove_custom_icon: called CC=3 SCAR=11.0
Pod documented
530 5 my $uuid = shift;
531 5 my @deleted;
532 12 ▶ @{$self->custom_icons} = grep { $_->{uuid} eq $uuid ? do { push @deleted, $_; 0 } : 1 }
Branch: 1 branch
BranchTrueFalseTotal
$_->{'uuid'} eq $uuid ? : 5 7 12
533 5 @{$self->custom_icons};
534 5 ▶ $self->add_deleted_object($uuid) if @deleted;
Branch: 1 branch
BranchTrueFalseTotal
if @deleted 5 0 5
535 5 return @deleted;
536 }
537  
538 ##############################################################################
539  
540  
541 sub custom_data {
542 120 ▶ my $self = shift;
Subroutine custom_data: called CC=13 SCAR=33.6
Pod documented
543 120 ▶ $self->{meta}{custom_data} = shift if @_ == 1 && is_plain_hashref($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 and Ref::Util::XS::is_plain_hashref($_[0]) 0 120 120
Condition33%1/3
@_ == 1 and Ref::Util::XS::is_plain_hashref($_[0])
!ll&&!rl&&r
12000
MC/DC0%0/2
@_ == 1 and Ref::Util::XS::is_plain_hashref($_[0])
@_ == 1 Ref::Util::XS::is_plain_hashref($_[0])
Truth table33%1/3
A and B
A= @_ == 1B= Ref::Util::XS::is_plain_hashref($_[0])
ABresult
0X0
100
111
544 120 ▶ return $self->{meta}{custom_data} //= {} if !@_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 119 1 120
Condition100%2/2
$self->{"meta"}{"custom_data"} //= {}
l!l
6059
MC/DC100%1/1
$self->{"meta"}{"custom_data"} //= {}
$self->{"meta"}{"custom_data"}
Truth table100%2/2
A
A= $self->{"meta"}{"custom_data"}
Aresult
11
00
545  
546 1 ▶ my %args = @_ == 2 ? (key => shift, value => shift)
Branch: 2 branches
BranchTrueFalseTotal
@_ == 2 ? : 1 0 1
@_ % 2 == 1 ? : 0 0 0
547 : @_ % 2 == 1 ? (key => shift, @_) : @_;
548  
549 1 ▶ if (!$args{key} && !$args{value}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"key"} or $args{"value"}) 0 1 1
Condition33%1/3
$args{"key"} or $args{"value"}
l!l&&r!l&&!r
100
MC/DC0%0/2
$args{"key"} or $args{"value"}
$args{"key"} $args{"value"}
Truth table33%1/3
A or B
A= $args{"key"}B= $args{"value"}
ABresult
1X1
011
000
550 0 my %standard = (key => 1, value => 1, last_modification_time => 1);
551 0 my @other_keys = grep { !$standard{$_} } keys %args;
552 0 ▶ if (@other_keys == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@other_keys == 1) 0 0 0
553 0 my $key = $args{key} = $other_keys[0];
554 0 $args{value} = delete $args{$key};
555 }
556 }
557  
558 1 ▶ my $key = $args{key} or throw 'Must provide a custom_data key to access';
Branch: 1 branch
BranchTrueFalseTotal
my $key = $args{"key"} or throw("Must provide a custom_data key to access") 0 1 1
559  
560 1 ▶ return $self->{meta}{custom_data}{$key} = $args{value} if is_plain_hashref($args{value});
Branch: 1 branch
BranchTrueFalseTotal
if Ref::Util::XS::is_plain_hashref($args{"value"}) 0 1 1
561  
562 1 ▶ while (my ($field, $value) = each %args) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %args) 2 1 3
563 2 $self->{meta}{custom_data}{$key}{$field} = $value;
564 }
565 1 return $self->{meta}{custom_data}{$key};
566 }
567  
568  
569 sub custom_data_value {
570 0 ▶ my $self = shift;
Subroutine custom_data_value: not called CC=2 SCAR=17.9
Pod documented
571 0 ▶ my $data = $self->custom_data(@_) // return;
Condition0%0/2
$self->custom_data(@_) // (return)
l!l
00
MC/DC0%0/1
$self->custom_data(@_) // (return)
$self->custom_data(@_)
Truth table0%0/2
A
A= $self->custom_data(@_)
Aresult
11
00
572 0 return $data->{value};
573 }
574  
575  
576 sub public_custom_data {
577 172 ▶ my $self = shift;
Subroutine public_custom_data: called CC=7 SCAR=28.0
Pod documented
578 172 ▶ $self->{headers}{+HEADER_PUBLIC_CUSTOM_DATA} = shift if @_ == 1 && is_plain_hashref($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 1 and Ref::Util::XS::is_plain_hashref($_[0]) 0 172 172
Condition33%1/3
@_ == 1 and Ref::Util::XS::is_plain_hashref($_[0])
!ll&&!rl&&r
17200
MC/DC0%0/2
@_ == 1 and Ref::Util::XS::is_plain_hashref($_[0])
@_ == 1 Ref::Util::XS::is_plain_hashref($_[0])
Truth table33%1/3
A and B
A= @_ == 1B= Ref::Util::XS::is_plain_hashref($_[0])
ABresult
0X0
100
111
579 172 ▶ return $self->{headers}{+HEADER_PUBLIC_CUSTOM_DATA} //= {} if !@_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 172 0 172
Condition100%2/2
$self->{"headers"}{"public_custom_data"} //= {}
l!l
11260
MC/DC100%1/1
$self->{"headers"}{"public_custom_data"} //= {}
$self->{"headers"}{"public_custom_data"}
Truth table100%2/2
A
A= $self->{"headers"}{"public_custom_data"}
Aresult
11
00
580  
581 0 ▶ my $key = shift or throw 'Must provide a public_custom_data key to access';
Branch: 1 branch
BranchTrueFalseTotal
my $key = shift() or throw("Must provide a public_custom_data key to access") 0 0 0
582 0 ▶ $self->{headers}{+HEADER_PUBLIC_CUSTOM_DATA}{$key} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
583 0 return $self->{headers}{+HEADER_PUBLIC_CUSTOM_DATA}{$key};
584 }
585  
586 ##############################################################################
587  
588 # TODO
589  
590 # sub merge_to {
591 # my $self = shift;
592 # my $other = shift;
593 # my %options = @_; # prefer_old / prefer_new
594 # $other->merge_from($self);
595 # }
596  
597 # sub merge_from {
598 # my $self = shift;
599 # my $other = shift;
600  
601 # die 'Not implemented';
602 # }
603  
604  
605 sub add_deleted_object {
606 11 ▶ my $self = shift;
Subroutine add_deleted_object: called CC=3 SCAR=12.0
Pod documented
607 11 my $uuid = shift;
608  
609 # ignore null and meta stream UUIDs
610 11 ▶ return if $uuid eq UUID_NULL || $uuid eq '0' x 16;
Branch: 1 branch
BranchTrueFalseTotal
if $uuid eq "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" or $uuid eq "0000000000000000" 0 11 11
Condition33%1/3
$uuid eq "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" or $uuid eq "0000000000000000"
l!l&&r!l&&!r
0011
MC/DC0%0/2
$uuid eq "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" or $uuid eq "0000000000000000"
$uuid eq "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" $uuid eq "0000000000000000"
Truth table33%1/3
A or B
A= $uuid eq "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"B= $uuid eq "0000000000000000"
ABresult
1X1
011
000
611  
612 11 $self->deleted_objects->{$uuid} = {
613 uuid => $uuid,
614 deletion_time => scalar gmtime,
615 };
616 }
617  
618  
619 sub remove_deleted_object {
620 48 ▶ my $self = shift;
Subroutine remove_deleted_object: called CC=1 SCAR=0.0
Pod documented
621 48 my $uuid = shift;
622 48 delete $self->deleted_objects->{$uuid};
623 }
624  
625  
626 sub clear_deleted_objects {
627 0 ▶ my $self = shift;
Subroutine clear_deleted_objects: not called CC=1 SCAR=6.9
Pod documented
628 0 %{$self->deleted_objects} = ();
629 }
630  
631 ##############################################################################
632  
633  
634 sub resolve_reference {
635 18 ▶ my $self = shift;
Subroutine resolve_reference: called CC=10 SCAR=23.5
Pod documented
636 18 ▶ my $wanted = shift // return;
Condition50%1/2
shift() // (return)
l!l
180
MC/DC0%0/1
shift() // (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
637 18 my $search_in = shift;
638 18 my $text = shift;
639  
640 18 ▶ if (!defined $text) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $text) 17 1 18
641 17 $wanted =~ s/^\{REF:([^\}]+)\}$/$1/i;
642 17 ($wanted, $search_in, $text) = $wanted =~ /^([TUPANI])\@([TUPANIO]):(.*)$/i;
643 }
644 18 ▶ $wanted && $search_in && nonempty($text) or return;
Branch: 1 branch
BranchTrueFalseTotal
$wanted and $search_in and nonempty($text) or return 0 17 17
Condition66%4/6
$wanted and $search_in and nonempty($text)
!ll&&!rl&&r
1017
$wanted and $search_in
!ll&&!rl&&r
1017
MC/DC33%1/3
$wanted and $search_in and nonempty($text)
$wanted $search_in nonempty($text)
Truth table50%2/4
A and B and C
A= $wantedB= $search_inC= nonempty($text)
ABCresult
0XX0
10X0
1100
1111
645  
646 17 my %fields = (
647 T => 'expand_title',
648 U => 'expand_username',
649 P => 'expand_password',
650 A => 'expand_url',
651 N => 'expand_notes',
652 I => 'uuid',
653 O => 'other_strings',
654 );
655 17 ▶ $wanted = $fields{$wanted} or return;
Branch: 1 branch
BranchTrueFalseTotal
$wanted = $fields{$wanted} or return 0 17 17
656 17 ▶ $search_in = $fields{$search_in} or return;
Branch: 1 branch
BranchTrueFalseTotal
$search_in = $fields{$search_in} or return 0 17 17
657  
658 17 ▶ my $query = $search_in eq 'uuid' ? query($search_in => uuid($text))
Branch: 1 branch
BranchTrueFalseTotal
$search_in eq 'uuid' ? : 9 8 17
659 : simple_expression_query($text, '=~', $search_in);
660  
661 17 my $entry = $self->entries->grep($query)->next;
662 17 ▶ $entry or return;
Branch: 1 branch
BranchTrueFalseTotal
$entry or return 2 15 17
663  
664 15 return $entry->$wanted;
665 }
666  
667 our %PLACEHOLDERS = (
668 # 'PLACEHOLDER' => sub { my ($entry, $arg) = @_; ... };
669 3 ▶ 'TITLE' => sub { $_[0]->expand_title },
Subroutine __ANON__: called CC=1 SCAR=0.0
670 1 ▶ 'USERNAME' => sub { $_[0]->expand_username },
Subroutine __ANON__: called CC=1 SCAR=0.0
671 0 ▶ 'PASSWORD' => sub { $_[0]->expand_password },
Subroutine __ANON__: not called CC=1 SCAR=6.9
672 10 ▶ 'NOTES' => sub { $_[0]->expand_notes },
Subroutine __ANON__: called CC=1 SCAR=0.0
673 0 ▶ 'S:' => sub { $_[0]->string_value($_[1]) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
674 10 ▶ 'URL' => sub { $_[0]->expand_url },
Subroutine __ANON__: called CC=1 SCAR=0.0
675 0 ▶ 'URL:RMVSCM' => sub { local $_ = $_[0]->url; s!^[^:/\?\#]+://!!; $_ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
676 0 ▶ 'URL:WITHOUTSCHEME' => sub { local $_ = $_[0]->url; s!^[^:/\?\#]+://!!; $_ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
677 0 ▶ 'URL:SCM' => sub { (split_url($_[0]->url))[0] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
678 0 ▶ 'URL:SCHEME' => sub { (split_url($_[0]->url))[0] }, # non-standard
Subroutine __ANON__: not called CC=1 SCAR=6.9
679 0 ▶ 'URL:HOST' => sub { (split_url($_[0]->url))[2] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
680 0 ▶ 'URL:PORT' => sub { (split_url($_[0]->url))[3] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
681 0 ▶ 'URL:PATH' => sub { (split_url($_[0]->url))[4] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
682 0 ▶ 'URL:QUERY' => sub { (split_url($_[0]->url))[5] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
683 0 ▶ 'URL:HASH' => sub { (split_url($_[0]->url))[6] }, # non-standard
Subroutine __ANON__: not called CC=1 SCAR=6.9
684 0 ▶ 'URL:FRAGMENT' => sub { (split_url($_[0]->url))[6] }, # non-standard
Subroutine __ANON__: not called CC=1 SCAR=6.9
685 0 ▶ 'URL:USERINFO' => sub { (split_url($_[0]->url))[1] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
686 0 ▶ 'URL:USERNAME' => sub { (split_url($_[0]->url))[7] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
687 0 ▶ 'URL:PASSWORD' => sub { (split_url($_[0]->url))[8] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
688 0 ▶ 'UUID' => sub { local $_ = format_uuid($_[0]->uuid); s/-//g; $_ },
Subroutine __ANON__: not called CC=1 SCAR=6.9
689 8 ▶ 'REF:' => sub { $_[0]->kdbx->resolve_reference($_[1]) },
Subroutine __ANON__: called CC=1 SCAR=0.0
690 0 ▶ 'INTERNETEXPLORER' => sub { load_optional('IPC::Cmd'); IPC::Cmd::can_run('iexplore') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
691 0 ▶ 'FIREFOX' => sub { load_optional('IPC::Cmd'); IPC::Cmd::can_run('firefox') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
692 0 ▶ 'GOOGLECHROME' => sub { load_optional('IPC::Cmd'); IPC::Cmd::can_run('google-chrome') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
693 0 ▶ 'OPERA' => sub { load_optional('IPC::Cmd'); IPC::Cmd::can_run('opera') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
694 0 ▶ 'SAFARI' => sub { load_optional('IPC::Cmd'); IPC::Cmd::can_run('safari') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
695 0 ▶ 'APPDIR' => sub { load_optional('FindBin'); $FindBin::Bin },
Subroutine __ANON__: not called CC=1 SCAR=6.9
696 0 ▶ 'GROUP' => sub { my $p = $_[0]->group; $p ? $p->name : undef },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$p ? : 0 0 0
697 0 ▶ 'GROUP_PATH' => sub { $_[0]->path },
Subroutine __ANON__: not called CC=1 SCAR=6.9
698 0 ▶ 'GROUP_NOTES' => sub { my $p = $_[0]->group; $p ? $p->notes : undef },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$p ? : 0 0 0
699 # 'GROUP_SEL'
700 # 'GROUP_SEL_PATH'
701 # 'GROUP_SEL_NOTES'
702 # 'DB_PATH'
703 # 'DB_DIR'
704 # 'DB_NAME'
705 # 'DB_BASENAME'
706 # 'DB_EXT'
707 2 ▶ 'ENV:' => sub { $ENV{$_[1]} },
Subroutine __ANON__: called CC=1 SCAR=0.0
708 0 ▶ 'ENV_DIRSEP' => sub { load_optional('File::Spec')->catfile('', '') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
709 0 ▶ 'ENV_PROGRAMFILES_X86' => sub { $ENV{'ProgramFiles(x86)'} || $ENV{'ProgramFiles'} },
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$ENV{"ProgramFiles(x86)"} or $ENV{"ProgramFiles"} 0 0 0
710 # 'T-REPLACE-RX:'
711 # 'T-CONV:'
712 0 ▶ 'DT_SIMPLE' => sub { localtime->strftime('%Y%m%d%H%M%S') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
713 0 ▶ 'DT_YEAR' => sub { localtime->strftime('%Y') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
714 0 ▶ 'DT_MONTH' => sub { localtime->strftime('%m') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
715 0 ▶ 'DT_DAY' => sub { localtime->strftime('%d') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
716 0 ▶ 'DT_HOUR' => sub { localtime->strftime('%H') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
717 0 ▶ 'DT_MINUTE' => sub { localtime->strftime('%M') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
718 0 ▶ 'DT_SECOND' => sub { localtime->strftime('%S') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
719 0 ▶ 'DT_UTC_SIMPLE' => sub { gmtime->strftime('%Y%m%d%H%M%S') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
720 0 ▶ 'DT_UTC_YEAR' => sub { gmtime->strftime('%Y') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
721 0 ▶ 'DT_UTC_MONTH' => sub { gmtime->strftime('%m') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
722 0 ▶ 'DT_UTC_DAY' => sub { gmtime->strftime('%d') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
723 0 ▶ 'DT_UTC_HOUR' => sub { gmtime->strftime('%H') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
724 0 ▶ 'DT_UTC_MINUTE' => sub { gmtime->strftime('%M') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
725 0 ▶ 'DT_UTC_SECOND' => sub { gmtime->strftime('%S') },
Subroutine __ANON__: not called CC=1 SCAR=6.9
726 # 'PICKCHARS'
727 # 'PICKCHARS:'
728 # 'PICKFIELD'
729 # 'NEWPASSWORD'
730 # 'NEWPASSWORD:'
731 # 'PASSWORD_ENC'
732 0 ▶ 'HMACOTP' => sub { $_[0]->hmac_otp },
Subroutine __ANON__: not called CC=1 SCAR=6.9
733 0 ▶ 'TIMEOTP' => sub { $_[0]->time_otp },
Subroutine __ANON__: not called CC=1 SCAR=6.9
734 0 ▶ 'C:' => sub { '' }, # comment
Subroutine __ANON__: not called CC=1 SCAR=6.9
735 # 'BASE'
736 # 'BASE:'
737 # 'CLIPBOARD'
738 # 'CLIPBOARD-SET:'
739 # 'CMD:'
740 25 );
741  
742 ##############################################################################
743  
744  
745 sub _safe {
746 50 ▶ my $self = shift;
Subroutine _safe: called CC=2 SCAR=6.9
747 50 ▶ $SAFE{$self} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 12 38 50
748 50 $SAFE{$self};
749 }
750  
751 94 ▶sub _remove_safe { delete $SAFE{$_[0]} }
Subroutine _remove_safe: called CC=1 SCAR=0.0
752  
753 sub lock {
754 0 ▶ my $self = shift;
Subroutine lock: not called CC=2 SCAR=17.9
Pod documented
755  
756 0 ▶ $self->_safe and return $self;
Branch: 1 branch
BranchTrueFalseTotal
$self->_safe and return $self 0 0 0
757  
758 0 my @strings;
759  
760 $self->entries(history => 1)->each(sub {
761 0 ▶ push @strings, grep { $_->{protect} } values %{$_->strings}, values %{$_->binaries};
Subroutine __ANON__: not called CC=1 SCAR=6.9
762 0 });
763  
764 0 $self->_safe(File::KDBX::Safe->new(\@strings));
765  
766 0 return $self;
767 }
768  
769  
770 sub unlock {
771 19 ▶ my $self = shift;
Subroutine unlock: called CC=2 SCAR=6.9
Pod documented
772 19 ▶ my $safe = $self->_safe or return $self;
Branch: 1 branch
BranchTrueFalseTotal
my $safe = $self->_safe or return $self 15 4 19
773  
774 4 $safe->unlock;
775 4 $self->_remove_safe;
776  
777 4 return $self;
778 }
779  
780  
781 sub unlock_scoped {
782 15 ▶ throw 'Programmer error: Cannot call unlock_scoped in void context' if !defined wantarray;
Subroutine unlock_scoped: called CC=3 SCAR=15.7
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
unless defined wantarray 0 15 15
783 15 my $self = shift;
784 15 ▶ return if !$self->is_locked;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_locked 15 0 15
785 0 require Scope::Guard;
786 0 ▶ my $guard = Scope::Guard->new(sub { $self->lock });
Subroutine __ANON__: not called CC=1 SCAR=6.9
787 0 $self->unlock;
788 0 return $guard;
789 }
790  
791  
792 sub peek {
793 4 ▶ my $self = shift;
Subroutine peek: called CC=2 SCAR=7.0
Pod documented
794 4 my $string = shift;
795 4 ▶ my $safe = $self->_safe or return;
Branch: 1 branch
BranchTrueFalseTotal
my $safe = $self->_safe or return 0 4 4
796 4 return $safe->peek($string);
797 }
798  
799  
800 15 ▶sub is_locked { !!$_[0]->_safe }
Subroutine is_locked: called CC=1 SCAR=0.0
Pod documented
801  
802 ##############################################################################
803  
804 # sub check {
805 # - Fixer tool. Can repair inconsistencies, including:
806 # - Orphaned binaries... not really a thing anymore since we now distribute binaries amongst entries
807 # - Unused custom icons (OFF, data loss)
808 # - Duplicate icons
809 # - All data types are valid
810 # - date times are correct
811 # - boolean fields
812 # - All UUIDs refer to things that exist
813 # - previous parent group
814 # - recycle bin
815 # - last selected group
816 # - last visible group
817 # - Enforce history size limits (ON)
818 # - Check headers/meta (ON)
819 # - Duplicate deleted objects (ON)
820 # - Duplicate window associations (OFF)
821 # - Header UUIDs match known ciphers/KDFs?
822 # }
823  
824  
825 sub remove_empty_groups {
826 1 ▶ my $self = shift;
Subroutine remove_empty_groups: called CC=1 SCAR=0.0
Pod documented
827 1 my @removed;
828 $self->groups(algorithm => 'dfs')
829 ->where(-true => 'is_empty')
830 1 ▶ ->each(sub { push @removed, $_->remove });
Subroutine __ANON__: called CC=1 SCAR=0.0
831 1 return @removed;
832 }
833  
834  
835 sub remove_unused_icons {
836 2 ▶ my $self = shift;
Subroutine remove_unused_icons: called CC=2 SCAR=6.9
Pod documented
837 2 my %icons = map { $_->{uuid} => 0 } @{$self->custom_icons};
838  
839 2 ▶ $self->objects->each(sub { ++$icons{$_->custom_icon_uuid // ''} });
Subroutine __ANON__: called CC=2 SCAR=6.9
Condition100%2/2
$_->custom_icon_uuid // ""
l!l
15
MC/DC100%1/1
$_->custom_icon_uuid // ""
$_->custom_icon_uuid
Truth table100%2/2
A
A= $_->custom_icon_uuid
Aresult
11
00
840  
841 2 my @removed;
842 2 push @removed, $self->remove_custom_icon($_) for grep { $icons{$_} == 0 } keys %icons;
843 2 return @removed;
844 }
845  
846  
847 sub remove_duplicate_icons {
848 1 ▶ my $self = shift;
Subroutine remove_duplicate_icons: called CC=4 SCAR=13.9
Pod documented
849  
850 1 my %seen;
851 my %dup;
852 1 for my $icon (@{$self->custom_icons}) {
853 3 my $digest = digest_data('SHA256', $icon->{data});
854 3 ▶ if (my $other = $seen{$digest}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $other = $seen{$digest}) { } 1 2 3
855 1 $dup{$icon->{uuid}} = $other->{uuid};
856 }
857 else {
858 2 $seen{$digest} = $icon;
859 }
860 }
861  
862 1 my @removed;
863 1 ▶ while (my ($old_uuid, $new_uuid) = each %dup) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %dup) 1 1 2
864 $self->objects
865 ->where(custom_icon_uuid => $old_uuid)
866 1 ▶ ->each(sub { $_->custom_icon_uuid($new_uuid) });
Subroutine __ANON__: called CC=1 SCAR=0.0
867 1 push @removed, $self->remove_custom_icon($old_uuid);
868 }
869 1 return @removed;
870 }
871  
872  
873 sub prune_history {
874 2 ▶ my $self = shift;
Subroutine prune_history: called CC=7 SCAR=22.6
Pod documented
875 2 my %args = @_;
876  
877 2 ▶ my $max_items = $args{max_items} // $self->history_max_items // HISTORY_DEFAULT_MAX_ITEMS;
Condition40%2/5
($args{"max_items"} // $self->history_max_items) // 10
l!l
20
$args{"max_items"} // $self->history_max_items
l!l&&r!l&&!r
020
MC/DC0%0/2
($args{"max_items"} // $self->history_max_items) // 10
$args{"max_items"} $self->history_max_items
Truth table33%1/3
A // B
A= $args{"max_items"}B= $self->history_max_items
ABresult
1X1
011
000
878 2 ▶ my $max_size = $args{max_size} // $self->history_max_size // HISTORY_DEFAULT_MAX_SIZE;
Condition40%2/5
($args{"max_size"} // $self->history_max_size) // 6291456
l!l
20
$args{"max_size"} // $self->history_max_size
l!l&&r!l&&!r
020
MC/DC0%0/2
($args{"max_size"} // $self->history_max_size) // 6291456
$args{"max_size"} $self->history_max_size
Truth table33%1/3
A // B
A= $args{"max_size"}B= $self->history_max_size
ABresult
1X1
011
000
879 2 ▶ my $max_age = $args{max_age} // $self->maintenance_history_days // HISTORY_DEFAULT_MAX_AGE;
Condition40%2/5
($args{"max_age"} // $self->maintenance_history_days) // 365
l!l
20
$args{"max_age"} // $self->maintenance_history_days
l!l&&r!l&&!r
200
MC/DC0%0/2
($args{"max_age"} // $self->maintenance_history_days) // 365
$args{"max_age"} $self->maintenance_history_days
Truth table33%1/3
A // B
A= $args{"max_age"}B= $self->maintenance_history_days
ABresult
1X1
011
000
880  
881 2 my @removed;
882 $self->entries->each(sub {
883 2 ▶ push @removed, $_->prune_history(
Subroutine __ANON__: called CC=1 SCAR=0.0
884 max_items => $max_items,
885 max_size => $max_size,
886 max_age => $max_age,
887 );
888 2 });
889 2 return @removed;
890 }
891  
892  
893 sub randomize_seeds {
894 14 ▶ my $self = shift;
Subroutine randomize_seeds: called CC=1 SCAR=0.0
Pod documented
895 14 $self->encryption_iv(random_bytes(16));
896 14 $self->inner_random_stream_key(random_bytes(64));
897 14 $self->master_seed(random_bytes(32));
898 14 $self->stream_start_bytes(random_bytes(32));
899 14 $self->transform_seed(random_bytes(32));
900 }
901  
902 ##############################################################################
903  
904  
905 sub key {
906 36 ▶ my $self = shift;
Subroutine key: called CC=2 SCAR=7.1
Pod documented
907 36 ▶ $KEYS{$self} = File::KDBX::Key->new(@_) if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 36 0 36
908 36 $KEYS{$self};
909 }
910  
911  
912 sub composite_key {
913 45 ▶ my $self = shift;
Subroutine composite_key: called CC=1 SCAR=0.0
Pod documented
914 45 require File::KDBX::Key::Composite;
915 45 return File::KDBX::Key::Composite->new(@_);
916 }
917  
918  
919 sub kdf {
920 173 ▶ my $self = shift;
Subroutine kdf: called CC=11 SCAR=27.2
Pod documented
921 173 ▶ my %args = @_ % 2 == 1 ? (params => shift, @_) : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ % 2 == 1 ? : 0 173 173
922  
923 173 my $params = $args{params};
924 173 ▶ my $compat = $args{compatible} // 1;
Condition50%1/2
$args{"compatible"} // 1
l!l
0173
MC/DC0%0/1
$args{"compatible"} // 1
$args{"compatible"}
Truth table50%1/2
A
A= $args{"compatible"}
Aresult
11
00
925  
926 173 ▶ $params //= $self->kdf_parameters;
Condition33%1/3
$params //= $self->kdf_parameters
l!l&&r!l&&!r
01730
MC/DC0%0/2
$params //= $self->kdf_parameters
$params $self->kdf_parameters
Truth table33%1/3
A //= B
A= $paramsB= $self->kdf_parameters
ABresult
1X1
011
000
927 173 ▶ $params = {%{$params || {}}};
Branch: 1 branch
BranchTrueFalseTotal
$params or {} 0 173 173
928  
929 173 ▶ if (empty $params || !defined $params->{+KDF_PARAM_UUID}) {
Branch: 1 branch
BranchTrueFalseTotal
if (empty($params || !defined($params->{"\$UUID"}))) 0 173 173
Condition33%1/3
$params || !defined($params->{'$UUID'})
l!l&&r!l&&!r
17300
MC/DC0%0/2
$params || !defined($params->{'$UUID'})
$params !defined($params->{'$UUID'})
Truth table33%1/3
A || not(B)
A= $paramsB= !defined($params->{'$UUID'})
ABresult
1X1
011
000
930 0 $params->{+KDF_PARAM_UUID} = KDF_UUID_AES;
931 }
932 173 ▶ if ($params->{+KDF_PARAM_UUID} eq KDF_UUID_AES) {
Branch: 1 branch
BranchTrueFalseTotal
if ($params->{"\$UUID"} eq "\311\331\363\232b\212D`\277t\r\b\301\212O\352") 155 18 173
933 # AES_CHALLENGE_RESPONSE is equivalent to AES if there are no challenge-response keys, and since
934 # non-KeePassXC implementations don't support challenge-response keys anyway, there's no problem with
935 # always using AES_CHALLENGE_RESPONSE for all KDBX4+ databases.
936 # For compatibility, we should not *write* AES_CHALLENGE_RESPONSE, but the dumper handles that.
937 155 ▶ if ($self->version >= KDBX_VERSION_4_0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->version >= 262144) 19 136 155
938 19 $params->{+KDF_PARAM_UUID} = KDF_UUID_AES_CHALLENGE_RESPONSE;
939 }
940 155 ▶ $params->{+KDF_PARAM_AES_SEED} //= $self->transform_seed;
Condition33%1/3
$params->{"S"} //= $self->transform_seed
l!l&&r!l&&!r
15500
MC/DC0%0/2
$params->{"S"} //= $self->transform_seed
$params->{"S"} $self->transform_seed
Truth table33%1/3
A //= B
A= $params->{"S"}B= $self->transform_seed
ABresult
1X1
011
000
941 155 ▶ $params->{+KDF_PARAM_AES_ROUNDS} //= $self->transform_rounds;
Condition33%1/3
$params->{"R"} //= $self->transform_rounds
l!l&&r!l&&!r
15500
MC/DC0%0/2
$params->{"R"} //= $self->transform_rounds
$params->{"R"} $self->transform_rounds
Truth table33%1/3
A //= B
A= $params->{"R"}B= $self->transform_rounds
ABresult
1X1
011
000
942 }
943  
944 173 require File::KDBX::KDF;
945 173 return File::KDBX::KDF->new(%$params);
946 }
947  
948 sub transform_seed {
949 81 ▶ my $self = shift;
Subroutine transform_seed: called CC=3 SCAR=11.4
Pod documented
950 $self->headers->{+HEADER_TRANSFORM_SEED} =
951 81 ▶ $self->headers->{+HEADER_KDF_PARAMETERS}{+KDF_PARAM_AES_SEED} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 14 67 81
952 $self->headers->{+HEADER_TRANSFORM_SEED} =
953 81 ▶ $self->headers->{+HEADER_KDF_PARAMETERS}{+KDF_PARAM_AES_SEED} //= random_bytes(32);
Condition33%1/3
$self->headers->{"kdf_parameters"}{"S"} //= &random_bytes(32)
l!l&&r!l&&!r
8100
MC/DC0%0/2
$self->headers->{"kdf_parameters"}{"S"} //= &random_bytes(32)
$self->headers->{"kdf_parameters"}{"S"} &random_bytes(32)
Truth table33%1/3
A //= B
A= $self->headers->{"kdf_parameters"}{"S"}B= &random_bytes(32)
ABresult
1X1
011
000
954 }
955  
956 sub transform_rounds {
957 67 ▶ my $self = shift;
Subroutine transform_rounds: called CC=3 SCAR=11.7
Pod documented
958 $self->headers->{+HEADER_TRANSFORM_ROUNDS} =
959 67 ▶ $self->headers->{+HEADER_KDF_PARAMETERS}{+KDF_PARAM_AES_ROUNDS} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 67 67
960 $self->headers->{+HEADER_TRANSFORM_ROUNDS} =
961 67 ▶ $self->headers->{+HEADER_KDF_PARAMETERS}{+KDF_PARAM_AES_ROUNDS} //= 100_000;
Condition50%1/2
$self->headers->{"kdf_parameters"}{"R"} //= 100000
l!l
670
MC/DC0%0/1
$self->headers->{"kdf_parameters"}{"R"} //= 100000
$self->headers->{"kdf_parameters"}{"R"}
Truth table50%1/2
A
A= $self->headers->{"kdf_parameters"}{"R"}
Aresult
11
00
962 }
963  
964  
965 sub cipher {
966 39 ▶ my $self = shift;
Subroutine cipher: called CC=3 SCAR=12.0
Pod documented
967 39 my %args = @_;
968  
969 39 ▶ $args{uuid} //= $self->headers->{+HEADER_CIPHER_ID};
Condition33%1/3
$args{"uuid"} //= $self->headers->{"cipher_id"}
l!l&&r!l&&!r
0390
MC/DC0%0/2
$args{"uuid"} //= $self->headers->{"cipher_id"}
$args{"uuid"} $self->headers->{"cipher_id"}
Truth table33%1/3
A //= B
A= $args{"uuid"}B= $self->headers->{"cipher_id"}
ABresult
1X1
011
000
970 39 ▶ $args{iv} //= $self->headers->{+HEADER_ENCRYPTION_IV};
Condition33%1/3
$args{"iv"} //= $self->headers->{"encryption_iv"}
l!l&&r!l&&!r
0390
MC/DC0%0/2
$args{"iv"} //= $self->headers->{"encryption_iv"}
$args{"iv"} $self->headers->{"encryption_iv"}
Truth table33%1/3
A //= B
A= $args{"iv"}B= $self->headers->{"encryption_iv"}
ABresult
1X1
011
000
971  
972 39 require File::KDBX::Cipher;
973 39 return File::KDBX::Cipher->new(%args);
974 }
975  
976  
977 sub random_stream {
978 18 ▶ my $self = shift;
Subroutine random_stream: called CC=4 SCAR=16.1
Pod documented
979 18 my %args = @_;
980  
981 18 ▶ $args{stream_id} //= delete $args{id} // $self->inner_random_stream_id;
Condition33%2/6
$args{"stream_id"} //= delete $args{"id"} // $self->inner_random_stream_id
l!l&&r!l&&!r
0180
delete $args{"id"} // $self->inner_random_stream_id
l!l&&r!l&&!r
0180
MC/DC0%0/3
$args{"stream_id"} //= delete $args{"id"} // $self->inner_random_stream_id
$args{"stream_id"} delete $args{"id"} $self->inner_random_stream_id
Truth table0%0/4
A //= B // C
A= $args{"stream_id"}B= delete $args{"id"}C= $self->inner_random_stream_id
ABCresult
1XX1
01X1
0011
0000
982 18 ▶ $args{key} //= $self->inner_random_stream_key;
Condition33%1/3
$args{"key"} //= $self->inner_random_stream_key
l!l&&r!l&&!r
0180
MC/DC0%0/2
$args{"key"} //= $self->inner_random_stream_key
$args{"key"} $self->inner_random_stream_key
Truth table33%1/3
A //= B
A= $args{"key"}B= $self->inner_random_stream_key
ABresult
1X1
011
000
983  
984 18 require File::KDBX::Cipher;
985 18 File::KDBX::Cipher->new(%args);
986 }
987  
988 sub inner_random_stream_id {
989 85 ▶ my $self = shift;
Subroutine inner_random_stream_id: called CC=5 SCAR=16.5
Pod documented
990 $self->inner_headers->{+INNER_HEADER_INNER_RANDOM_STREAM_ID}
991 85 ▶ = $self->headers->{+HEADER_INNER_RANDOM_STREAM_ID} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 8 77 85
992 $self->inner_headers->{+INNER_HEADER_INNER_RANDOM_STREAM_ID}
993 85 ▶ //= $self->headers->{+HEADER_INNER_RANDOM_STREAM_ID} //= do {
Condition66%4/6
$self->inner_headers->{"inner_random_stream_id"} //= ($self->headers->{"inner_random_stream_id"} //= do { my $version = $self->minimum_version; $version < 262144 ? 2 : 3 })
l!l&&r!l&&!r
17680
$self->headers->{"inner_random_stream_id"} //= do { my $version = $self->minimum_version; $version < 262144 ? 2 : 3 }
l!l&&r!l&&!r
9590
MC/DC0%0/2
$self->inner_headers->{"inner_random_stream_id"} //= ($self->headers->{"inner_random_stream_id"} //= do { my $version = $self->minimum_version; $version < 262144 ? 2 : 3 })
$self->inner_headers->{"inner_random_stream_id"} ($self->headers->{"inner_random_stream_id"} //= do { my $version = $self->minimum_version; $version < 262144 ? 2 : 3 })
MC/DC0%0/2
$self->headers->{"inner_random_stream_id"} //= do { my $version = $self->minimum_version; $version < 262144 ? 2 : 3 }
$self->headers->{"inner_random_stream_id"} do { my $version = $self->minimum_version; $version < 262144 ? 2 : 3 }
Truth table66%2/3
A //= B
A= $self->inner_headers->{"inner_random_stream_id"}B= ($self->headers->{"inner_random_stream_id"} //= do { my $version = $self->minimum_version; $version < 262144 ? 2 : 3 })
ABresult
1X1
011
000
Truth table66%2/3
A //= B
A= $self->headers->{"inner_random_stream_id"}B= do { my $version = $self->minimum_version; $version < 262144 ? 2 : 3 }
ABresult
1X1
011
000
994 59 my $version = $self->minimum_version;
995 59 ▶ $version < KDBX_VERSION_4_0 ? STREAM_ID_SALSA20 : STREAM_ID_CHACHA20;
Branch: 1 branch
BranchTrueFalseTotal
$version < 262144 ? : 59 0 59
996 };
997 }
998  
999 sub inner_random_stream_key {
1000 107 ▶ my $self = shift;
Subroutine inner_random_stream_key: called CC=4 SCAR=14.0
Pod documented
1001 107 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 22 85 107
1002 # These are probably the same SvPV so erasing one will CoW, but erasing the second should do the
1003 # trick anyway.
1004 22 erase \$self->inner_headers->{+INNER_HEADER_INNER_RANDOM_STREAM_KEY};
1005 22 erase \$self->headers->{+HEADER_INNER_RANDOM_STREAM_KEY};
1006 $self->inner_headers->{+INNER_HEADER_INNER_RANDOM_STREAM_KEY}
1007 22 = $self->headers->{+HEADER_INNER_RANDOM_STREAM_KEY} = shift;
1008 }
1009 $self->inner_headers->{+INNER_HEADER_INNER_RANDOM_STREAM_KEY}
1010 107 ▶ //= $self->headers->{+HEADER_INNER_RANDOM_STREAM_KEY} //= random_bytes(64); # 32
Condition66%4/6
$self->inner_headers->{"inner_random_stream_key"} //= ($self->headers->{"inner_random_stream_key"} //= &random_bytes(64))
l!l&&r!l&&!r
39680
$self->headers->{"inner_random_stream_key"} //= &random_bytes(64)
l!l&&r!l&&!r
9590
MC/DC0%0/2
$self->inner_headers->{"inner_random_stream_key"} //= ($self->headers->{"inner_random_stream_key"} //= &random_bytes(64))
$self->inner_headers->{"inner_random_stream_key"} ($self->headers->{"inner_random_stream_key"} //= &random_bytes(64))
MC/DC0%0/2
$self->headers->{"inner_random_stream_key"} //= &random_bytes(64)
$self->headers->{"inner_random_stream_key"} &random_bytes(64)
Truth table66%2/3
A //= B
A= $self->inner_headers->{"inner_random_stream_key"}B= ($self->headers->{"inner_random_stream_key"} //= &random_bytes(64))
ABresult
1X1
011
000
Truth table66%2/3
A //= B
A= $self->headers->{"inner_random_stream_key"}B= &random_bytes(64)
ABresult
1X1
011
000
1011 }
1012  
1013 #########################################################################################
1014  
1015 sub _handle_signal {
1016 68 ▶ my $self = shift;
Subroutine _handle_signal: called CC=2 SCAR=7.0
1017 68 my $object = shift;
1018 68 my $type = shift;
1019  
1020 68 my %handlers = (
1021 'entry.added' => \&_handle_object_added,
1022 'group.added' => \&_handle_object_added,
1023 'entry.removed' => \&_handle_object_removed,
1024 'group.removed' => \&_handle_object_removed,
1025 'entry.uuid.changed' => \&_handle_entry_uuid_changed,
1026 'group.uuid.changed' => \&_handle_group_uuid_changed,
1027 );
1028 68 ▶ my $handler = $handlers{$type} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $handler = $handlers{$type} or return 0 68 68
1029 68 $self->$handler($object, @_);
1030 }
1031  
1032 sub _handle_object_added {
1033 48 ▶ my $self = shift;
Subroutine _handle_object_added: called CC=1 SCAR=0.0
1034 48 my $object = shift;
1035 48 $self->remove_deleted_object($object->uuid);
1036 }
1037  
1038 sub _handle_object_removed {
1039 6 ▶ my $self = shift;
Subroutine _handle_object_removed: called CC=10 SCAR=26.2
1040 6 my $object = shift;
1041 6 ▶ my $old_uuid = $object->{uuid} // return;
Condition50%1/2
$object->{"uuid"} // (return)
l!l
60
MC/DC0%0/1
$object->{"uuid"} // (return)
$object->{"uuid"}
Truth table50%1/2
A
A= $object->{"uuid"}
Aresult
11
00
1042  
1043 6 my $meta = $self->meta;
1044 6 ▶ $self->recycle_bin_uuid(UUID_NULL) if $old_uuid eq ($meta->{recycle_bin_uuid} // '');
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($meta->{"recycle_bin_uuid"} // "") 0 6 6
Condition50%1/2
$meta->{"recycle_bin_uuid"} // ""
l!l
60
MC/DC0%0/1
$meta->{"recycle_bin_uuid"} // ""
$meta->{"recycle_bin_uuid"}
Truth table50%1/2
A
A= $meta->{"recycle_bin_uuid"}
Aresult
11
00
1045 6 ▶ $self->entry_templates_group(UUID_NULL) if $old_uuid eq ($meta->{entry_templates_group} // '');
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($meta->{"entry_templates_group"} // "") 0 6 6
Condition50%1/2
$meta->{"entry_templates_group"} // ""
l!l
60
MC/DC0%0/1
$meta->{"entry_templates_group"} // ""
$meta->{"entry_templates_group"}
Truth table50%1/2
A
A= $meta->{"entry_templates_group"}
Aresult
11
00
1046 6 ▶ $self->last_selected_group(UUID_NULL) if $old_uuid eq ($meta->{last_selected_group} // '');
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($meta->{"last_selected_group"} // "") 0 6 6
Condition50%1/2
$meta->{"last_selected_group"} // ""
l!l
60
MC/DC0%0/1
$meta->{"last_selected_group"} // ""
$meta->{"last_selected_group"}
Truth table50%1/2
A
A= $meta->{"last_selected_group"}
Aresult
11
00
1047 6 ▶ $self->last_top_visible_group(UUID_NULL) if $old_uuid eq ($meta->{last_top_visible_group} // '');
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($meta->{"last_top_visible_group"} // "") 0 6 6
Condition50%1/2
$meta->{"last_top_visible_group"} // ""
l!l
60
MC/DC0%0/1
$meta->{"last_top_visible_group"} // ""
$meta->{"last_top_visible_group"}
Truth table50%1/2
A
A= $meta->{"last_top_visible_group"}
Aresult
11
00
1048  
1049 6 $self->add_deleted_object($old_uuid);
1050 }
1051  
1052 sub _handle_entry_uuid_changed {
1053 13 ▶ my $self = shift;
Subroutine _handle_entry_uuid_changed: called CC=2 SCAR=7.0
1054 13 my $object = shift;
1055 13 my $new_uuid = shift;
1056 13 ▶ my $old_uuid = shift // return;
Condition50%1/2
shift() // (return)
l!l
130
MC/DC0%0/1
shift() // (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1057  
1058 13 my $old_pretty = format_uuid($old_uuid);
1059 13 my $new_pretty = format_uuid($new_uuid);
1060 13 my $fieldref_match = qr/\{REF:([TUPANI])\@I:\Q$old_pretty\E\}/is;
1061  
1062 $self->entries->each(sub {
1063 26 ▶ $_->previous_parent_group($new_uuid) if $old_uuid eq ($_->{previous_parent_group} // '');
Subroutine __ANON__: called CC=6 SCAR=18.3
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($_->{"previous_parent_group"} // "") 0 26 26
Condition50%1/2
$_->{"previous_parent_group"} // ""
l!l
026
MC/DC0%0/1
$_->{"previous_parent_group"} // ""
$_->{"previous_parent_group"}
Truth table50%1/2
A
A= $_->{"previous_parent_group"}
Aresult
11
00
1064  
1065 26 for my $string (values %{$_->strings}) {
1066 130 ▶ next if !defined $string->{value} || $string->{value} !~ $fieldref_match;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $string->{"value"} and $string->{"value"} =~ /$fieldref_match/ 129 1 130
Condition66%2/3
defined $string->{"value"} and $string->{"value"} =~ /$fieldref_match/
!ll&&!rl&&r
01291
MC/DC50%1/2
defined $string->{"value"} and $string->{"value"} =~ /$fieldref_match/
defined $string->{"value"} $string->{"value"} =~ /$fieldref_match/
Truth table66%2/3
A and B
A= defined $string->{"value"}B= $string->{"value"} =~ /$fieldref_match/
ABresult
0X0
100
111
1067 1 my $txn = $_->begin_work;
1068 1 $string->{value} =~ s/$fieldref_match/{REF:$1\@I:$new_pretty}/g;
1069 1 $txn->commit;
1070 }
1071 13 });
1072 }
1073  
1074 sub _handle_group_uuid_changed {
1075 1 ▶ my $self = shift;
Subroutine _handle_group_uuid_changed: called CC=10 SCAR=26.4
1076 1 my $object = shift;
1077 1 my $new_uuid = shift;
1078 1 ▶ my $old_uuid = shift // return;
Condition50%1/2
shift() // (return)
l!l
10
MC/DC0%0/1
shift() // (return)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1079  
1080 1 my $meta = $self->meta;
1081 1 ▶ $self->recycle_bin_uuid($new_uuid) if $old_uuid eq ($meta->{recycle_bin_uuid} // '');
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($meta->{"recycle_bin_uuid"} // "") 0 1 1
Condition50%1/2
$meta->{"recycle_bin_uuid"} // ""
l!l
10
MC/DC0%0/1
$meta->{"recycle_bin_uuid"} // ""
$meta->{"recycle_bin_uuid"}
Truth table50%1/2
A
A= $meta->{"recycle_bin_uuid"}
Aresult
11
00
1082 1 ▶ $self->entry_templates_group($new_uuid) if $old_uuid eq ($meta->{entry_templates_group} // '');
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($meta->{"entry_templates_group"} // "") 0 1 1
Condition50%1/2
$meta->{"entry_templates_group"} // ""
l!l
10
MC/DC0%0/1
$meta->{"entry_templates_group"} // ""
$meta->{"entry_templates_group"}
Truth table50%1/2
A
A= $meta->{"entry_templates_group"}
Aresult
11
00
1083 1 ▶ $self->last_selected_group($new_uuid) if $old_uuid eq ($meta->{last_selected_group} // '');
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($meta->{"last_selected_group"} // "") 0 1 1
Condition50%1/2
$meta->{"last_selected_group"} // ""
l!l
10
MC/DC0%0/1
$meta->{"last_selected_group"} // ""
$meta->{"last_selected_group"}
Truth table50%1/2
A
A= $meta->{"last_selected_group"}
Aresult
11
00
1084 1 ▶ $self->last_top_visible_group($new_uuid) if $old_uuid eq ($meta->{last_top_visible_group} // '');
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($meta->{"last_top_visible_group"} // "") 0 1 1
Condition50%1/2
$meta->{"last_top_visible_group"} // ""
l!l
10
MC/DC0%0/1
$meta->{"last_top_visible_group"} // ""
$meta->{"last_top_visible_group"}
Truth table50%1/2
A
A= $meta->{"last_top_visible_group"}
Aresult
11
00
1085  
1086 $self->groups->each(sub {
1087 2 ▶ $_->last_top_visible_entry($new_uuid) if $old_uuid eq ($_->{last_top_visible_entry} // '');
Subroutine __ANON__: called CC=5 SCAR=18.9
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($_->{"last_top_visible_entry"} // "") 0 2 2
Condition50%1/2
$_->{"last_top_visible_entry"} // ""
l!l
02
MC/DC0%0/1
$_->{"last_top_visible_entry"} // ""
$_->{"last_top_visible_entry"}
Truth table50%1/2
A
A= $_->{"last_top_visible_entry"}
Aresult
11
00
1088 2 ▶ $_->previous_parent_group($new_uuid) if $old_uuid eq ($_->{previous_parent_group} // '');
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($_->{"previous_parent_group"} // "") 0 2 2
Condition50%1/2
$_->{"previous_parent_group"} // ""
l!l
02
MC/DC0%0/1
$_->{"previous_parent_group"} // ""
$_->{"previous_parent_group"}
Truth table50%1/2
A
A= $_->{"previous_parent_group"}
Aresult
11
00
1089 1 });
1090 $self->entries->each(sub {
1091 3 ▶ $_->previous_parent_group($new_uuid) if $old_uuid eq ($_->{previous_parent_group} // '');
Subroutine __ANON__: called CC=3 SCAR=12.7
Branch: 1 branch
BranchTrueFalseTotal
if $old_uuid eq ($_->{"previous_parent_group"} // "") 0 3 3
Condition50%1/2
$_->{"previous_parent_group"} // ""
l!l
03
MC/DC0%0/1
$_->{"previous_parent_group"} // ""
$_->{"previous_parent_group"}
Truth table50%1/2
A
A= $_->{"previous_parent_group"}
Aresult
11
00
1092 1 });
1093 }
1094  
1095 #########################################################################################
1096  
1097  
1098 #########################################################################################
1099  
1100 0 ▶sub TO_JSON { +{%{$_[0]}} }
Subroutine TO_JSON: not called CC=1 SCAR=6.9
Pod undocumented
1101  
1102 25 1;
1103  
1104 __END__
« KDBX/Loader/KDB.pm ↑ Summary KDBX/Util.pm »