| 1 | package Uniform::HTTP::Auth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use Uniform::HTTP::Auth::Basic (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use Uniform::HTTP::Auth::Bearer (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use Uniform::HTTP::Auth::Digest (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | my %SCHEME_CLASS = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | basic => 'Uniform::HTTP::Auth::Basic', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | bearer => 'Uniform::HTTP::Auth::Bearer', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | digest => 'Uniform::HTTP::Auth::Digest', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 19 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=18 SCAR=29.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 19 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 19 | for my $name (keys %args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 21 | ▶ | croak "unknown constructor option '$name'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$name eq "schemes" or $name eq "credentials" or $name eq "origin"
$name eq "schemes" or $name eq "credentials"
MC/DC100%3/3
$name eq "schemes" or $name eq "credentials" or $name eq "origin"
$name eq "schemes"
$name eq "credentials"
$name eq "origin"
Truth table100%4/4
A or B or C
A= $name eq "schemes"B= $name eq "credentials"C= $name eq "origin"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | unless $name eq 'schemes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | || $name eq 'credentials' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | || $name eq 'origin'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | my $schemes = exists $args{schemes} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ? $args{schemes} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 18 | ▶ | : [qw(digest bearer basic)]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 18 | ▶ | croak "schemes must be an array reference" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | unless ref($schemes) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 18 | my (@normalized, %seen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 18 | for my $scheme (@$schemes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 47 | ▶ | croak "scheme names must be plain scalars" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $scheme or ref $scheme
MC/DC0%0/2
not defined $scheme or ref $scheme
not defined $scheme
ref $scheme
Truth table33%1/3
not(A) or B
A= not defined $schemeB= ref $scheme
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | if !defined($scheme) || ref($scheme); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 47 | my $name = lc $scheme; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | croak "unsupported authentication scheme '$scheme'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 47 | ▶ | unless exists $SCHEME_CLASS{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | croak "duplicate authentication scheme '$scheme'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 46 | ▶ | if $seen{$name}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 46 | push @normalized, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 17 | ▶ | _validate_origin($args{origin}) if exists $args{origin}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 17 | my $credentials = $args{credentials}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 17 | ▶ | if (exists $args{credentials}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 9 | my $type = ref($credentials); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 9 | ▶ | croak "credentials must be a hash reference or coderef" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$type eq "HASH" or $type eq "CODE"
MC/DC0%0/2
$type eq "HASH" or $type eq "CODE"
$type eq "HASH"
$type eq "CODE"
Truth table66%2/3
A or B
A= $type eq "HASH"B= $type eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | unless $type eq 'HASH' || $type eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 9 | ▶ | if ($type eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | croak "origin is required when credentials is a hash reference" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | ▶ | unless exists $args{origin}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 5 | _validate_static_credentials($credentials); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | $credentials = { %$credentials }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | schemes => \@normalized, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | credentials => $credentials, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | origin => $args{origin}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 14 | digest => Uniform::HTTP::Auth::Digest->new, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 14 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub schemes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
schemes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return [ @{ $self->{schemes} } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 23 | ▶ | sub parse_challenges { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_challenges: called CC=10 SCAR=24.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 23 | my ($self, @values) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 23 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 23 | for my $value (@values) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 24 | ▶ | if (!defined($value) || ref($value)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $value or ref $value
MC/DC0%0/2
not defined $value or ref $value
not defined $value
ref $value
Truth table33%1/3
not(A) or B
A= not defined $valueB= ref $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | push @out, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | scheme => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | raw => defined($value) ? "$value" : '', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | params => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | token68 => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | malformed => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | error => 'challenge header value must be a plain scalar', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 24 | push @out, @{ _parse_field($value) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 23 | for my $challenge (@out) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 28 | ▶ | next if $challenge->{malformed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 24 | my $scheme = $challenge->{scheme}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 24 | ▶ | next unless defined $scheme && exists $SCHEME_CLASS{$scheme}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $scheme and exists $SCHEME_CLASS{$scheme}
MC/DC50%1/2
defined $scheme and exists $SCHEME_CLASS{$scheme}
defined $scheme
exists $SCHEME_CLASS{$scheme}
Truth table66%2/3
A and B
A= defined $schemeB= exists $SCHEME_CLASS{$scheme}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 23 | my $class = $SCHEME_CLASS{$scheme}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 23 | my $error = $class->validate_challenge($challenge); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 23 | ▶ | if (defined $error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | $challenge->{malformed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | $challenge->{error} = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 23 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | ▶ | sub select { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
select: called CC=8 SCAR=22.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | my ($self, $challenges) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | croak "select() requires an array reference" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | unless ref($challenges) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | for my $scheme (@{ $self->{schemes} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | my @candidates = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 4 | ref($_) eq 'HASH' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | && !$_->{malformed} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | && defined($_->{scheme}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 9 | ▶ | && $_->{scheme} eq $scheme | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition44%4/9
ref $_ eq 'HASH' && !$_->{'malformed'} && defined $_->{'scheme'} && $_->{'scheme'} eq $scheme
ref $_ eq "HASH" and not $_->{"malformed"} and defined $_->{"scheme"}
ref $_ eq "HASH" and not $_->{"malformed"}
MC/DC25%1/4
ref $_ eq 'HASH' && !$_->{'malformed'} && defined $_->{'scheme'} && $_->{'scheme'} eq $scheme
ref $_ eq "HASH"
not $_->{"malformed"}
defined $_->{"scheme"}
$_->{'scheme'} eq $scheme
Truth table40%2/5
A and not(B) and C && D
A= ref $_ eq "HASH"B= not $_->{"malformed"}C= defined $_->{"scheme"}D= $_->{'scheme'} eq $scheme
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } @$challenges; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 4 | ▶ | next unless @candidates; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 3 | my $handler = $self->_handler($scheme); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 3 | my $chosen = $handler->select_challenge(\@candidates); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 3 | ▶ | return $chosen if $chosen; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 12 | ▶ | sub prepare_authentication { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_authentication: called CC=35 SCAR=37.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 12 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | croak "prepare_authentication() requires credentials" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | unless ref($self->{credentials}) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 12 | ▶ | || ref($self->{credentials}) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $self->{"credentials"} eq "HASH" or ref $self->{"credentials"} eq "CODE"
MC/DC100%2/2
ref $self->{"credentials"} eq "HASH" or ref $self->{"credentials"} eq "CODE"
ref $self->{"credentials"} eq "HASH"
ref $self->{"credentials"} eq "CODE"
Truth table100%3/3
A or B
A= ref $self->{"credentials"} eq "HASH"B= ref $self->{"credentials"} eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | croak "challenge_headers must be an array reference" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 11 | ▶ | unless ref($args{challenge_headers}) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 11 | ▶ | if (exists $args{request}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 4 | my $request = $args{request}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 4 | ▶ | croak "request must implement method(), target(), and has_buffered_body()" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
ref $request and $request->can("method") and $request->can("target") and $request->can("has_buffered_body")
ref $request and $request->can("method") and $request->can("target")
ref $request and $request->can("method")
MC/DC25%1/4
ref $request and $request->can("method") and $request->can("target") and $request->can("has_buffered_body")
ref $request
$request->can("method")
$request->can("target")
$request->can("has_buffered_body")
Truth table40%2/5
A and B and C and D
A= ref $requestB= $request->can("method")C= $request->can("target")D= $request->can("has_buffered_body")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | unless ref($request) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | && $request->can('method') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | && $request->can('target') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | && $request->can('has_buffered_body'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | $args{method} = $request->method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 3 | ▶ | unless exists $args{method}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | $args{request_target} = $request->target | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 3 | ▶ | unless exists $args{request_target}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 3 | ▶ | if (!exists($args{entity_body}) && $request->has_buffered_body) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not exists $args{"entity_body"} and $request->has_buffered_body
MC/DC50%1/2
not exists $args{"entity_body"} and $request->has_buffered_body
not exists $args{"entity_body"}
$request->has_buffered_body
Truth table66%2/3
not(A) and B
A= not exists $args{"entity_body"}B= $request->has_buffered_body
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 2 | ▶ | croak "request reports a buffered body but does not implement body()" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | unless $request->can('body'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | $args{entity_body} = $request->body; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 10 | my $origin; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 10 | ▶ | if (exists $args{origin}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | _validate_origin($args{origin}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 3 | ▶ | if (defined($self->{origin}) && $args{origin} ne $self->{origin}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->{"origin"} and $args{"origin"} ne $self->{"origin"}
MC/DC50%1/2
defined $self->{"origin"} and $args{"origin"} ne $self->{"origin"}
defined $self->{"origin"}
$args{"origin"} ne $self->{"origin"}
Truth table66%2/3
A and B
A= defined $self->{"origin"}B= $args{"origin"} ne $self->{"origin"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | croak "origin does not match the origin bound at construction"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | $origin = $args{origin}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 5 | $origin = $self->{origin}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 5 | _validate_origin($origin); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 7 | my $challenges = $self->parse_challenges(@{ $args{challenge_headers} }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 7 | for my $scheme (@{ $self->{schemes} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | my @candidates = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 11 | !$_->{malformed} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | && defined($_->{scheme}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 15 | ▶ | && $_->{scheme} eq $scheme | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
!$_->{'malformed'} && defined $_->{'scheme'} && $_->{'scheme'} eq $scheme
not $_->{"malformed"} and defined $_->{"scheme"}
MC/DC33%1/3
!$_->{'malformed'} && defined $_->{'scheme'} && $_->{'scheme'} eq $scheme
not $_->{"malformed"}
defined $_->{"scheme"}
$_->{'scheme'} eq $scheme
Truth table50%2/4
not(A) and B && C
A= not $_->{"malformed"}B= defined $_->{"scheme"}C= $_->{'scheme'} eq $scheme
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } @$challenges; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 11 | ▶ | next unless @candidates; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 9 | my $handler = $self->_handler($scheme); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 9 | my $challenge = $handler->select_challenge(\@candidates); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 9 | ▶ | next unless $challenge; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | my $context = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | scheme => $scheme, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | origin => $origin, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | realm => $challenge->{params}{realm}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 9 | challenge => $challenge, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 9 | my $credentials; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 9 | ▶ | if (ref($self->{credentials}) eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 3 | $credentials = $self->{credentials}->($context); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 3 | ▶ | next unless defined $credentials; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | ▶ | croak "credentials callback must return a hash reference or undef" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | unless ref($credentials) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | $credentials = _static_credentials_for_scheme( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 6 | $self->{credentials}, $scheme, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 6 | ▶ | next unless $credentials; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 7 | my $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 7 | ▶ | if ($scheme eq 'basic') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 2 | _require_fields($credentials, qw(username password)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | $value = Uniform::HTTP::Auth::Basic->authorization( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | %$credentials, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | challenge => $challenge, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | elsif ($scheme eq 'bearer') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | _require_fields($credentials, qw(token)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | $value = Uniform::HTTP::Auth::Bearer->authorization( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | %$credentials, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | challenge => $challenge, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | elsif ($scheme eq 'digest') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 4 | _require_fields($credentials, qw(username password)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | croak "method is required for Digest authentication" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 4 | ▶ | unless defined($args{method}) && !ref($args{method}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $args{"method"} and not ref $args{"method"}
MC/DC0%0/2
defined $args{"method"} and not ref $args{"method"}
defined $args{"method"}
not ref $args{"method"}
Truth table33%1/3
A and not(B)
A= defined $args{"method"}B= not ref $args{"method"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | croak "request_target is required for Digest authentication" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 4 | ▶ | unless defined($args{request_target}) && !ref($args{request_target}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $args{"request_target"} and not ref $args{"request_target"}
MC/DC0%0/2
defined $args{"request_target"} and not ref $args{"request_target"}
defined $args{"request_target"}
not ref $args{"request_target"}
Truth table33%1/3
A and not(B)
A= defined $args{"request_target"}B= not ref $args{"request_target"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | my %digest_args = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | %$credentials, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | challenge => $challenge, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | origin => $origin, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | method => $args{method}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | request_target => $args{request_target}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | $digest_args{entity_body} = $args{entity_body} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 4 | ▶ | if exists $args{entity_body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 4 | $value = $handler->authorization(%digest_args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 3 | ▶ | next unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 6 | scheme => $scheme, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | value => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | challenge => $challenge, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 12 | ▶ | sub _handler { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_handler: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 12 | my ($self, $scheme) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 12 | ▶ | return $self->{digest} if $scheme eq 'digest'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 5 | return $SCHEME_CLASS{$scheme}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 5 | ▶ | sub _validate_static_credentials { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_static_credentials: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 5 | my ($credentials) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 5 | my $has_token = exists $credentials->{token}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | my $has_username = exists $credentials->{username}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 5 | my $has_password = exists $credentials->{password}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 5 | ▶ | croak "static credentials require both username and password" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | if $has_username != $has_password; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 4 | ▶ | croak "static credentials require token or username/password" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$has_token or $has_username and $has_password
$has_username and $has_password
MC/DC66%2/3
$has_token or $has_username and $has_password
$has_token
$has_username
$has_password
Truth table75%3/4
A or B and C
A= $has_tokenB= $has_usernameC= $has_password
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | unless $has_token || ($has_username && $has_password); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 3 | for my $field (qw(token username password)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 9 | ▶ | next unless exists $credentials->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | croak "credential '$field' must be defined" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 5 | ▶ | unless defined $credentials->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | croak "credential '$field' must be a plain scalar" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 5 | ▶ | if ref($credentials->{$field}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 6 | ▶ | sub _static_credentials_for_scheme { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_static_credentials_for_scheme: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 6 | my ($credentials, $scheme) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 6 | ▶ | if ($scheme eq 'bearer') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | ▶ | return unless exists $credentials->{token}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | return unless exists($credentials->{username}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 5 | ▶ | && exists($credentials->{password}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $credentials->{"username"} and exists $credentials->{"password"}
MC/DC50%1/2
exists $credentials->{"username"} and exists $credentials->{"password"}
exists $credentials->{"username"}
exists $credentials->{"password"}
Truth table66%2/3
A and B
A= exists $credentials->{"username"}B= exists $credentials->{"password"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 5 | return { %$credentials }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 7 | ▶ | sub _require_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_require_fields: called CC=5 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 7 | my ($credentials, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 7 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | croak "credentials require '$field'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 13 | ▶ | unless exists($credentials->{$field}) && defined($credentials->{$field}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $credentials->{$field} and defined $credentials->{$field}
MC/DC0%0/2
exists $credentials->{$field} and defined $credentials->{$field}
exists $credentials->{$field}
defined $credentials->{$field}
Truth table33%1/3
A and B
A= exists $credentials->{$field}B= defined $credentials->{$field}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | croak "credential '$field' must be a plain scalar" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 13 | ▶ | if ref($credentials->{$field}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 15 | ▶ | sub _validate_origin { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_origin: called CC=6 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 15 | my ($origin) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 15 | ▶ | croak "origin is required" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $origin and not ref $origin and length $origin
defined $origin and not ref $origin
MC/DC0%0/3
defined $origin and not ref $origin and length $origin
defined $origin
not ref $origin
length $origin
Truth table25%1/4
A and not(B) and C
A= defined $originB= not ref $originC= length $origin
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | unless defined($origin) && !ref($origin) && length($origin); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 15 | ▶ | croak "origin must not contain whitespace or control characters" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | if $origin =~ /[\x00-\x20\x7f]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 14 | ▶ | croak "origin must be a normalized origin without credentials or path" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | unless $origin =~ m{\A[A-Za-z][A-Za-z0-9+.-]*://[^/?#@]+\z}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 11 | my $TCHAR = q{!#$%&'*+\-.^_`|~0-9A-Za-z}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 11 | my $TOKEN_RE = qr/[$TCHAR]+/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 11 | my $TOKEN68_RE = qr/[A-Za-z0-9\-._~+\/]+={0,}/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 24 | ▶ | sub _parse_field { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_field: called CC=17 SCAR=32.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 24 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 24 | ▶ | if ($value =~ /[\r\n]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | return [{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | scheme => undef, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | raw => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | params => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | token68 => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | malformed => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | error => 'challenge header value contains a newline', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | }]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 23 | my @parts = _split_top_level_commas($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 23 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | my $current; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 23 | for my $part (@parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 75 | my $trim = $part; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 75 | $trim =~ s/\A[ \t]+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 75 | $trim =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 75 | ▶ | next unless length $trim; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 75 | ▶ | if ($current && $current->{_mode} && $current->{_mode} eq 'params') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$current and $current->{"_mode"} and $current->{"_mode"} eq "params"
$current and $current->{"_mode"}
MC/DC33%1/3
$current and $current->{"_mode"} and $current->{"_mode"} eq "params"
$current
$current->{"_mode"}
$current->{"_mode"} eq "params"
Truth table50%2/4
A and B and C
A= $currentB= $current->{"_mode"}C= $current->{"_mode"} eq "params"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 52 | my ($name, $param_value, $error) = _parse_auth_param($trim); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 52 | ▶ | if (defined $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 48 | $current->{raw} .= ',' . $part; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 48 | ▶ | if (exists $current->{params}{$name}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | $current->{malformed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 1 | ▶ | $current->{error} ||= "duplicate authentication parameter '$name'"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$current->{"error"} ||= "duplicate authentication parameter '${name}'"
MC/DC0%0/1
$current->{"error"} ||= "duplicate authentication parameter '${name}'"
$current->{"error"}
Truth table50%1/2
A
A= $current->{"error"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 47 | $current->{params}{$name} = $param_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 48 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 4 | ▶ | if ($trim =~ /\A$TOKEN_RE[ \t]*=/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $current->{raw} .= ',' . $part; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $current->{malformed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | $current->{error} ||= $error || 'malformed authentication parameter'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$current->{"error"} ||= $error || "malformed authentication parameter"
$error || 'malformed authentication parameter'
MC/DC0%0/2
$current->{"error"} ||= $error || "malformed authentication parameter"
$current->{"error"}
$error
Truth table0%0/3
A ||= B
A= $current->{"error"}B= $error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 27 | ▶ | push @out, _finish_challenge($current) if $current; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 27 | $current = _start_challenge($part); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 23 | ▶ | push @out, _finish_challenge($current) if $current; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 23 | ▶ | if (!@out && length $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not @out and length $value
MC/DC0%0/2
not @out and length $value
not @out
length $value
Truth table33%1/3
not(A) and B
A= not @outB= length $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | push @out, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | scheme => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | raw => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | params => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | token68 => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | malformed => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | error => 'no authentication challenge found', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 23 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 27 | ▶ | sub _start_challenge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start_challenge: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 27 | my ($raw) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 27 | my $trim = $raw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 27 | $trim =~ s/\A[ \t]+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 27 | $trim =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 27 | my $challenge = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | scheme => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | raw => $raw, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | params => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | token68 => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | malformed => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | error => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | _mode => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 27 | ▶ | unless ($trim =~ /\A($TOKEN_RE)(?:[ \t]+(.*))?\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | $challenge->{malformed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 1 | $challenge->{error} = 'malformed authentication challenge'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | return $challenge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 26 | $challenge->{scheme} = lc $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 26 | my $rest = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 26 | ▶ | return $challenge unless defined($rest) && length($rest); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $rest and length $rest
MC/DC0%0/2
defined $rest and length $rest
defined $rest
length $rest
Truth table33%1/3
A and B
A= defined $restB= length $rest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 26 | $rest =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 26 | ▶ | if ($rest =~ /\A($TOKEN68_RE)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 1 | $challenge->{token68} = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | $challenge->{_mode} = 'token68'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | return $challenge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 25 | my ($name, $value, $error) = _parse_auth_param($rest); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 25 | ▶ | unless (defined $name) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | $challenge->{malformed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | ▶ | $challenge->{error} = $error || 'malformed authentication parameters'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$error || 'malformed authentication parameters'
MC/DC0%0/1
$error || 'malformed authentication parameters'
$error
Truth table50%1/2
A
A= $error
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | return $challenge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 24 | $challenge->{params}{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 24 | $challenge->{_mode} = 'params'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 24 | return $challenge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 27 | ▶ | sub _finish_challenge { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish_challenge: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 27 | my ($challenge) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 27 | delete $challenge->{_mode}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 27 | $challenge->{raw} =~ s/\A[ \t]+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 27 | $challenge->{raw} =~ s/[ \t]+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 27 | return $challenge; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 77 | ▶ | sub _parse_auth_param { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_auth_param: called CC=8 SCAR=21.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 77 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 77 | ▶ | unless ($text =~ /\A($TOKEN_RE)[ \t]*=[ \t]*(.*)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 4 | return (undef, undef, 'authentication parameter requires name=value syntax'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 73 | my $name = lc $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 73 | my $raw_value = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 73 | ▶ | if ($raw_value =~ /\A($TOKEN_RE)\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 16 | return ($name, $1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 57 | ▶ | if ($raw_value =~ /\A"(.*)"\z/s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 57 | my $inner = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 57 | ▶ | return (undef, undef, 'quoted authentication parameter contains a newline') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | if $inner =~ /[\r\n]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 57 | my $decoded = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 57 | ▶ | while (length $inner) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 58 | ▶ | if ($inner =~ s/\A\\([\x09\x20-\x7e\x80-\xff])//s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | $decoded .= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | elsif ($inner =~ s/\A([\x09\x20-\x21\x23-\x5b\x5d-\x7e\x80-\xff]+)//s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 57 | $decoded .= $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 1 | return (undef, undef, 'malformed quoted authentication parameter'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 56 | return ($name, $decoded, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | return (undef, undef, 'authentication parameter value must be a token or quoted string'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 23 | ▶ | sub _split_top_level_commas { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_top_level_commas: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 23 | my ($text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 23 | my @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 23 | my $start = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 23 | my $quoted = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 23 | my $escaped = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 23 | ▶ | for (my $i = 0; $i < length($text); $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 1472 | my $ch = substr($text, $i, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 1472 | ▶ | if ($quoted) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 540 | ▶ | if ($escaped) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $escaped = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | elsif ($ch eq '\\') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | $escaped = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | elsif ($ch eq '"') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 57 | $quoted = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 540 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 932 | ▶ | if ($ch eq '"') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 57 | $quoted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 57 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 875 | ▶ | if ($ch eq ',') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 52 | push @parts, substr($text, $start, $i - $start); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 52 | $start = $i + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 23 | push @parts, substr($text, $start); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 23 | return @parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||