| 1 | package App::BCSSH::Client; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use App::BCSSH::Message qw(send_message BCSSH_SUCCESS BCSSH_FAILURE BCSSH_COMMAND); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use JSON qw(encode_json decode_json); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 0 | ▶ | has 'agent' => ( is => 'ro', default => sub { $ENV{SSH_AUTH_SOCK} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 0 | ▶ | has 'auth_key' => ( is => 'ro', default => sub { $ENV{LC_BCSSH_KEY} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | has 'agent_socket' => ( is => 'lazy' ); | |||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | if (! $ENV{SSH_CONNECTION}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | die "No SSH connection!\n"; | |||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub _build_agent_socket { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_agent_socket: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | require IO::Socket::UNIX; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | IO::Socket::UNIX->new( | |||||||||||||||||||||||||||||||||||||||||
| 20 | Peer => $self->agent, | ||||||||||||||||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 22 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub handler { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handler: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | $class =~ s/.*:://; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | return $class; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub command { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
command: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | my $key = $self->auth_key || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->auth_key || ''
MC/DC0%0/1
$self->auth_key || ''
$self->auth_key
Truth table0%0/2
A
A= $self->auth_key
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $message = join '|', $self->handler, $key, encode_json(\@args); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my ($rtype, $rmessage) = send_message($self->agent_socket, BCSSH_COMMAND, $message); | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if (defined $rtype && $rtype == BCSSH_FAILURE && $rmessage) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
defined $rtype and $rtype == -42 and $rmessage
defined $rtype and $rtype == -42
MC/DC0%0/3
defined $rtype and $rtype == -42 and $rmessage
defined $rtype
$rtype == -42
$rmessage
Truth table0%0/4
A and B and C
A= defined $rtypeB= $rtype == -42C= $rmessage
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | die $rmessage; | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ($rtype != BCSSH_SUCCESS) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | die "Error!"; | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | unless (defined $rmessage && length $rmessage) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $rmessage and length $rmessage
MC/DC0%0/2
defined $rmessage and length $rmessage
defined $rmessage
length $rmessage
Truth table0%0/3
A and B
A= defined $rmessageB= length $rmessage
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $response = decode_json($rmessage); | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return wantarray ? @$response : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 50 | __END__ | ||||||||||||||||||||||||||||||||||||||||||