SASL/Perl/LOGIN.pm

filter: Statementstmt 85.3% 64 / 75 Branchbran 77.2% 17 / 22 Conditioncond 45.4% 5 / 11 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 85.7% 12 / 14 Podpod 0.0% 0 / 5 totaltotal 73.8% 99 / 134 CC 16 SCAR 14.6
CC
16
Cov
80%
server_step
9.3
__ANON__
4.1
client_step
4.0
CRAP 4.3
« SASL.pm ↑ Summary SASL/Perl/PLAIN.pm »
1 # Copyright (c) 2002 Graham Barr <gbarr@pobox.com>. All rights reserved.
2 # This program is free software; you can redistribute it and/or
3 # modify it under the same terms as Perl itself.
4  
5 package Authen::SASL::Perl::LOGIN 2.2100;
6  
7 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use vars qw(@ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 @ISA = qw(Authen::SASL::Perl);
12  
13 4 my %secflags = (
14 noanonymous => 1,
15 );
16  
17 39 ▶sub _order { 1 }
Subroutine _order: called CC=1 SCAR=0.0
18 18 ▶sub _secflags {
Subroutine _secflags: called CC=1 SCAR=0.4
19 18 shift;
20 0 scalar grep { $secflags{$_} } @_;
21 }
22  
23 5 ▶sub mechanism { 'LOGIN' }
Subroutine mechanism: called CC=1 SCAR=0.0
Pod undocumented
24  
25 4 ▶sub client_start {
Subroutine client_start: called CC=1 SCAR=0.0
Pod undocumented
26 4 my $self = shift;
27 4 $self->{stage} = 0;
28 4 '';
29 }
30  
31 9 ▶sub client_step {
Subroutine client_step: called CC=4 SCAR=14.0
Pod undocumented
32 9 my ($self, $string) = @_;
33  
34 # XXX technically this is wrong. I might want to change that.
35 # spec say it's "staged" and that the content of the challenge doesn't
36 # matter
37 # actually, let's try
38 9 my $stage = ++$self->{stage};
39 9 ▶ if ($stage == 1) {
Branch: 3 branches
BranchTrueFalseTotal
if ($stage == 1) { } 4 5 9
elsif ($stage == 2) { } 4 1 5
elsif ($stage == 3) { } 1 0 1
40 4 return $self->_call('user');
41 }
42 elsif ($stage == 2) {
43 4 return $self->_call('pass');
44 }
45 elsif ($stage == 3) {
46 1 $self->set_success;
47 1 return;
48 }
49 else {
50 0 return $self->set_error("Invalid sequence");
51 }
52 }
53  
54 9 ▶sub server_start {
Subroutine server_start: called CC=2 SCAR=7.0
Pod undocumented
55 9 my $self = shift;
56 9 my $response = shift;
57 9 ▶ my $user_cb = shift || sub {};
Subroutine __ANON__: not called CC=1 SCAR=1.2
Condition33%1/3
shift() || sub { }
l!l&&r!l&&!r
900
MC/DC0%0/2
shift() || sub { }
shift() sub { }
Truth table33%1/3
A || B
A= shift()B= sub { }
ABresult
1X1
011
000
58  
59 9 $self->{answer} = {};
60 9 $self->{stage} = 0;
61 9 $self->{need_step} = 1;
62 9 $self->{error} = undef;
63 9 $user_cb->('Username:');
64 9 return;
65 }
66  
67 15 ▶sub server_step {
Subroutine server_step: called CC=8 SCAR=22.3
Pod undocumented
68 15 my $self = shift;
69 15 my $response = shift;
70 15 ▶ my $user_cb = shift || sub {};
Subroutine __ANON__: not called CC=1 SCAR=1.2
Condition33%1/3
shift() || sub { }
l!l&&r!l&&!r
1500
MC/DC0%0/2
shift() || sub { }
shift() sub { }
Truth table33%1/3
A || B
A= shift()B= sub { }
ABresult
1X1
011
000
71  
72 15 my $stage = ++$self->{stage};
73  
74 15 ▶ if ($stage == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($stage == 1) { } 8 7 15
elsif ($stage == 2) { } 7 0 7
75 8 ▶ unless (defined $response) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $response) 0 8 8
76 0 $self->set_error("Invalid sequence (empty username)");
77 0 return $user_cb->();
78 }
79 8 $self->{answer}{user} = $response;
80 8 return $user_cb->("Password:");
81 }
82 elsif ($stage == 2) {
83 7 ▶ unless (defined $response) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $response) 0 7 7
84 0 $self->set_error("Invalid sequence (empty pass)");
85 0 return $user_cb->();
86 }
87 7 $self->{answer}{pass} = $response;
88 }
89 else {
90 0 $self->set_error("Invalid sequence (end)");
91 0 return $user_cb->();
92 }
93 7 my $error = "Credentials don't match";
94 7 my $answers = { user => $self->{answer}{user}, pass => $self->{answer}{pass} };
95 7 ▶ if (my $checkpass = $self->{callback}{checkpass}) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $checkpass = $self->{'callback'}{'checkpass'}) { } 2 5 7
elsif (my $getsecret = $self->{'callback'}{'getsecret'}) { } 5 0 5
96 2 ▶ my $cb = sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
97 2 my $result = shift;
98 2 ▶ unless ($result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($result) { } 1 1 2
99 1 $self->set_error($error);
100 }
101 else {
102 1 $self->set_success;
103 }
104 2 $user_cb->();
105 2 };
106 2 $checkpass->($self => $answers => $cb );
107 2 return;
108 }
109 elsif (my $getsecret = $self->{callback}{getsecret}) {
110 5 ▶ my $cb = sub {
Subroutine __ANON__: called CC=4 SCAR=14.0
111 5 my $good_pass = shift;
112 5 ▶ if ($good_pass && $good_pass eq ($self->{answer}{pass} || "")) {
Branch: 1 branch
BranchTrueFalseTotal
if ($good_pass and $good_pass eq ($self->{'answer'}{'pass'} || '')) { } 2 3 5
Condition60%3/5
$good_pass and $good_pass eq ($self->{"answer"}{"pass"} || "")
!ll&&!rl&&r
032
$self->{'answer'}{'pass'} || ''
l!l
50
MC/DC50%1/2
$good_pass and $good_pass eq ($self->{"answer"}{"pass"} || "")
$good_pass $good_pass eq ($self->{"answer"}{"pass"} || "")
MC/DC0%0/1
$self->{'answer'}{'pass'} || ''
$self->{'answer'}{'pass'}
Truth table66%2/3
A and B
A= $good_passB= $good_pass eq ($self->{"answer"}{"pass"} || "")
ABresult
0X0
100
111
Truth table50%1/2
A
A= $self->{'answer'}{'pass'}
Aresult
11
00
113 2 $self->set_success;
114 }
115 else {
116 3 $self->set_error($error);
117 }
118 5 $user_cb->();
119 5 };
120 5 $getsecret->($self => $answers => $cb );
121 5 return;
122 }
123 else {
124 0 $self->set_error($error);
125 0 $user_cb->();
126 }
127 0 return;
128 }
129  
130 4 1;
131  
132 __END__
« SASL.pm ↑ Summary SASL/Perl/PLAIN.pm »