| 1 | package HTTP::Message::Signature; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Verify HTTP Message Signatures (RFC 9421) | ||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use v5.24; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Carp qw( carp croak ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Crypt::PK::Ed25519 0.089; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Hash::MultiValue; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use HTTP::Message; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use HTTP::Tiny; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use Hash::Ordered; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use JSON::MaybeXS qw( decode_json ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | use List::Util 1.29 qw( first pairmap ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 16 | 3 | ▶ | use MIME::Base64 qw( decode_base64 ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | use PerlX::Maybe qw( maybe ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | use Ref::Util qw( is_plain_hashref ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 19 | 3 | ▶ | use String::Util qw( trim unquote ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 20 | 3 | ▶ | use Syntax::Keyword::Match; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use Types::Common qw( Bool HashRef InstanceOf NonEmptyStr ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use Types::URI qw( Uri ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | use URI; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | use experimental qw( lexical_subs signatures ); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | 3 | our $VERSION = 'v0.0.2'; | |||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||
| 33 | 3 | has message => ( | |||||||||||||||||||||||||||||||||||||
| 34 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||
| 35 | isa => InstanceOf [qw/ HTTP::Message Plack::Request /], | ||||||||||||||||||||||||||||||||||||||
| 36 | required => 1, | ||||||||||||||||||||||||||||||||||||||
| 37 | handles => [qw/ as_string headers /], | ||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||
| 41 | has is_request => ( | ||||||||||||||||||||||||||||||||||||||
| 42 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 43 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | builder => sub($self) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_is_request: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $message = $self->message; | |||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return $message->isa("HTTP::Request") || $message->isa("Plack::Request"); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$message->isa('HTTP::Request') || $message->isa('Plack::Request')
MC/DC0%0/2
$message->isa('HTTP::Request') || $message->isa('Plack::Request')
$message->isa('HTTP::Request')
$message->isa('Plack::Request')
Truth table0%0/3
A || B
A= $message->isa('HTTP::Request')B= $message->isa('Plack::Request')
| |||||||||||||||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||||||||||||
| 48 | 3 | init_arg => undef, | |||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||
| 52 | has is_response => ( | ||||||||||||||||||||||||||||||||||||||
| 53 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 54 | isa => Bool, | ||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | builder => sub($self) { $self->message->isa("HTTP::Response") }, | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_is_response: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 56 | 3 | init_arg => undef, | |||||||||||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||
| 60 | has user_agent => ( | ||||||||||||||||||||||||||||||||||||||
| 61 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 62 | isa => InstanceOf ['HTTP::Tiny'], | ||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | builder => sub($self) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return HTTP::Tiny->new; | |||||||||||||||||||||||||||||||||||||
| 65 | }, | ||||||||||||||||||||||||||||||||||||||
| 66 | 3 | ); | |||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||
| 69 | has signature_agent => ( | ||||||||||||||||||||||||||||||||||||||
| 70 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 71 | isa => NonEmptyStr, | ||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | builder => sub($self) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_signature_agent: not called CC=3 SCAR=24.8
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $agent = join(",", $self->headers->header("signature-agent") ); | |||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ( $agent =~ /\A \w+ = /ax ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | my ($key) = $self->headers->header("signature-agent-key") || $self->signature_labels; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->headers->header('signature-agent-key') || $self->signature_labels
$self->headers->header('signature-agent-key') || $self->signature_labels
MC/DC0%0/2
$self->headers->header('signature-agent-key') || $self->signature_labels
$self->headers->header('signature-agent-key')
$self->signature_labels
MC/DC0%0/2
$self->headers->header('signature-agent-key') || $self->signature_labels
$self->headers->header('signature-agent-key')
$self->signature_labels
Truth table0%0/3
A || B
A= $self->headers->header('signature-agent-key')B= $self->signature_labels
Truth table0%0/3
A || B
A= $self->headers->header('signature-agent-key')B= $self->signature_labels
| |||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $agents = $self->_parse_dict( ',', $agent ); | |||||||||||||||||||||||||||||||||||||
| 77 | 0 | $agent = $agents->{ unquote($key) }; | |||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return $agent; | |||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||
| 81 | 3 | ); | |||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||
| 84 | has signature_agent_uri => ( | ||||||||||||||||||||||||||||||||||||||
| 85 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 86 | isa => Uri, | ||||||||||||||||||||||||||||||||||||||
| 87 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | builder => sub($self) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_signature_agent_uri: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my $uri = URI->new( unquote( $self->signature_agent ) ); | |||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | carp "signature-agent header contains a full URL" if $uri->path && $uri->path ne "/"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$uri->path and $uri->path ne "/"
MC/DC0%0/2
$uri->path and $uri->path ne "/"
$uri->path
$uri->path ne "/"
Truth table0%0/3
A and B
A= $uri->pathB= $uri->path ne "/"
| |||||||||||||||||||||||||||||||||||||||
| 91 | 0 | $uri->path("/.well-known/http-message-signatures-directory"); | |||||||||||||||||||||||||||||||||||||
| 92 | 0 | return $uri; | |||||||||||||||||||||||||||||||||||||
| 93 | }, | ||||||||||||||||||||||||||||||||||||||
| 94 | 3 | ); | |||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | has signature_input => ( | ||||||||||||||||||||||||||||||||||||||
| 98 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 99 | isa => InstanceOf ['Hash::MultiValue'], | ||||||||||||||||||||||||||||||||||||||
| 100 | 4 | ▶ | builder => sub($self) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 101 | 4 | my @input = $self->headers->header("signature-input"); | |||||||||||||||||||||||||||||||||||||
| 102 | 4 | return $self->_parse_dict( ';', join( ';', @input ) ); | |||||||||||||||||||||||||||||||||||||
| 103 | }, | ||||||||||||||||||||||||||||||||||||||
| 104 | 3 | handles => { | |||||||||||||||||||||||||||||||||||||
| 105 | signature_labels => 'keys', | ||||||||||||||||||||||||||||||||||||||
| 106 | }, | ||||||||||||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||
| 110 | has signature_header => ( | ||||||||||||||||||||||||||||||||||||||
| 111 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 112 | isa => InstanceOf ['Hash::MultiValue'], | ||||||||||||||||||||||||||||||||||||||
| 113 | 2 | ▶ | builder => sub($self) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 114 | 2 | my @input = $self->headers->header("signature"); | |||||||||||||||||||||||||||||||||||||
| 115 | 2 | return $self->_parse_dict( ',', join( ',', @input ) ); | |||||||||||||||||||||||||||||||||||||
| 116 | }, | ||||||||||||||||||||||||||||||||||||||
| 117 | 3 | ); | |||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||
| 120 | has public_keys_json => ( | ||||||||||||||||||||||||||||||||||||||
| 121 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 122 | isa => NonEmptyStr, | ||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | builder => sub($self) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_public_keys_json: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||
| 125 | # TODO: add support for caching keys by URL | ||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||
| 127 | 0 | state $types = { map { $_ => 1 } qw[ application/http-message-signatures-directory+json application/json ] }; | |||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $uri = $self->signature_agent_uri; | |||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | croak "agent_uri should be an https URL" unless $uri->scheme eq "https"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my $res = | |||||||||||||||||||||||||||||||||||||
| 132 | $self->user_agent->get( "$uri", { headers => { 'Accept' => join( ",", keys $types->%* ) } } ); | ||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if ( $res->{success} && $types->{ $res->{headers}{'content-type'} } ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$res->{"success"} and $$types{$res->{"headers"}{"content-type"}}
MC/DC0%0/2
$res->{"success"} and $$types{$res->{"headers"}{"content-type"}}
$res->{"success"}
$$types{$res->{"headers"}{"content-type"}}
Truth table0%0/3
A and B
A= $res->{"success"}B= $$types{$res->{"headers"}{"content-type"}}
| |||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return $res->{content}; | |||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||
| 137 | 0 | croak "error retrieving ${uri}"; | |||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||
| 139 | 3 | ); | |||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||
| 142 | has public_keys => ( | ||||||||||||||||||||||||||||||||||||||
| 143 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||
| 144 | isa => HashRef, # TODO make strict validation optional | ||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | builder => sub($self) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_public_keys: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 146 | 0 | return decode_json( $self->public_keys_json ); | |||||||||||||||||||||||||||||||||||||
| 147 | }, | ||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ); | |||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||
| 151 | 3 | has require_tag => ( | |||||||||||||||||||||||||||||||||||||
| 152 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||
| 153 | isa => NonEmptyStr, | ||||||||||||||||||||||||||||||||||||||
| 154 | predicate => 1, | ||||||||||||||||||||||||||||||||||||||
| 155 | ); | ||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | sub is_expired($self) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
is_expired: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 159 | 2 | ▶ | my $expires = $self->signature_input->{expires} or return undef; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 160 | 2 | return time > $expires; | |||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||
| 164 | 2 | ▶ | sub verify( $self, $label = undef ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
verify: called CC=8 SCAR=21.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||
| 166 | 2 | ▶ | if ( $self->has_require_tag ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 167 | 2 | my $tag = $self->require_tag; | |||||||||||||||||||||||||||||||||||||
| 168 | 2 | ▶ | croak "tag is not '${tag}'" unless unquote( $self->signature_input->{tag} ) eq $tag; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||
| 171 | my $kid = unquote( $self->signature_input->{keyid} ) | ||||||||||||||||||||||||||||||||||||||
| 172 | 2 | ▶ | or croak "not keyid was found in the signature-input"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||
| 174 | # TODO: add support for looking up keys from a cache based on agent URL and key id. | ||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | my $key = first { $_->{kid} eq $kid } $self->public_keys->{keys}->@* | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 177 | 2 | ▶ | or croak "keyid '${kid}' was not found in the public keys"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||
| 179 | 2 | ▶ | croak "unsupposed algorithm" unless $key->{crv} eq "Ed25519"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||
| 181 | 2 | my $pk = Crypt::PK::Ed25519->new(); | |||||||||||||||||||||||||||||||||||||
| 182 | 2 | $pk->import_key($key); | |||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||
| 184 | 2 | ▶ | ($label) = $self->signature_labels unless defined $label; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 185 | 2 | my $sig = decode_base64( $self->signature_header->{$label} ); | |||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||
| 187 | 2 | my $base = $self->_generate_signature_base($label); | |||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||
| 189 | 2 | return $pk->verify_message( $sig, $base ); | |||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||
| 192 | 4 | ▶ | sub _generate_signature_base( $self, $label ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_generate_signature_base: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||
| 194 | 4 | my @buffer; | |||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | 4 | my $seen = Hash::Ordered->new; | |||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||
| 198 | 11 | ▶ | my sub _process_header_field( $field, $value ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_header_field: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||
| 200 | # TODO serialize line as per "component-identifier ABNF rule" | ||||||||||||||||||||||||||||||||||||||
| 201 | # TODO canonicalize the field value | ||||||||||||||||||||||||||||||||||||||
| 202 | 11 | ▶ | my $line = sprintf( '%s: %s', lc($field), $value // "" ); | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$value // ""
MC/DC0%0/1
$value // ""
$value
Truth table50%1/2
A
A= $value
| |||||||||||||||||||||||||||||||||||||||
| 203 | 11 | ▶ | croak "component has already been added to the sginature base" if $seen->exists( lc $field ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 204 | 11 | $seen->set( lc $field => 1 ); | |||||||||||||||||||||||||||||||||||||
| 205 | 11 | push @buffer, $line; | |||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||
| 208 | 4 | ▶ | my $input = $self->signature_input->{$label} or croak "signature-input label ${label} was not found"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||
| 210 | 4 | my @fields = split / /, unquote( $input, braces => 1 ); | |||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||
| 212 | 4 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||
| 213 | 7 | ▶ | if ( $field =~ /\A \"? \@/ax ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 214 | 4 | _process_header_field( $self->_get_derived_field($field) ); | |||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||
| 216 | else { | ||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||
| 218 | 3 | my $value; | |||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||
| 220 | 3 | my ( $key, $param ) = _structured_split( ';', $field ); | |||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||
| 222 | 3 | ▶ | my $ufield = unquote( $param ? $key : $field ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||
| 224 | 3 | my $header = $self->headers->header($ufield); | |||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||
| 226 | 3 | ▶ | if ($param) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 227 | 1 | my ( $name, $key ) = _structured_split( '=', $param ); | |||||||||||||||||||||||||||||||||||||
| 228 | 1 | my $hash = $self->_parse_dict( ";", $header ); | |||||||||||||||||||||||||||||||||||||
| 229 | 1 | $value = $hash->{ unquote($key) }; | |||||||||||||||||||||||||||||||||||||
| 230 | 1 | _process_header_field( $field => $value ); | |||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||
| 232 | else { | ||||||||||||||||||||||||||||||||||||||
| 233 | 2 | $value = $header; | |||||||||||||||||||||||||||||||||||||
| 234 | 2 | $field = unquote($field); | |||||||||||||||||||||||||||||||||||||
| 235 | 2 | _process_header_field( "\"${field}\"" => $value ); | |||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||
| 241 | 4 | my $header = $self->headers->header("signature-input"); | |||||||||||||||||||||||||||||||||||||
| 242 | 4 | ▶ | croak "unexpected signature-input" unless substr( $header, 0, length($label) + 1 ) eq "${label}="; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 243 | 4 | my $params = substr( $header, length($label) + 1 ); | |||||||||||||||||||||||||||||||||||||
| 244 | 4 | _process_header_field( '"@signature-params"' => $params ); | |||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||
| 246 | 4 | return join( "\n", @buffer ); | |||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||
| 249 | 4 | ▶ | sub _get_derived_field( $self, $field ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_derived_field: called CC=5 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||
| 251 | # Note: HTTP::Message has uri_canonical but Plack::Request does not. | ||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||
| 253 | state $handlers = { | ||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | '@status' => sub( $message, $ ) { $message->code }, | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | '@method' => sub( $message, $ ) { $message->method }, | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | '@target-uri' => sub( $message, $ ) { $message->uri }, | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 257 | 4 | ▶ | '@authority' => sub( $message, $ ) { $message->uri->authority }, | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | '@scheme' => sub( $message, $ ) { $message->uri->scheme }, | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | '@path' => sub( $message, $ ) { $message->uri->path }, | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | '@query' => sub( $message, $ ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $query = $message->uri_canonical->query; | |||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | if ( defined $query ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 263 | 0 | return '?' . $query; | |||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||
| 265 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||
| 266 | }, | ||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | '@query-param' => sub( $message, $param ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 268 | 0 | ▶ | if ( my ($name) = $param =~ /\A name = " ((?:\w+-)*\w+) " \z/ax ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||
| 270 | # Note: RFC 9421 Sec 2.2.8 says named parameters with multiple values must not be included | ||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my @values = $message->uri->query_param($name); | |||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | croak "multipe query-param values for '${name}'" if @values > 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 273 | 0 | return $values[0]; | |||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||
| 275 | }, | ||||||||||||||||||||||||||||||||||||||
| 276 | 4 | }; | |||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||
| 278 | 4 | my ( $key, $param, @extra ) = _structured_split( ';', $field ); | |||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||
| 280 | 4 | ▶ | croak "extra parameters in field ${field}" if @extra; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||
| 282 | 4 | ▶ | if ( my ($quoted) = $key =~ /\A " ( \@ (?:\w+-)* \w+ ) "\z/ax ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 283 | 4 | $key = $quoted; | |||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||
| 286 | 4 | ▶ | croak "unsupported field ${field}" unless exists $handlers->{$key}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||
| 288 | 4 | my $qfield = "\"${key}\""; | |||||||||||||||||||||||||||||||||||||
| 289 | 4 | ▶ | $qfield .= ";${param}" if defined $param; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||
| 291 | 4 | return ( maybe $qfield => $handlers->{$key}->( $self->message, $param ) ); | |||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||
| 294 | 7 | ▶ | sub _parse_dict( $self, $on, $input ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_dict: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 295 | 7 | return Hash::MultiValue->new( map { _structured_split( '=', $_ ) } _structured_split( $on, $input ) ); | |||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||
| 299 | 3 | ▶ | use constant DQUOTE => "\""; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 300 | 3 | ▶ | use constant ESCAPE => "\\"; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 301 | 3 | ▶ | use constant INNER_START => '('; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 302 | 3 | ▶ | use constant INNER_END => ')'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||
| 304 | 51 | ▶ | sub _structured_split( $on, $input ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_structured_split: called CC=20 SCAR=37.2
| |||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||
| 306 | 51 | my @res; | |||||||||||||||||||||||||||||||||||||
| 307 | my @ctx; | ||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||
| 309 | 51 | my $i = 0; | |||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||
| 311 | 51 | ▶ | while ( $i < length($input) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||
| 313 | 2331 | my $char = substr( $input, $i, 1 ); | |||||||||||||||||||||||||||||||||||||
| 314 | match( $char : eq ) { | ||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||
| 316 | case (ESCAPE) { | ||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | my $next = substr( $input, $i + 1, 1 ) // ''; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
substr($input, $i + 1, 1) // ""
MC/DC0%0/1
substr($input, $i + 1, 1) // ""
substr($input, $i + 1, 1)
Truth table0%0/2
A
A= substr($input, $i + 1, 1)
| |||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | unless ( $next eq ESCAPE || $next eq DQUOTE ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$next eq "\\" or $next eq "\""
MC/DC0%0/2
$next eq "\\" or $next eq "\""
$next eq "\\"
$next eq "\""
Truth table0%0/3
A or B
A= $next eq "\\"B= $next eq "\""
| |||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $i += 2; | |||||||||||||||||||||||||||||||||||||
| 320 | 0 | next; | |||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | croak "invalid character after backslash"; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||
| 325 | case (INNER_START) { | ||||||||||||||||||||||||||||||||||||||
| 326 | 12 | ▶ | unless ( $ctx[-1] && $ctx[-1] eq DQUOTE ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ctx[-1] and $ctx[-1] eq "\""
MC/DC0%0/2
$ctx[-1] and $ctx[-1] eq "\""
$ctx[-1]
$ctx[-1] eq "\""
Truth table33%1/3
A and B
A= $ctx[-1]B= $ctx[-1] eq "\""
| |||||||||||||||||||||||||||||||||||||||
| 327 | 12 | ▶ | push @ctx, INNER_END; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||
| 331 | case (DQUOTE) { | ||||||||||||||||||||||||||||||||||||||
| 332 | 140 | ▶ | if ( $ctx[-1] && $ctx[-1] eq DQUOTE ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ctx[-1] and $ctx[-1] eq "\""
MC/DC100%2/2
$ctx[-1] and $ctx[-1] eq "\""
$ctx[-1]
$ctx[-1] eq "\""
Truth table100%3/3
A and B
A= $ctx[-1]B= $ctx[-1] eq "\""
| |||||||||||||||||||||||||||||||||||||||
| 333 | 70 | pop @ctx; | |||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||
| 335 | else { | ||||||||||||||||||||||||||||||||||||||
| 336 | 70 | ▶ | push @ctx, DQUOTE; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||
| 340 | case (INNER_END) { | ||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||
| 342 | 12 | ▶ | if ( $ctx[-1] && $ctx[-1] eq INNER_END ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$ctx[-1] and $ctx[-1] eq ")"
MC/DC0%0/2
$ctx[-1] and $ctx[-1] eq ")"
$ctx[-1]
$ctx[-1] eq ")"
Truth table33%1/3
A and B
A= $ctx[-1]B= $ctx[-1] eq ")"
| |||||||||||||||||||||||||||||||||||||||
| 343 | 12 | pop @ctx; | |||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||
| 345 | ▶ | elsif ( !( $ctx[-1] && $ctx[-1] eq DQUOTE ) ) { | |||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ctx[-1] && $ctx[-1] eq '"'
MC/DC0%0/2
$ctx[-1] && $ctx[-1] eq '"'
$ctx[-1]
$ctx[-1] eq '"'
Truth table0%0/3
A && B
A= $ctx[-1]B= $ctx[-1] eq '"'
| |||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | croak "unbalanced bracket"; | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$(Syntax::Keyword::Match/topic) eq $on and do {
unless ($ctx[-1]) {
push @res, trim(substr($input, 0, $i));
$input = substr($input, $i + 1);
$i = 0;
next;
}
}
MC/DC0%0/2
$(Syntax::Keyword::Match/topic) eq $on and do {
unless ($ctx[-1]) {
push @res, trim(substr($input, 0, $i));
$input = substr($input, $i + 1);
$i = 0;
next;
}
}
$(Syntax::Keyword::Match/topic) eq $on
do {
unless ($ctx[-1]) {
push @res, trim(substr($input, 0, $i));
$input = substr($input, $i + 1);
$i = 0;
next;
}
}
Truth table66%2/3
A and B
A= $(Syntax::Keyword::Match/topic) eq $onB= do {
unless ($ctx[-1]) {
push @res, trim(substr($input, 0, $i));
$input = substr($input, $i + 1);
$i = 0;
next;
}
}
| |||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||
| 350 | 2331 | ▶ | case ($on) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||
| 352 | 84 | ▶ | unless ( $ctx[-1] ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 353 | 71 | push @res, trim( substr( $input, 0, $i ) ); | |||||||||||||||||||||||||||||||||||||
| 354 | 71 | $input = substr( $input, $i + 1 ); | |||||||||||||||||||||||||||||||||||||
| 355 | 71 | $i = 0; | |||||||||||||||||||||||||||||||||||||
| 356 | 71 | next; | |||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||
| 362 | 2260 | $i++; | |||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||
| 365 | 51 | ▶ | push @res, trim($input) unless $input eq ""; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||
| 367 | 51 | return @res; | |||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||
| 372 | 4 | ▶ | sub BUILDARGS( $, @args ) { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=4 SCAR=14.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||
| 374 | 4 | ▶ | my %args = @args == 1 && is_plain_hashref( $args[0] ) ? $args[0]->%* : @args; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@args == 1 and Ref::Util::XS::is_plain_hashref($args[0])
MC/DC0%0/2
@args == 1 and Ref::Util::XS::is_plain_hashref($args[0])
@args == 1
Ref::Util::XS::is_plain_hashref($args[0])
Truth table33%1/3
A and B
A= @args == 1B= Ref::Util::XS::is_plain_hashref($args[0])
| |||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||
| 376 | 4 | my $message = $args{message}; | |||||||||||||||||||||||||||||||||||||
| 377 | 4 | ▶ | if ( is_plain_hashref($message) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 378 | 1 | require Plack::Request; | |||||||||||||||||||||||||||||||||||||
| 379 | 1 | $args{message} = Plack::Request->new($message); | |||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||
| 383 | 4 | return \%args; | |||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||
| 387 | 3 | 1; | |||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||
| 389 | __END__ | ||||||||||||||||||||||||||||||||||||||