| 1 | #!/usr/bin/perl -s | ||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## | ||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Tie::EncryptedHash - A tied hash with encrypted fields. | ||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## | ||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Copyright (c) 2000, Vipul Ved Prakash. All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## This code is based on Damian Conway's Tie::SecureHash. | ||||||||||||||||||||||||||||||||||||||||||||
| 7 | ## | ||||||||||||||||||||||||||||||||||||||||||||
| 8 | ## $Id: EncryptedHash.pm,v 1.8 2000/09/02 19:23:00 vipul Exp vipul $ | ||||||||||||||||||||||||||||||||||||||||||||
| 9 | ## vi:expandtab=1;ts=4; | ||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||
| 11 | package Tie::EncryptedHash; | ||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use vars qw($VERSION $strict); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use Digest::MD5 qw(md5_base64); | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use Crypt::CBC; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 17 | 7 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 18 | 7 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||
| 20 | 7 | ( $VERSION ) = '$Revision: 1.8 $' =~ /\s(\d+\.\d+)\s/; | |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | 7 | my $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub debug { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | return undef unless $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | my ($caller, undef) = caller; | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my (undef,undef,$line,$sub) = caller(1); $sub =~ s/.*://; | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | $sub = sprintf "%10s()%4d",$sub,$line; | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | print "$sub " . (shift) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||
| 32 | # sub new { | ||||||||||||||||||||||||||||||||||||||||||||
| 33 | # my ($class,%args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
| 34 | # my %self = (); tie %self, $class; | ||||||||||||||||||||||||||||||||||||||||||||
| 35 | # my $self = bless \%self, $class; | ||||||||||||||||||||||||||||||||||||||||||||
| 36 | # $self->{__password} = $args{__password} if $args{__password}; | ||||||||||||||||||||||||||||||||||||||||||||
| 37 | # $self->{__cipher} = $args{__cipher} || qq{Blowfish}; | ||||||||||||||||||||||||||||||||||||||||||||
| 38 | # return $self; | ||||||||||||||||||||||||||||||||||||||||||||
| 39 | # } | ||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | my ($class,%args) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | my $self = {}; tie %$self, $class; | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | bless $self, $class; | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | ▶ | $self->{__password} = $args{__password} if $args{__password}; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | ▶ | $self->{__cipher} = $args{__cipher} || qq{Blowfish}; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$args{'__cipher'} || 'Blowfish'
MC/DC100%1/1
$args{'__cipher'} || 'Blowfish'
$args{'__cipher'}
Truth table100%2/2
A
A= $args{'__cipher'}
| |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 741 | ▶ | sub _access { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_access: called CC=44 SCAR=39.3
| |||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 741 | my ($self, $key, $caller, $file, $value, $delete) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 741 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||
| 55 | # SPECIAL ATTRIBUTE | ||||||||||||||||||||||||||||||||||||||||||||
| 56 | 741 | ▶ | if ( $key =~ /(__password|__hide|__scaffolding|__cipher)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||
| 57 | 104 | my $key = $1; | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 104 | ▶ | unless($value||$delete) {return undef unless $caller eq $class} | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$value or $delete
MC/DC100%2/2
$value or $delete
$value
$delete
Truth table100%3/3
A or B
A= $valueB= $delete
| |||||||||||||||||||||||||||||||||||||||||||||
| 59 | 78 | ▶ | if ($delete && ($key =~ /__password/)) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$delete and $key =~ /__password/
MC/DC100%2/2
$delete and $key =~ /__password/
$delete
$key =~ /__password/
Truth table100%3/3
A and B
A= $deleteB= $key =~ /__password/
| |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | for (keys %{$$self{__scaffolding}}) { | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | ▶ | if ( ref $self->{$_} ) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | $self->{$_} = encrypt($self->{$_}, $self->{__scaffolding}{$_}, $self->{__cipher}); | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | delete $self->{__scaffolding}{$_}; | |||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 67 | 78 | ▶ | delete $$self{$key} if $delete; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 78 | ▶ | return $self->{$key} = $value if $value; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 69 | 5 | return $self->{$key}; | |||||||||||||||||||||||||||||||||||||||||||
| 70 | # SECRET FIELD | ||||||||||||||||||||||||||||||||||||||||||||
| 71 | ▶ | } elsif ( $key =~ m/^(_{1}[^_][^:]*)$/ ||$key =~ m/.*?::(_{1}[^_][^:]*)/ ) { | |||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$key =~ /^(_{1}[^_][^:]*)$/ or $key =~ /.*?::(_{1}[^_][^:]*)/
MC/DC50%1/2
$key =~ /^(_{1}[^_][^:]*)$/ or $key =~ /.*?::(_{1}[^_][^:]*)/
$key =~ /^(_{1}[^_][^:]*)$/
$key =~ /.*?::(_{1}[^_][^:]*)/
Truth table66%2/3
A or B
A= $key =~ /^(_{1}[^_][^:]*)$/B= $key =~ /.*?::(_{1}[^_][^:]*)/
| |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 573 | my $ctext = $self->{$1}; | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 573 | ▶ | if ( ref $ctext && !($value)) { # ENCRYPT REF AT FETCH | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $ctext and not $value
MC/DC50%1/2
ref $ctext and not $value
ref $ctext
not $value
Truth table66%2/3
A and not(B)
A= ref $ctextB= not $value
| |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 179 | ▶ | my $pass = $self->{__scaffolding}{$1} || $self->{__password}; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'__scaffolding'}{$1} || $self->{'__password'}
MC/DC0%0/2
$self->{'__scaffolding'}{$1} || $self->{'__password'}
$self->{'__scaffolding'}{$1}
$self->{'__password'}
Truth table33%1/3
A || B
A= $self->{'__scaffolding'}{$1}B= $self->{'__password'}
| |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 179 | ▶ | return undef unless $pass; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 179 | $self->{$1} = encrypt($ctext, $pass, $self->{__cipher}); | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 179 | return $self->FETCH ($1); | |||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 79 | 394 | my $ptext = qq{}; my $isnot = !( exists $self->{$1} ); | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 394 | my $auth = verify($self,$1); | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 394 | ▶ | return undef if !($auth) && ref $self->{$1}; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $auth and ref $self->{$1}
MC/DC0%0/2
not $auth and ref $self->{$1}
not $auth
ref $self->{$1}
Truth table66%2/3
not(A) and B
A= not $authB= ref $self->{$1}
| |||||||||||||||||||||||||||||||||||||||||||||
| 82 | 394 | ▶ | return undef if !($auth) && $self->{__hide}; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $auth and $self->{"__hide"}
MC/DC100%2/2
not $auth and $self->{"__hide"}
not $auth
$self->{"__hide"}
Truth table100%3/3
not(A) and B
A= not $authB= $self->{"__hide"}
| |||||||||||||||||||||||||||||||||||||||||||||
| 83 | 388 | ▶ | if ($auth && $auth ne "1") { $ptext = $auth } | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$auth and $auth ne 1
MC/DC100%2/2
$auth and $auth ne 1
$auth
$auth ne 1
Truth table100%3/3
A and B
A= $authB= $auth ne 1
| |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 388 | ▶ | if ($value && $auth) { # STORE | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition66%2/3
$value and $auth
MC/DC50%1/2
$value and $auth
$value
$auth
Truth table66%2/3
A and B
A= $valueB= $auth
| |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 65 | ▶ | if ( ref $value ) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 42 | $self->{__scaffolding}{$1} = $self->{__password}; $ctext = $value; | |||||||||||||||||||||||||||||||||||||||||||
| 87 | } else { | ||||||||||||||||||||||||||||||||||||||||||||
| 88 | 23 | my $key = $1; | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 23 | ▶ | unless ($self->{__password}) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | ▶ | if ($value =~ m:^\S+\s\S{22}\s:) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | return $self->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | } else { return undef } | |||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 94 | 22 | $ctext = encrypt($value, $self->{__password}, $self->{__cipher}); | |||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 96 | 64 | $self->{$1} = $ctext; | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 64 | return $value; | |||||||||||||||||||||||||||||||||||||||||||
| 98 | ▶ | } elsif ($auth && $delete) { # DELETE | |||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$auth and $delete
MC/DC100%2/2
$auth and $delete
$auth
$delete
Truth table100%3/3
A and B
A= $authB= $delete
| |||||||||||||||||||||||||||||||||||||||||||||
| 99 | 4 | delete $$self{$1} | |||||||||||||||||||||||||||||||||||||||||||
| 100 | ▶ | } elsif ($isnot && (!($value))) { # DOESN'T EXIST | |||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$isnot and not $value
MC/DC50%1/2
$isnot and not $value
$isnot
not $value
Truth table66%2/3
A and not(B)
A= $isnotB= not $value
| |||||||||||||||||||||||||||||||||||||||||||||
| 101 | 46 | return; | |||||||||||||||||||||||||||||||||||||||||||
| 102 | ▶ | } elsif ((!($auth)) && $ctext) { | |||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
not $auth and $ctext
MC/DC50%1/2
not $auth and $ctext
not $auth
$ctext
Truth table66%2/3
not(A) and B
A= not $authB= $ctext
| |||||||||||||||||||||||||||||||||||||||||||||
| 103 | 89 | return $ctext; # FETCH return ciphertext | |||||||||||||||||||||||||||||||||||||||||||
| 104 | ▶ | } elsif ($auth && !($isnot)) { # FETCH return plaintext | |||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$auth and not $isnot
MC/DC0%0/2
$auth and not $isnot
$auth
not $isnot
Truth table33%1/3
A and not(B)
A= $authB= not $isnot
| |||||||||||||||||||||||||||||||||||||||||||||
| 105 | 184 | ▶ | if (ref $ptext) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 106 | 167 | $self->{$1} = $ptext; | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 167 | $self->{__scaffolding}{$1} = $self->{__password}; # Ref counting mechanism | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 167 | return $self->{$1}; | |||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 111 | 21 | ▶ | return undef unless $auth; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 112 | 21 | return $ptext; | |||||||||||||||||||||||||||||||||||||||||||
| 113 | # PUBLIC FIELD | ||||||||||||||||||||||||||||||||||||||||||||
| 114 | ▶ | } elsif ( $key =~ m/([^:]*)$/ || $key =~ m/.*?::([^:]*)/ ) { | |||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$key =~ /([^:]*)$/ or $key =~ /.*?::([^:]*)/
MC/DC0%0/2
$key =~ /([^:]*)$/ or $key =~ /.*?::([^:]*)/
$key =~ /([^:]*)$/
$key =~ /.*?::([^:]*)/
Truth table33%1/3
A or B
A= $key =~ /([^:]*)$/B= $key =~ /.*?::([^:]*)/
| |||||||||||||||||||||||||||||||||||||||||||||
| 115 | 64 | ▶ | $self->{$1} = $value if $value; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 116 | 64 | ▶ | delete $$self{$1} if $delete; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 117 | 64 | ▶ | return $self->{$1} if $self->{$1}; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 118 | 16 | return undef; | |||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||
| 123 | 202 | ▶ | sub encrypt { # ($plaintext, $password, $cipher) | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encrypt: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 124 | 202 | ▶ | $_[0] = qq{REF }. Data::Dumper->new([$_[0]])->Indent(0)->Terse(0)->Purity(1)->Dumpxs if ref $_[0]; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 125 | 202 | return qq{$_[2] } . md5_base64($_[0]) .qq{ } . | |||||||||||||||||||||||||||||||||||||||||||
| 126 | Crypt::CBC->new($_[1],$_[2])->encrypt_hex($_[0]) | ||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||
| 129 | 299 | ▶ | sub decrypt { # ($cipher $md5sum $ciphertext, $password) | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decrypt: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 130 | 299 | ▶ | return undef unless $_[1]; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 131 | 292 | my ($m, $d, $c) = split /\s/,$_[0]; | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 292 | my $ptext = Crypt::CBC->new($_[1],$m)->decrypt_hex($c); | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 292 | my $check = md5_base64($ptext); | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 292 | ▶ | if ( $d eq $check ) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 135 | 200 | ▶ | if ($ptext =~ /^REF (.*)/is) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 167 | my ($VAR1,$VAR2,$VAR3,$VAR4,$VAR5,$VAR6,$VAR7,$VAR8); | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 167 | return eval qq{$1}; | |||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 139 | 33 | return $ptext; | |||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | 418 | ▶ | sub verify { # ($self, $key) | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 418 | my ($self, $key) = splice @_,0,2; | |||||||||||||||||||||||||||||||||||||||||||
| 145 | # debug ("$self->{__scaffolding}{$key}, $self->{__password}, $self->{$key}"); | ||||||||||||||||||||||||||||||||||||||||||||
| 146 | 418 | ▶ | return 1 unless $key =~ m:^_:; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 402 | ▶ | return 1 unless exists $self->{$key}; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 148 | return undef if ref $self->{$key} && ($self->{__scaffolding}{$key} ne | ||||||||||||||||||||||||||||||||||||||||||||
| 149 | 299 | ▶ | $self->{__password}); | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $self->{$key} and $self->{"__scaffolding"}{$key} ne $self->{"__password"}
MC/DC0%0/2
ref $self->{$key} and $self->{"__scaffolding"}{$key} ne $self->{"__password"}
ref $self->{$key}
$self->{"__scaffolding"}{$key} ne $self->{"__password"}
Truth table33%1/3
A and B
A= ref $self->{$key}B= $self->{"__scaffolding"}{$key} ne $self->{"__password"}
| |||||||||||||||||||||||||||||||||||||||||||||
| 150 | 299 | my $ptext = decrypt($self->{$key}, $self->{__password}); | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 299 | ▶ | return $ptext if $ptext; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub each { CORE::each %{$_[0]} } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
each: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | sub keys { CORE::keys %{$_[0]} } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keys: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub values { CORE::values %{$_[0]} } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
values: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub exists { CORE::exists $_[0]->{$_[1]} } | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
exists: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub TIEHASH # ($class, @args) | ||||||||||||||||||||||||||||||||||||||||||||
| 160 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 161 | 12 | ▶ | my $class = ref($_[0]) || $_[0]; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||
| 162 | 12 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 12 | ▶ | $self->{__password} = $_[1] if $_[1]; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 164 | 12 | ▶ | $self->{__cipher} = $_[2] || qq{Blowfish}; | ||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$_[2] || 'Blowfish'
MC/DC100%1/1
$_[2] || 'Blowfish'
$_[2]
Truth table100%2/2
A
A= $_[2]
| |||||||||||||||||||||||||||||||||||||||||||||
| 165 | 12 | return $self; | |||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | sub FETCH # ($self, $key) | ||||||||||||||||||||||||||||||||||||||||||||
| 169 | 434 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 434 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 434 | my $entry = _access($self,$key,(caller)[0..1]); | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 434 | ▶ | return $entry if $entry; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||
| 175 | sub STORE # ($self, $key, $value) | ||||||||||||||||||||||||||||||||||||||||||||
| 176 | 158 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||
| 177 | 158 | my ($self, $key, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 158 | my $entry = _access($self,$key,(caller)[0..1],$value); | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 158 | ▶ | return $entry if $entry; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | sub DELETE # ($self, $key) | ||||||||||||||||||||||||||||||||||||||||||||
| 183 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DELETE: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 184 | 13 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 13 | return _access($self,$key,(caller)[0..1],'',1); | |||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||
| 188 | sub CLEAR # ($self) | ||||||||||||||||||||||||||||||||||||||||||||
| 189 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLEAR: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||
| 190 | 8 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 24 | return undef if grep { ! $self->verify($_) } | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 8 | ▶ | grep { ! /__/ } CORE::keys %{$self}; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 193 | 4 | %{$self} = (); | |||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | sub EXISTS # ($self, $key) | ||||||||||||||||||||||||||||||||||||||||||||
| 197 | 40 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
EXISTS: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||
| 198 | 40 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 40 | my @context = (caller)[0..1]; | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 40 | ▶ | return _access($self,$key,@context) ? 1 : ''; | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||
| 203 | sub FIRSTKEY # ($self) | ||||||||||||||||||||||||||||||||||||||||||||
| 204 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 10 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 10 | CORE::keys %{$self}; | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 10 | goto &NEXTKEY; | |||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||
| 210 | sub NEXTKEY # ($self) | ||||||||||||||||||||||||||||||||||||||||||||
| 211 | 80 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 212 | 80 | my $self = $_[0]; my $key; | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 80 | my @context = (caller)[0..1]; | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 80 | ▶ | while (defined($key = CORE::each %{$self})) { | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 215 | 96 | ▶ | last if eval { _access($self,$key,@context) } | ||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 217 | 80 | return $key; | |||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | sub DESTROY # ($self) | ||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||
| 225 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||