PostgreSQL/Backend/AuthenticationRequest.pm

filter: Statementstmt 44.0% 22 / 50 Branchbran 21.4% 3 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 38.4% 5 / 13 Podpod 11.1% 1 / 9 totaltotal 36.0% 31 / 86 CC 8 SCAR 26.7
CC
8
Cov
39%
new_from_message
33.7
type
2.0
auth_type
2.0
CRAP 14.5
« PostgreSQL/Backend/NoticeResponse.pm ↑ Summary PostgreSQL/Backend/ErrorResponse.pm »
1 package Protocol::Database::PostgreSQL::Backend::AuthenticationRequest;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 our $VERSION = '2.000'; # VERSION
7  
8 4 ▶use parent qw(Protocol::Database::PostgreSQL::Backend);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 Protocol::Database::PostgreSQL::Backend::AuthenticationRequest - an authentication request message
13  
14 =head1 DESCRIPTION
15  
16 =cut
17  
18 4 ▶use Log::Any qw($log);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 0 ▶sub type { 'authentication_request' }
Subroutine type: not called CC=1 SCAR=6.9
Pod undocumented
21  
22 0 ▶sub auth_type { shift->{auth_type} }
Subroutine auth_type: not called CC=1 SCAR=6.9
Pod undocumented
23 0 ▶sub password_type { shift->{password_type} }
Subroutine password_type: not called CC=1 SCAR=6.9
Pod undocumented
24 0 ▶sub password_salt { shift->{password_salt} }
Subroutine password_salt: not called CC=1 SCAR=6.9
Pod undocumented
25 0 ▶sub password_rounds { shift->{password_rounds} }
Subroutine password_rounds: not called CC=1 SCAR=6.9
Pod undocumented
26 0 ▶sub password_nonce { shift->{password_nonce} }
Subroutine password_nonce: not called CC=1 SCAR=6.9
Pod undocumented
27 0 ▶sub server_first_message { shift->{server_first_message} }
Subroutine server_first_message: not called CC=1 SCAR=6.9
Pod undocumented
28 0 ▶sub server_signature { shift->{server_signature} }
Subroutine server_signature: not called CC=1 SCAR=6.9
Pod undocumented
29  
30 sub new_from_message {
31 1 ▶ my ($class, $msg) = @_;
Subroutine new_from_message: called CC=8 SCAR=35.2
Pod documented
32  
33 1 my (undef, undef, $auth_code, $data) = unpack('C1N1N1a*', $msg);
34 1 ▶ my $auth_type = $Protocol::Database::PostgreSQL::AUTH_TYPE{$auth_code} or die "Invalid auth code $auth_code received";
Branch: 1 branch
BranchTrueFalseTotal
my $auth_type = $Protocol::Database::PostgreSQL::AUTH_TYPE{$auth_code} or die "Invalid auth code $auth_code received" 0 1 1
35 1 $log->tracef("Auth message [%s]", $auth_type);
36 1 my %info = (
37 auth_type => $auth_type,
38 );
39 1 ▶ if($auth_type eq 'AuthenticationMD5Password') {
Branch: 6 branches
BranchTrueFalseTotal
if ($auth_type eq 'AuthenticationMD5Password') { } 0 1 1
elsif ($auth_type eq 'AuthenticationCleartextPassword') { } 1 0 1
elsif ($auth_type eq 'AuthenticationOk') { } 0 0 0
elsif ($auth_type eq 'AuthenticationSASL') { } 0 0 0
elsif ($auth_type eq 'AuthenticationSASLContinue') { } 0 0 0
elsif ($auth_type eq 'AuthenticationSASLFinal') { } 0 0 0
40 0 my ($salt) = unpack('a4', $data);
41 0 $info{password_type} = 'md5';
42 0 $info{password_salt} = $salt;
43 } elsif($auth_type eq 'AuthenticationCleartextPassword') {
44 1 $info{password_type} = 'plain';
45 } elsif($auth_type eq 'AuthenticationOk') {
46 # No action required
47 } elsif($auth_type eq 'AuthenticationSASL') {
48 0 my @methods = split /\0/, $data;
49 0 $log->tracef('Have auth methods %s', \@methods);
50 0 $info{password_mechanisms} = \@methods;
51 } elsif($auth_type eq 'AuthenticationSASLContinue') {
52 0 $log->tracef('Auth continue: %s', $data);
53 0 my %data = map { /([rsi])=(.*)$/ } split /,/, $data;
54 0 $log->tracef('Have parameters: %s', \%data);
55 0 $info{password_rounds} = $data{i};
56 0 $info{password_salt} = $data{s};
57 0 $info{password_nonce} = $data{r};
58 0 $info{server_first_message} = $data;
59 } elsif($auth_type eq 'AuthenticationSASLFinal') {
60 0 $log->tracef('Auth final %s', $data);
61 0 my %data = map { /([v])=(.*)$/ } split /,/, $data;
62 0 $log->tracef('Have parameters: %s', \%data);
63 0 $info{server_signature} = $data{v};
64 } else {
65 0 die 'unknown auth thing here';
66 }
67 1 return $class->new(
68 %info,
69 );
70 }
71  
72 4 1;
73  
74 =head1 AUTHOR
75  
76 Tom Molesworth <TEAM@cpan.org>
77  
78 =head1 LICENSE
79  
80 Copyright Tom Molesworth 2010-2019. Licensed under the same terms as Perl itself.
81  
« PostgreSQL/Backend/NoticeResponse.pm ↑ Summary PostgreSQL/Backend/ErrorResponse.pm »