Session/Store/CHI.pm

filter: Statementstmt 95.0% 38 / 40 Branchbran 80.0% 8 / 10 Conditioncond 83.3% 5 / 6 MC/DCmcdc 75.0% 3 / 4 Subroutinesub 91.6% 11 / 12 Podpod 83.3% 5 / 6 totaltotal 89.7% 70 / 78 CC 9 SCAR 11.8
CC
9
Cov
91%
new
6.4
_filter_sid
4.0
cleanup
2.0
CRAP 3.3
« Session/State/Cookie.pm ↑ Summary Session/Store/DBM.pm »
1 package HTTP::Session::Store::CHI;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw/Class::Accessor::Fast/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use CHI;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Encode qw( encode_utf8 is_utf8 );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 __PACKAGE__->mk_ro_accessors(qw/chi expires/);
9  
10 2 ▶sub new {
Subroutine new: called CC=6 SCAR=18.6
Pod documented
11 2 my $class = shift;
12 0 ▶ my %args = ref($_[0]) ? %{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 2 2
13 # check required parameters
14 2 for (qw/chi expires/) {
15 4 ▶ Carp::croak "missing parameter $_" unless $args{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless $args{$_} 0 4 4
16 }
17 # coerce
18 2 ▶ if (ref $args{chi} && ref $args{chi} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $args{"chi"} and ref $args{"chi"} eq "HASH") 1 1 2
Condition66%2/3
ref $args{"chi"} and ref $args{"chi"} eq "HASH"
!ll&&!rl&&r
011
MC/DC50%1/2
ref $args{"chi"} and ref $args{"chi"} eq "HASH"
ref $args{"chi"} ref $args{"chi"} eq "HASH"
Truth table66%2/3
A and B
A= ref $args{"chi"}B= ref $args{"chi"} eq "HASH"
ABresult
0X0
100
111
19 1 $args{chi} = CHI->new(%{$args{chi}});
20 }
21 2 bless {%args}, $class;
22 }
23  
24 40 ▶sub _filter_sid($) {
Subroutine _filter_sid: called CC=4 SCAR=13.9
25 40 my $session_id = shift;
26 40 ▶ $session_id = encode_utf8($session_id) if is_utf8($session_id);
Branch: 1 branch
BranchTrueFalseTotal
if &is_utf8($session_id) 6 34 40
27 40 ▶ if ($session_id =~ /[\x00-\x20\x7f-\xff]/ || length($session_id) > 250) {
Branch: 1 branch
BranchTrueFalseTotal
if ($session_id =~ /[\x00-\x20\x7f-\xff]/ or length $session_id > 250) 24 16 40
Condition100%3/3
$session_id =~ /[\x00-\x20\x7f-\xff]/ or length $session_id > 250
l!l&&r!l&&!r
18616
MC/DC100%2/2
$session_id =~ /[\x00-\x20\x7f-\xff]/ or length $session_id > 250
$session_id =~ /[\x00-\x20\x7f-\xff]/ length $session_id > 250
Truth table100%3/3
A or B
A= $session_id =~ /[\x00-\x20\x7f-\xff]/B= length $session_id > 250
ABresult
1X1
011
000
28 24 die "detected memcached injection: $session_id";
29 }
30 16 return $session_id;
31 }
32  
33 16 ▶sub select {
Subroutine select: called CC=1 SCAR=0.0
Pod documented
34 16 my ( $self, $session_id ) = @_;
35 16 my $data = $self->chi->get(_filter_sid $session_id);
36 }
37  
38 12 ▶sub insert {
Subroutine insert: called CC=1 SCAR=0.0
Pod documented
39 12 my ($self, $session_id, $data) = @_;
40 12 $self->chi->set( _filter_sid($session_id), $data, $self->expires );
41 }
42  
43 10 ▶sub update {
Subroutine update: called CC=1 SCAR=0.0
Pod documented
44 10 my ($self, $session_id, $data) = @_;
45 10 $self->chi->set( _filter_sid($session_id), $data, $self->expires );
46 }
47  
48 2 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
Pod documented
49 2 my ($self, $session_id) = @_;
50 2 $self->chi->remove( _filter_sid($session_id) );
51 }
52  
53 0 ▶sub cleanup { Carp::croak "This storage doesn't support cleanup" }
Subroutine cleanup: not called CC=1 SCAR=6.9
Pod undocumented
54  
55 1 1;
56 __END__
« Session/State/Cookie.pm ↑ Summary Session/Store/DBM.pm »