| 1 | package File::KDBX::Entry; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: A KDBX database entry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use Crypt::Misc 0.049 qw(decode_b64 encode_b32r); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use Devel::GlobalDestruction; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use Encode qw(encode); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 11 | ▶ | use File::KDBX::Constants qw(:history :icon); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | ▶ | use File::KDBX::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | ▶ | use File::KDBX::Util qw(:assert :class :coercion :erase :function :uri generate_uuid load_optional); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | ▶ | use Hash::Util::FieldHash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 11 | ▶ | use List::Util qw(any first sum0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | ▶ | use Ref::Util qw(is_coderef is_hashref is_plain_hashref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 11 | ▶ | use Scalar::Util qw(blessed looks_like_number); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 11 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 11 | ▶ | use Time::Piece 1.33; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 11 | ▶ | use boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 11 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 11 | extends 'File::KDBX::Object'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 11 | our $VERSION = '0.904'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 11 | my $PLACEHOLDER_MAX_DEPTH = 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 11 | my %PLACEHOLDERS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 11 | my %STANDARD_STRINGS = map { $_ => 1 } qw(Title UserName Password URL Notes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | sub uuid { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 449 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
uuid: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 449 | ▶ | if (@_ || !defined $self->{uuid}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ or not defined $self->{"uuid"}
MC/DC100%2/2
@_ or not defined $self->{"uuid"}
@_
not defined $self->{"uuid"}
Truth table100%3/3
A or not(B)
A= @_B= not defined $self->{"uuid"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 98 | ▶ | my %args = @_ % 2 == 1 ? (uuid => shift, @_) : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 98 | my $old_uuid = $self->{uuid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 98 | ▶ | my $uuid = $self->{uuid} = delete $args{uuid} // generate_uuid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
delete $args{"uuid"} // generate_uuid()
MC/DC0%0/2
delete $args{"uuid"} // generate_uuid()
delete $args{"uuid"}
generate_uuid()
Truth table66%2/3
A // B
A= delete $args{"uuid"}B= generate_uuid()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 98 | for my $entry (@{$self->history}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | $entry->{uuid} = $uuid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 98 | ▶ | $self->_signal('uuid.changed', $uuid, $old_uuid) if defined $old_uuid && $self->is_current; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $old_uuid and $self->is_current
MC/DC50%1/2
defined $old_uuid and $self->is_current
defined $old_uuid
$self->is_current
Truth table66%2/3
A and B
A= defined $old_uuidB= $self->is_current
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 449 | $self->{uuid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 182 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
icon_id: called CC=4 SCAR=14.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 182 | ▶ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
custom_icon_uuid: called CC=4 SCAR=14.1
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 182 | ▶ | # has uuid => sub { generate_uuid(printable => 1) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
foreground_color: called CC=4 SCAR=14.5
Pod
documented
Branch: 2 branches
Condition66%2/3
$_[0]{"icon_id"} //= $default
MC/DC0%0/2
$_[0]{"icon_id"} //= $default
$_[0]{"icon_id"}
$default
Truth table66%2/3
A //= B
A= $_[0]{"icon_id"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 98 | ▶ | has icon_id => ICON_PASSWORD, coerce => \&to_icon_constant; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
background_color: called CC=4 SCAR=15.0
Pod
documented
Branch: 2 branches
Condition100%2/2
$_[0]{"custom_icon_uuid"} //= undef
MC/DC100%1/1
$_[0]{"custom_icon_uuid"} //= undef
$_[0]{"custom_icon_uuid"}
Truth table100%2/2
A
A= $_[0]{"custom_icon_uuid"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 84 | ▶ | has custom_icon_uuid => undef, coerce => \&to_uuid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
override_url: called CC=4 SCAR=15.6
Pod
documented
Branch: 2 branches
Condition33%1/3
$_[0]{"foreground_color"} //= $default
MC/DC0%0/2
$_[0]{"foreground_color"} //= $default
$_[0]{"foreground_color"}
$default
Truth table33%1/3
A //= B
A= $_[0]{"foreground_color"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 84 | ▶ | has foreground_color => '', coerce => \&to_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tags: called CC=4 SCAR=15.2
Pod
documented
Branch: 2 branches
Condition33%1/3
$_[0]{"background_color"} //= $default
MC/DC0%0/2
$_[0]{"background_color"} //= $default
$_[0]{"background_color"}
$default
Truth table33%1/3
A //= B
A= $_[0]{"background_color"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 84 | ▶ | has background_color => '', coerce => \&to_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_type: called CC=4 SCAR=14.5
Pod
undocumented
Branch: 2 branches
Condition33%1/3
$_[0]{"override_url"} //= $default
MC/DC0%0/2
$_[0]{"override_url"} //= $default
$_[0]{"override_url"}
$default
Truth table33%1/3
A //= B
A= $_[0]{"override_url"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 87 | ▶ | has override_url => '', coerce => \&to_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
previous_parent_group: called CC=4 SCAR=14.0
Pod
documented
Branch: 2 branches
Condition66%2/3
$_[0]{"tags"} //= $default
MC/DC50%1/2
$_[0]{"tags"} //= $default
$_[0]{"tags"}
$default
Truth table66%2/3
A //= B
A= $_[0]{"tags"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 511 | ▶ | has tags => '', coerce => \&to_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quality_check: called CC=4 SCAR=14.0
Pod
documented
Branch: 2 branches
Condition100%2/2
$_[0]{"auto_type"} //= scalar &$default($_[0])
MC/DC100%1/1
$_[0]{"auto_type"} //= scalar &$default($_[0])
$_[0]{"auto_type"}
Truth table100%2/2
A
A= $_[0]{"auto_type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 113 | ▶ | has auto_type => {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strings: called CC=4 SCAR=14.3
Pod
documented
Branch: 2 branches
Condition100%2/2
$_[0]{"previous_parent_group"} //= undef
MC/DC100%1/1
$_[0]{"previous_parent_group"} //= undef
$_[0]{"previous_parent_group"}
Truth table100%2/2
A
A= $_[0]{"previous_parent_group"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 138 | ▶ | has previous_parent_group => undef, coerce => \&to_uuid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binaries: called CC=4 SCAR=14.5
Pod
documented
Branch: 2 branches
Condition66%2/3
$_[0]{"quality_check"} //= $default
MC/DC0%0/2
$_[0]{"quality_check"} //= $default
$_[0]{"quality_check"}
$default
Truth table66%2/3
A //= B
A= $_[0]{"quality_check"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 134 | ▶ | has quality_check => true, coerce => \&to_bool; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
times: called CC=4 SCAR=14.1
Pod
undocumented
Branch: 2 branches
Condition50%1/2
$_[0]{"strings"} //= scalar &$default($_[0])
MC/DC0%0/1
$_[0]{"strings"} //= scalar &$default($_[0])
$_[0]{"strings"}
Truth table50%1/2
A
A= $_[0]{"strings"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 134 | ▶ | has strings => {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$_[0]{"binaries"} //= scalar &$default($_[0])
MC/DC100%1/1
$_[0]{"binaries"} //= scalar &$default($_[0])
$_[0]{"binaries"}
Truth table100%2/2
A
A= $_[0]{"binaries"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 720 | ▶ | has binaries => {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_[0]{"times"} //= scalar &$default($_[0])
MC/DC100%1/1
$_[0]{"times"} //= scalar &$default($_[0])
$_[0]{"times"}
Truth table100%2/2
A
A= $_[0]{"times"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 11 | has times => {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 100 | ▶ | # has custom_data => {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_modification_time: called CC=4 SCAR=14.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 100 | ▶ | # has history => []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
creation_time: called CC=4 SCAR=13.9
Pod
documented
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 100 | ▶ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_access_time: called CC=4 SCAR=13.9
Pod
documented
Branch: 2 branches
Condition100%2/2
$_[0]->times->{"last_modification_time"} //= scalar &$default($_[0])
MC/DC100%1/1
$_[0]->times->{"last_modification_time"} //= scalar &$default($_[0])
$_[0]->times->{"last_modification_time"}
Truth table100%2/2
A
A= $_[0]->times->{"last_modification_time"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 87 | ▶ | has last_modification_time => sub { gmtime }, store => 'times', coerce => \&to_time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
expiry_time: called CC=4 SCAR=14.1
Pod
documented
Branch: 2 branches
Condition100%2/2
$_[0]->times->{"creation_time"} //= scalar &$default($_[0])
MC/DC100%1/1
$_[0]->times->{"creation_time"} //= scalar &$default($_[0])
$_[0]->times->{"creation_time"}
Truth table100%2/2
A
A= $_[0]->times->{"creation_time"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 92 | ▶ | has creation_time => sub { gmtime }, store => 'times', coerce => \&to_time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Subroutine
expires: called CC=4 SCAR=14.6
Pod
documented
Branch: 2 branches
Condition100%2/2
$_[0]->times->{"last_access_time"} //= scalar &$default($_[0])
MC/DC100%1/1
$_[0]->times->{"last_access_time"} //= scalar &$default($_[0])
$_[0]->times->{"last_access_time"}
Truth table100%2/2
A
A= $_[0]->times->{"last_access_time"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 84 | ▶ | has last_access_time => sub { gmtime }, store => 'times', coerce => \&to_time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Subroutine
usage_count: called CC=4 SCAR=14.8
Pod
documented
Branch: 2 branches
Condition50%1/2
$_[0]->times->{"expiry_time"} //= scalar &$default($_[0])
MC/DC0%0/1
$_[0]->times->{"expiry_time"} //= scalar &$default($_[0])
$_[0]->times->{"expiry_time"}
Truth table50%1/2
A
A= $_[0]->times->{"expiry_time"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 84 | ▶ | has expiry_time => sub { gmtime }, store => 'times', coerce => \&to_time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.4
Subroutine
location_changed: called CC=4 SCAR=14.5
Pod
documented
Branch: 2 branches
Condition33%1/3
$_[0]->times->{"expires"} //= $default
MC/DC0%0/2
$_[0]->times->{"expires"} //= $default
$_[0]->times->{"expires"}
$default
Truth table33%1/3
A //= B
A= $_[0]->times->{"expires"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 84 | ▶ | has expires => false, store => 'times', coerce => \&to_bool; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_[0]->times->{"usage_count"} //= $default
MC/DC0%0/2
$_[0]->times->{"usage_count"} //= $default
$_[0]->times->{"usage_count"}
$default
Truth table33%1/3
A //= B
A= $_[0]->times->{"usage_count"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 85 | ▶ | has usage_count => 0, store => 'times', coerce => \&to_number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_[0]->times->{"location_changed"} //= scalar &$default($_[0])
MC/DC100%1/1
$_[0]->times->{"location_changed"} //= scalar &$default($_[0])
$_[0]->times->{"location_changed"}
Truth table100%2/2
A
A= $_[0]->times->{"location_changed"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 84 | ▶ | has location_changed => sub { gmtime }, store => 'times', coerce => \&to_time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Subroutine
auto_type_obfuscation: called CC=4 SCAR=15.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 84 | ▶ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 84 | ▶ | # has 'auto_type.auto_type_enabled' => true, coerce => \&to_bool; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_type_default_sequence: called CC=4 SCAR=16.0
Pod
documented
Branch: 1 branch
Condition33%1/3
$_[0]->auto_type->{"data_transfer_obfuscation"} //= $default
MC/DC0%0/2
$_[0]->auto_type->{"data_transfer_obfuscation"} //= $default
$_[0]->auto_type->{"data_transfer_obfuscation"}
$default
Truth table33%1/3
A //= B
A= $_[0]->auto_type->{"data_transfer_obfuscation"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 84 | ▶ | has 'auto_type_obfuscation' => 0, path => 'auto_type.data_transfer_obfuscation', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 84 | ▶ | coerce => \&to_number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_type_associations: called CC=4 SCAR=14.8
Pod
documented
Branch: 1 branch
Condition33%1/3
$_[0]->auto_type->{"default_sequence"} //= $default
MC/DC0%0/2
$_[0]->auto_type->{"default_sequence"} //= $default
$_[0]->auto_type->{"default_sequence"}
$default
Truth table33%1/3
A //= B
A= $_[0]->auto_type->{"default_sequence"}B= $default
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 87 | ▶ | has 'auto_type_default_sequence' => '{USERNAME}{TAB}{PASSWORD}{ENTER}', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 87 | ▶ | path => 'auto_type.default_sequence', coerce => \&to_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_[0]->auto_type->{"associations"} //= scalar &$default($_[0])
MC/DC100%1/1
$_[0]->auto_type->{"associations"} //= scalar &$default($_[0])
$_[0]->auto_type->{"associations"}
Truth table100%2/2
A
A= $_[0]->auto_type->{"associations"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 11 | has 'auto_type_associations' => [], path => 'auto_type.associations'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 11 | my %ATTRS_STRINGS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | title => 'Title', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | username => 'UserName', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | password => 'Password', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | url => 'URL', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | notes => 'Notes', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 11 | ▶ | while (my ($attr, $string_key) = each %ATTRS_STRINGS) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 11 | ▶ | no strict 'refs'; ## no critic (ProhibitNoStrict) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 479 | ▶ | *{$attr} = sub { shift->string_value($string_key, @_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 323 | ▶ | *{"expand_${attr}"} = sub { shift->expand_string_value($string_key, @_) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 11 | my @ATTRS = qw(uuid custom_data history auto_type_enabled); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | sub _set_nonlazy_attributes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 84 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_nonlazy_attributes: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 84 | $self->$_ for @ATTRS, keys %ATTRS_STRINGS, list_attributes(ref $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 104 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 104 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 104 | ▶ | while (my ($key, $val) = each %args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 156 | ▶ | if (my $method = $self->can($key)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 154 | $self->$method($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 2 | $self->string($key => $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 104 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | sub string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1263 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string: called CC=12 SCAR=29.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1263 | ▶ | my %args = @_ == 2 ? (key => shift, value => shift) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | : @_ % 2 == 1 ? (key => shift, @_) : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1263 | ▶ | if (!defined $args{key} && !defined $args{value}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $args{"key"} or defined $args{"value"}
MC/DC0%0/2
defined $args{"key"} or defined $args{"value"}
defined $args{"key"}
defined $args{"value"}
Truth table33%1/3
A or B
A= defined $args{"key"}B= defined $args{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my %standard = (value => 1, protect => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my @other_keys = grep { !$standard{$_} } keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if (@other_keys == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $key = $args{key} = $other_keys[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $args{value} = delete $args{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1263 | ▶ | my $key = delete $args{key} or throw 'Must provide a string key to access'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1263 | ▶ | return $self->{strings}{$key} = $args{value} if is_plain_hashref($args{value}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1263 | ▶ | while (my ($field, $value) = each %args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 145 | $self->{strings}{$key}{$field} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # Auto-vivify the standard strings. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1263 | ▶ | if ($STANDARD_STRINGS{$key}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 809 | ▶ | return $self->{strings}{$key} //= {value => '', $self->_protect($key) ? (protect => true) : ()}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->{"strings"}{$key} //= {"value", "", $self->_protect($key) ? ("protect", &true()) : ()}
MC/DC100%1/1
$self->{"strings"}{$key} //= {"value", "", $self->_protect($key) ? ("protect", &true()) : ()}
$self->{"strings"}{$key}
Truth table100%2/2
A
A= $self->{"strings"}{$key}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 454 | return $self->{strings}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ### Get whether or not a standard string is configured to be protected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | sub _protect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 348 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_protect: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 348 | my $key = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 348 | ▶ | return false if !$STANDARD_STRINGS{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 348 | ▶ | if (my $kdbx = eval { $self->kdbx }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 89 | my $protect = $kdbx->memory_protection($key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 89 | ▶ | return $protect if defined $protect; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 259 | return $key eq 'Password'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | sub string_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 875 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string_value: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 875 | ▶ | my $string = $self->string(@_) // return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->string(@_) // (return undef)
MC/DC100%1/1
$self->string(@_) // (return undef)
$self->string(@_)
Truth table100%2/2
A
A= $self->string(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 599 | return $string->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | sub _expand_placeholder { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 43 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_placeholder: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 43 | my $placeholder = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 43 | my $arg = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 43 | require File::KDBX; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 43 | my $placeholder_key = $placeholder; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 43 | ▶ | if (defined $arg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 12 | ▶ | $placeholder_key = $File::KDBX::PLACEHOLDERS{"${placeholder}:${arg}"} ? "${placeholder}:${arg}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | : "${placeholder}:"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 43 | ▶ | return if !defined $File::KDBX::PLACEHOLDERS{$placeholder_key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 42 | my $local_key = join('/', Hash::Util::FieldHash::id($self), $placeholder_key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 42 | ▶ | local $PLACEHOLDERS{$local_key} = my $handler = $PLACEHOLDERS{$local_key} // do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$PLACEHOLDERS{$local_key} // do {
my $handler = $File::KDBX::PLACEHOLDERS{$placeholder_key} or next;
memoize(recurse_limit($handler, $PLACEHOLDER_MAX_DEPTH, sub {
alert("Detected deep recursion while expanding $placeholder placeholder", "placeholder", $placeholder);
return;
}
))
}
MC/DC0%0/2
$PLACEHOLDERS{$local_key} // do {
my $handler = $File::KDBX::PLACEHOLDERS{$placeholder_key} or next;
memoize(recurse_limit($handler, $PLACEHOLDER_MAX_DEPTH, sub {
alert("Detected deep recursion while expanding $placeholder placeholder", "placeholder", $placeholder);
return;
}
))
}
$PLACEHOLDERS{$local_key}
do {
my $handler = $File::KDBX::PLACEHOLDERS{$placeholder_key} or next;
memoize(recurse_limit($handler, $PLACEHOLDER_MAX_DEPTH, sub {
alert("Detected deep recursion while expanding $placeholder placeholder", "placeholder", $placeholder);
return;
}
))
}
Truth table66%2/3
A // B
A= $PLACEHOLDERS{$local_key}B= do {
my $handler = $File::KDBX::PLACEHOLDERS{$placeholder_key} or next;
memoize(recurse_limit($handler, $PLACEHOLDER_MAX_DEPTH, sub {
alert("Detected deep recursion while expanding $placeholder placeholder", "placeholder", $placeholder);
return;
}
))
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 23 | ▶ | my $handler = $File::KDBX::PLACEHOLDERS{$placeholder_key} or next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | memoize recurse_limit($handler, $PLACEHOLDER_MAX_DEPTH, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | ▶ | alert "Detected deep recursion while expanding $placeholder placeholder", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | placeholder => $placeholder; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | return; # undef | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 23 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 42 | return $handler->($self, $arg, $placeholder); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | sub _expand_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 323 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_string: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 323 | my $str = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 323 | my $expand = memoize $self->can('_expand_placeholder'), $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # placeholders (including field references): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 323 | ▶ | $str =~ s!\{([^:\}]+)(?::([^\}]*))?\}!$expand->(uc($1), $2, @_) // $&!egi; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
&$expand(uc $1, $2, @_) // $&
MC/DC0%0/2
&$expand(uc $1, $2, @_) // $&
&$expand(uc $1, $2, @_)
$&
Truth table66%2/3
A // B
A= &$expand(uc $1, $2, @_)B= $&
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # environment variables (alt syntax): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 323 | my $vars = join('|', map { quotemeta($_) } keys %ENV); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 323 | ▶ | $str =~ s!\%($vars)\%!$expand->(ENV => $1, @_) // $&!eg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
&$expand("ENV", $1, @_) // $&
MC/DC0%0/2
&$expand("ENV", $1, @_) // $&
&$expand("ENV", $1, @_)
$&
Truth table33%1/3
A // B
A= &$expand("ENV", $1, @_)B= $&
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 323 | return $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | sub expand_string_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 323 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_string_value: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 323 | ▶ | my $str = $self->string_peek(@_) // return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->string_peek(@_) // (return undef)
MC/DC0%0/1
$self->string_peek(@_) // (return undef)
$self->string_peek(@_)
Truth table50%1/2
A
A= $self->string_peek(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 323 | my $cleanup = erase_scoped $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 323 | return $self->_expand_string($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | sub other_strings { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
other_strings: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 5 | ▶ | my $delim = shift // "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // "\n"
MC/DC0%0/1
shift() // "\n"
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 5 | my @strings = map { $self->string_value($_) } grep { !$STANDARD_STRINGS{$_} } sort keys %{$self->strings}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | return join($delim, @strings); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | sub string_peek { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 325 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string_peek: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 325 | my $string = $self->string(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 325 | ▶ | return defined $string->{value} ? $string->{value} : $self->kdbx->peek($string); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | sub add_auto_type_association { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_auto_type_association: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | my $association = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | push @{$self->auto_type_associations}, $association; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | sub expand_keystroke_sequence { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expand_keystroke_sequence: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my $association = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $keys; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | if ($association) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | $keys = is_hashref($association) && exists $association->{keystroke_sequence} ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | $association->{keystroke_sequence} : defined $association ? $association : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
Ref::Util::XS::is_hashref($association) and exists $association->{"keystroke_sequence"}
MC/DC0%0/2
Ref::Util::XS::is_hashref($association) and exists $association->{"keystroke_sequence"}
Ref::Util::XS::is_hashref($association)
exists $association->{"keystroke_sequence"}
Truth table0%0/3
A and B
A= Ref::Util::XS::is_hashref($association)B= exists $association->{"keystroke_sequence"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | $keys = $self->auto_type_default_sequence if !$keys; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # TODO - Fall back to getting default sequence from parent group, which probably means we shouldn't be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # setting a default value in the entry.. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | return $self->_expand_string($keys); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | sub binary { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binary: called CC=9 SCAR=32.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 3 | ▶ | my %args = @_ == 2 ? (key => shift, value => shift) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | : @_ % 2 == 1 ? (key => shift, @_) : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 3 | ▶ | if (!defined $args{key} && !defined $args{value}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $args{"key"} or defined $args{"value"}
MC/DC0%0/2
defined $args{"key"} or defined $args{"value"}
defined $args{"key"}
defined $args{"value"}
Truth table33%1/3
A or B
A= defined $args{"key"}B= defined $args{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my %standard = (value => 1, protect => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my @other_keys = grep { !$standard{$_} } keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if (@other_keys == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $key = $args{key} = $other_keys[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $args{value} = delete $args{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 3 | ▶ | my $key = delete $args{key} or throw 'Must provide a binary key to access'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 3 | ▶ | return $self->{binaries}{$key} = $args{value} if is_plain_hashref($args{value}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | ▶ | assert { !defined $args{value} || !utf8::is_utf8($args{value}) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
Condition0%0/3
defined $args{'value'} && utf8::is_utf8($args{'value'})
MC/DC0%0/2
defined $args{'value'} && utf8::is_utf8($args{'value'})
defined $args{'value'}
utf8::is_utf8($args{'value'})
Truth table0%0/3
A && B
A= defined $args{'value'}B= utf8::is_utf8($args{'value'})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 3 | ▶ | while (my ($field, $value) = each %args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $self->{binaries}{$key}{$field} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 3 | return $self->{binaries}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | sub binary_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
binary_value: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | ▶ | my $binary = $self->binary(@_) // return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->binary(@_) // (return undef)
MC/DC0%0/1
$self->binary(@_) // (return undef)
$self->binary(@_)
Truth table50%1/2
A
A= $self->binary(@_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | return $binary->{value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | sub hmac_otp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 27 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hmac_otp: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 27 | load_optional('Pass::OTP'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 27 | my %params = ($self->_hotp_params, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 27 | ▶ | return if !defined $params{type} || !defined $params{secret}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $params{"type"} and defined $params{"secret"}
MC/DC0%0/2
defined $params{"type"} and defined $params{"secret"}
defined $params{"type"}
defined $params{"secret"}
Truth table33%1/3
A and B
A= defined $params{"type"}B= defined $params{"secret"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 27 | ▶ | $params{secret} = encode_b32r($params{secret}) if !$params{base32}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 27 | $params{base32} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 27 | my $otp = eval { Pass::OTP::otp(%params, @_) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 27 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | throw 'Unable to generate HOTP', error => $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 27 | $self->_hotp_increment_counter($params{counter}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 27 | return $otp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | sub time_otp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 10 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time_otp: called CC=5 SCAR=17.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 10 | load_optional('Pass::OTP'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 10 | my %params = ($self->_totp_params, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 10 | ▶ | return if !defined $params{type} || !defined $params{secret}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $params{"type"} and defined $params{"secret"}
MC/DC0%0/2
defined $params{"type"} and defined $params{"secret"}
defined $params{"type"}
defined $params{"secret"}
Truth table33%1/3
A and B
A= defined $params{"type"}B= defined $params{"secret"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 10 | ▶ | $params{secret} = encode_b32r($params{secret}) if !$params{base32}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 10 | $params{base32} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 10 | my $otp = eval { Pass::OTP::otp(%params, @_) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 10 | ▶ | if (my $err = $@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | throw 'Unable to generate TOTP', error => $err; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 10 | return $otp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 9 | ▶ | sub hmac_otp_uri { $_[0]->_otp_uri($_[0]->_hotp_params) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hmac_otp_uri: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 11 | ▶ | sub time_otp_uri { $_[0]->_otp_uri($_[0]->_totp_params) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time_otp_uri: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | sub _otp_uri { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 20 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_otp_uri: called CC=19 SCAR=29.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 20 | my %params = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 20 | ▶ | return if 4 != grep { defined } @params{qw(type secret issuer account)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 20 | ▶ | return if $params{type} !~ /^[ht]otp$/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 20 | my $label = delete $params{label}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 20 | $params{$_} = uri_escape_utf8($params{$_}) for keys %params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 20 | my $type = lc($params{type}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 20 | my $issuer = $params{issuer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 20 | my $account = $params{account}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 20 | ▶ | $label //= "$issuer:$account"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$label //= "${issuer}:$account"
MC/DC100%1/1
$label //= "${issuer}:$account"
$label
Truth table100%2/2
A
A= $label
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 20 | my $secret = $params{secret}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 20 | ▶ | $secret = uc(encode_b32r($secret)) if !$params{base32}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 20 | ▶ | delete $params{algorithm} if defined $params{algorithm} && $params{algorithm} eq 'sha1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $params{"algorithm"} and $params{"algorithm"} eq "sha1"
MC/DC100%2/2
defined $params{"algorithm"} and $params{"algorithm"} eq "sha1"
defined $params{"algorithm"}
$params{"algorithm"} eq "sha1"
Truth table100%3/3
A and B
A= defined $params{"algorithm"}B= $params{"algorithm"} eq "sha1"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 20 | ▶ | delete $params{period} if defined $params{period} && $params{period} == 30; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $params{"period"} and $params{"period"} == 30
MC/DC100%2/2
defined $params{"period"} and $params{"period"} == 30
defined $params{"period"}
$params{"period"} == 30
Truth table100%3/3
A and B
A= defined $params{"period"}B= $params{"period"} == 30
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 20 | ▶ | delete $params{digits} if defined $params{digits} && $params{digits} == 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $params{"digits"} and $params{"digits"} == 6
MC/DC50%1/2
defined $params{"digits"} and $params{"digits"} == 6
defined $params{"digits"}
$params{"digits"} == 6
Truth table66%2/3
A and B
A= defined $params{"digits"}B= $params{"digits"} == 6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 20 | ▶ | delete $params{counter} if defined $params{counter} && $params{counter} == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $params{"counter"} and $params{"counter"} == 0
MC/DC100%2/2
defined $params{"counter"} and $params{"counter"} == 0
defined $params{"counter"}
$params{"counter"} == 0
Truth table100%3/3
A and B
A= defined $params{"counter"}B= $params{"counter"} == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 20 | my $uri = "otpauth://$type/$label?secret=$secret&issuer=$issuer"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 20 | ▶ | if (defined $params{encoder}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 1 | $uri .= "&encoder=$params{encoder}"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | return $uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 19 | ▶ | $uri .= '&algorithm=' . uc($params{algorithm}) if defined $params{algorithm}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 19 | ▶ | $uri .= "&digits=$params{digits}" if defined $params{digits}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 19 | ▶ | $uri .= "&counter=$params{counter}" if defined $params{counter}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 19 | ▶ | $uri .= "&period=$params{period}" if defined $params{period}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 19 | return $uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | sub _hotp_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 36 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hotp_params: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 36 | ▶ | my %params = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$self->expand_title || 'KDBX'
$self->expand_username || 'none'
$self->string_value("HmacOtp-Counter") // 0
MC/DC100%1/1
$self->expand_title || 'KDBX'
$self->expand_title
MC/DC100%1/1
$self->expand_username || 'none'
$self->expand_username
MC/DC100%1/1
$self->string_value("HmacOtp-Counter") // 0
$self->string_value("HmacOtp-Counter")
Truth table100%2/2
A
A= $self->expand_title
Truth table100%2/2
A
A= $self->expand_username
Truth table100%2/2
A
A= $self->string_value("HmacOtp-Counter")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | type => 'hotp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | issuer => $self->expand_title || 'KDBX', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | account => $self->expand_username || 'none', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | digits => 6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | counter => $self->string_value('HmacOtp-Counter') // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | $self->_otp_secret_params('Hmac'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 36 | ▶ | return %params if $params{secret}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 12 | my %otp_params = $self->_otp_params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 12 | ▶ | return () if !$otp_params{secret} || $otp_params{type} ne 'hotp'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $otp_params{"secret"} or $otp_params{"type"} ne "hotp"
MC/DC0%0/2
not $otp_params{"secret"} or $otp_params{"type"} ne "hotp"
not $otp_params{"secret"}
$otp_params{"type"} ne "hotp"
Truth table33%1/3
not(A) or B
A= not $otp_params{"secret"}B= $otp_params{"type"} ne "hotp"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | # $otp_params{counter} = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 12 | return (%params, %otp_params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | sub _totp_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 21 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_totp_params: called CC=10 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 21 | my %algorithms = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 'HMAC-SHA-1' => 'sha1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 'HMAC-SHA-256' => 'sha256', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 'HMAC-SHA-512' => 'sha512', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | my %params = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | type => 'totp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | issuer => $self->expand_title || 'KDBX', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | account => $self->expand_username || 'none', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | digits => $self->string_value('TimeOtp-Length') // 6, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 21 | ▶ | algorithm => $algorithms{$self->string_value('TimeOtp-Algorithm') || ''} || 'sha1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%12/12
$self->expand_title || 'KDBX'
$self->expand_username || 'none'
$self->string_value("TimeOtp-Length") // 6
$algorithms{$self->string_value('TimeOtp-Algorithm') or ''} || 'sha1'
$self->string_value('TimeOtp-Algorithm') || ''
$self->string_value("TimeOtp-Period") // 30
MC/DC100%1/1
$self->expand_title || 'KDBX'
$self->expand_title
MC/DC100%1/1
$self->expand_username || 'none'
$self->expand_username
MC/DC100%1/1
$self->string_value("TimeOtp-Length") // 6
$self->string_value("TimeOtp-Length")
MC/DC100%1/1
$algorithms{$self->string_value('TimeOtp-Algorithm') or ''} || 'sha1'
$algorithms{$self->string_value('TimeOtp-Algorithm') or ''}
MC/DC100%1/1
$self->string_value('TimeOtp-Algorithm') || ''
$self->string_value('TimeOtp-Algorithm')
MC/DC100%1/1
$self->string_value("TimeOtp-Period") // 30
$self->string_value("TimeOtp-Period")
Truth table100%2/2
A
A= $self->expand_title
Truth table100%2/2
A
A= $self->expand_username
Truth table100%2/2
A
A= $self->string_value("TimeOtp-Length")
Truth table100%2/2
A
A= $algorithms{$self->string_value('TimeOtp-Algorithm') or ''}
Truth table100%2/2
A
A= $self->string_value('TimeOtp-Algorithm')
Truth table100%2/2
A
A= $self->string_value("TimeOtp-Period")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | period => $self->string_value('TimeOtp-Period') // 30, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | $self->_otp_secret_params('Time'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 21 | ▶ | return %params if $params{secret}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 10 | my %otp_params = $self->_otp_params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 10 | ▶ | return () if !$otp_params{secret} || $otp_params{type} ne 'totp'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $otp_params{"secret"} or $otp_params{"type"} ne "totp"
MC/DC0%0/2
not $otp_params{"secret"} or $otp_params{"type"} ne "totp"
not $otp_params{"secret"}
$otp_params{"type"} ne "totp"
Truth table33%1/3
not(A) or B
A= not $otp_params{"secret"}B= $otp_params{"type"} ne "totp"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 10 | return (%params, %otp_params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # KeePassXC style | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | sub _otp_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 22 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_otp_params: called CC=12 SCAR=26.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 22 | load_optional('Pass::OTP::URI'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 22 | ▶ | my $uri = $self->string_value('otp') || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->string_value('otp') || ''
MC/DC0%0/1
$self->string_value('otp') || ''
$self->string_value('otp')
Truth table50%1/2
A
A= $self->string_value('otp')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 22 | my %params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 22 | ▶ | %params = Pass::OTP::URI::parse($uri) if $uri =~ m!^otpauth://!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 22 | ▶ | return () if !$params{secret} || !$params{type}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$params{"secret"} and $params{"type"}
MC/DC0%0/2
$params{"secret"} and $params{"type"}
$params{"secret"}
$params{"type"}
Truth table33%1/3
A and B
A= $params{"secret"}B= $params{"type"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 22 | ▶ | if (($params{encoder} // '') eq 'steam') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$params{"encoder"} // ""
MC/DC100%1/1
$params{"encoder"} // ""
$params{"encoder"}
Truth table100%2/2
A
A= $params{"encoder"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 2 | $params{digits} = 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 2 | $params{chars} = '23456789BCDFGHJKMNPQRTVWXY'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # Pass::OTP::URI doesn't provide the issuer and account separately, so get them from the label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 22 | ▶ | my ($issuer, $user) = split(':', $params{label} // ':', 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$params{"label"} // ":"
MC/DC0%0/1
$params{"label"} // ":"
$params{"label"}
Truth table50%1/2
A
A= $params{"label"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 22 | ▶ | $params{issuer} //= uri_unescape_utf8($issuer); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$params{"issuer"} //= uri_unescape_utf8($issuer)
MC/DC0%0/2
$params{"issuer"} //= uri_unescape_utf8($issuer)
$params{"issuer"}
uri_unescape_utf8($issuer)
Truth table66%2/3
A //= B
A= $params{"issuer"}B= uri_unescape_utf8($issuer)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 22 | ▶ | $params{account} //= uri_unescape_utf8($user); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$params{"account"} //= uri_unescape_utf8($user)
MC/DC0%0/2
$params{"account"} //= uri_unescape_utf8($user)
$params{"account"}
uri_unescape_utf8($user)
Truth table33%1/3
A //= B
A= $params{"account"}B= uri_unescape_utf8($user)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 22 | ▶ | $params{algorithm} = lc($params{algorithm}) if $params{algorithm}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 22 | ▶ | $params{counter} = $self->string_value('HmacOtp-Counter') if $params{type} eq 'hotp'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 22 | return %params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | sub _otp_secret_params { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 57 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_otp_secret_params: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 57 | ▶ | my $type = shift // return (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // (return ())
MC/DC0%0/1
shift() // (return ())
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 57 | my $secret_txt = $self->string_value("${type}Otp-Secret"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 57 | my $secret_hex = $self->string_value("${type}Otp-Secret-Hex"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 57 | my $secret_b32 = $self->string_value("${type}Otp-Secret-Base32"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 57 | my $secret_b64 = $self->string_value("${type}Otp-Secret-Base64"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 57 | my $count = grep { defined } ($secret_txt, $secret_hex, $secret_b32, $secret_b64); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 57 | ▶ | return () if $count == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 35 | ▶ | alert "Found multiple ${type}Otp-Secret strings", count => $count if 1 < $count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 35 | ▶ | return (secret => $secret_b32, base32 => 1) if defined $secret_b32; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 20 | ▶ | return (secret => decode_b64($secret_b64)) if defined $secret_b64; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 16 | ▶ | return (secret => pack('H*', $secret_hex)) if defined $secret_hex; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 12 | return (secret => encode('UTF-8', $secret_txt)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | sub _hotp_increment_counter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 27 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_hotp_increment_counter: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 27 | ▶ | my $counter = shift // $self->string_value('HmacOtp-Counter') || 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
(shift() // $self->string_value('HmacOtp-Counter')) || 0
shift() // $self->string_value("HmacOtp-Counter")
MC/DC50%1/2
(shift() // $self->string_value('HmacOtp-Counter')) || 0
shift()
$self->string_value("HmacOtp-Counter")
Truth table66%2/3
A // B
A= shift()B= $self->string_value("HmacOtp-Counter")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 27 | ▶ | looks_like_number($counter) or throw 'HmacOtp-Counter value must be a number', value => $counter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 27 | my $next = $counter + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 27 | $self->string('HmacOtp-Counter', $next); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 27 | return $next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | sub size { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
size: called CC=14 SCAR=36.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 3 | my $size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | # tags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 3 | ▶ | $size += length(encode('UTF-8', $self->tags // '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->tags // ""
MC/DC0%0/1
$self->tags // ""
$self->tags
Truth table50%1/2
A
A= $self->tags
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # attributes (strings) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 3 | ▶ | while (my ($key, $string) = each %{$self->strings}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 15 | ▶ | next if !defined $string->{value}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 15 | ▶ | $size += length(encode('UTF-8', $key)) + length(encode('UTF-8', $string->{value} // '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$string->{"value"} // ""
MC/DC0%0/1
$string->{"value"} // ""
$string->{"value"}
Truth table50%1/2
A
A= $string->{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # custom data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 3 | ▶ | while (my ($key, $item) = each %{$self->custom_data}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | next if !defined $item->{value}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | ▶ | $size += length(encode('UTF-8', $key)) + length(encode('UTF-8', $item->{value} // '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$item->{"value"} // ""
MC/DC0%0/1
$item->{"value"} // ""
$item->{"value"}
Truth table0%0/2
A
A= $item->{"value"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # binaries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 3 | ▶ | while (my ($key, $binary) = each %{$self->binaries}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | next if !defined $binary->{value}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | my $value_len = utf8::is_utf8($binary->{value}) ? length(encode('UTF-8', $binary->{value})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | : length($binary->{value}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $size += length(encode('UTF-8', $key)) + $value_len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | # autotype associations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 3 | ▶ | for my $association (@{$self->auto_type->{associations} || []}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | $size += length(encode('UTF-8', $association->{window})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | + length(encode('UTF-8', $association->{keystroke_sequence} // '')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$association->{"keystroke_sequence"} // ""
MC/DC0%0/1
$association->{"keystroke_sequence"} // ""
$association->{"keystroke_sequence"}
Truth table0%0/2
A
A= $association->{"keystroke_sequence"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 3 | return $size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | sub history { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 280 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
history: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 280 | ▶ | my $entries = $self->{history} //= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"history"} //= []
MC/DC100%1/1
$self->{"history"} //= []
$self->{"history"}
Truth table100%2/2
A
A= $self->{"history"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 280 | ▶ | if (@$entries && !blessed($entries->[0])) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@$entries and not builtin::blessed($entries->[0])
MC/DC100%2/2
@$entries and not builtin::blessed($entries->[0])
@$entries
not builtin::blessed($entries->[0])
Truth table100%3/3
A and not(B)
A= @$entriesB= not builtin::blessed($entries->[0])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 4 | @$entries = map { $self->_wrap_entry($_, $self->kdbx) } @$entries; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 280 | ▶ | assert { !any { !blessed $_ } @$entries }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 280 | return $entries; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | sub history_size { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
history_size: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 2 | return sum0 map { $_->size } @{$self->history}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | sub prune_history { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prune_history: called CC=14 SCAR=32.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 2 | my %args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 2 | ▶ | my $max_items = $args{max_items} // eval { $self->kdbx->history_max_items } // HISTORY_DEFAULT_MAX_ITEMS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($args{"max_items"} // eval {
do {
$self->kdbx->history_max_items
}
}) // 10
$args{"max_items"} // eval {
do {
$self->kdbx->history_max_items
}
}
MC/DC0%0/2
($args{"max_items"} // eval {
do {
$self->kdbx->history_max_items
}
}) // 10
$args{"max_items"}
eval {
do {
$self->kdbx->history_max_items
}
}
Truth table33%1/3
A // B
A= $args{"max_items"}B= eval {
do {
$self->kdbx->history_max_items
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 2 | ▶ | my $max_size = $args{max_size} // eval { $self->kdbx->history_max_size } // HISTORY_DEFAULT_MAX_SIZE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($args{"max_size"} // eval {
do {
$self->kdbx->history_max_size
}
}) // 6291456
$args{"max_size"} // eval {
do {
$self->kdbx->history_max_size
}
}
MC/DC0%0/2
($args{"max_size"} // eval {
do {
$self->kdbx->history_max_size
}
}) // 6291456
$args{"max_size"}
eval {
do {
$self->kdbx->history_max_size
}
}
Truth table33%1/3
A // B
A= $args{"max_size"}B= eval {
do {
$self->kdbx->history_max_size
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 2 | ▶ | my $max_age = $args{max_age} // eval { $self->kdbx->maintenance_history_days } // HISTORY_DEFAULT_MAX_AGE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
($args{"max_age"} // eval {
do {
$self->kdbx->maintenance_history_days
}
}) // 365
$args{"max_age"} // eval {
do {
$self->kdbx->maintenance_history_days
}
}
MC/DC0%0/2
($args{"max_age"} // eval {
do {
$self->kdbx->maintenance_history_days
}
}) // 365
$args{"max_age"}
eval {
do {
$self->kdbx->maintenance_history_days
}
}
Truth table33%1/3
A // B
A= $args{"max_age"}B= eval {
do {
$self->kdbx->maintenance_history_days
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | # history is ordered oldest to newest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 2 | my $history = $self->history; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | my @removed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 2 | ▶ | if (0 <= $max_items && $max_items < @$history) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
0 <= $max_items and $max_items < @$history
MC/DC0%0/2
0 <= $max_items and $max_items < @$history
0 <= $max_items
$max_items < @$history
Truth table33%1/3
A and B
A= 0 <= $max_itemsB= $max_items < @$history
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | push @removed, splice @$history, -$max_items; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 2 | ▶ | if (0 <= $max_size) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 2 | my $current_size = $self->history_size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 2 | ▶ | while ($max_size < $current_size) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | push @removed, my $entry = shift @$history; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | $current_size -= $entry->size; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 2 | ▶ | if (0 <= $max_age) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 2 | my $cutoff = gmtime - ($max_age * 86400); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 2 | ▶ | for (my $i = @$history - 1; 0 <= $i; --$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 3 | my $entry = $history->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 3 | ▶ | next if $cutoff <= $entry->last_modification_time; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 1 | push @removed, splice @$history, $i, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 2 | @removed = sort { $a->last_modification_time <=> $b->last_modification_time } @removed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 2 | return @removed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | sub add_historical_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_historical_entry: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 8 | delete $_->{history} for @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 8 | ▶ | push @{$self->{history} //= []}, map { $self->_wrap_entry($_) } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"history"} //= []
MC/DC100%1/1
$self->{"history"} //= []
$self->{"history"}
Truth table100%2/2
A
A= $self->{"history"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | sub remove_historical_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 33 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_historical_entry: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 33 | my $entry = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 33 | my $history = $self->history; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 33 | my @removed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 33 | ▶ | for (my $i = @$history - 1; 0 <= $i; --$i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 3 | my $item = $history->[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 3 | ▶ | next if Hash::Util::FieldHash::id($entry) != Hash::Util::FieldHash::id($item); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | push @removed, splice @{$self->{history}}, $i, 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 33 | return @removed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | sub current_entry { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 50 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
current_entry: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 50 | my $parent = $self->group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 50 | ▶ | if ($parent) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 9 | my $id = $self->uuid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 9 | ▶ | my $entry = first { $id eq $_->uuid } @{$parent->entries}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 9 | ▶ | return $entry if $entry; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 41 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | sub is_current { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 16 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_current: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 16 | my $current = $self->current_entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 16 | return Hash::Util::FieldHash::id($self) == Hash::Util::FieldHash::id($current); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 1 | ▶ | sub is_historical { !$_[0]->is_current } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_historical: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | sub remove { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 33 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 33 | my $current = $self->current_entry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 33 | ▶ | return $self if $current->remove_historical_entry($self); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 33 | $self->SUPER::remove(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | sub searching_enabled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
searching_enabled: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my $parent = $self->group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | return $parent->effective_enable_searching if $parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | return true; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | sub auto_type_enabled { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 84 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_type_enabled: called CC=6 SCAR=19.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 84 | ▶ | $self->auto_type->{enabled} = to_bool(shift) if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 84 | ▶ | $self->auto_type->{enabled} //= true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->auto_type->{"enabled"} //= &true()
MC/DC0%0/2
$self->auto_type->{"enabled"} //= &true()
$self->auto_type->{"enabled"}
&true()
Truth table33%1/3
A //= B
A= $self->auto_type->{"enabled"}B= &true()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 84 | ▶ | return false if !$self->auto_type->{enabled}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 84 | ▶ | return true if !$self->is_connected; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 25 | my $parent = $self->group; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 25 | ▶ | return $parent->effective_enable_auto_type if $parent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 25 | return true; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | sub _signal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 45 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_signal: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 45 | my $type = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 45 | return $self->SUPER::_signal("entry.$type", @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | sub _commit { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_commit: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 8 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 8 | $self->add_historical_entry($orig); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 8 | my $time = gmtime; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 8 | $self->last_modification_time($time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 8 | $self->last_access_time($time); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 138 | ▶ | sub label { shift->expand_title(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
label: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | ### Name of the parent attribute expected to contain the object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 22 | ▶ | sub _parent_container { 'entries' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parent_container: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||