HTTP/Execute.pm untested

filter: Statementstmt 0.0% 0 / 21 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 28 CC 2 SCAR 12.8
CC
2
Cov
0%
index
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.6
1 package Rex::Endpoint::HTTP::Execute;
2 use Mojo::Base 'Mojolicious::Controller';
3  
4 use Mojo::JSON;
5  
6 use Rex::Endpoint::HTTP::Interface::Exec;
7  
8 # This action will render a template
9 sub index {
10 my $self = shift;
11  
12 my $ref = $self->req->json;
13 my $cmd = $ref->{exec};
14  
15 my ($out);
16 eval {
17 my $iface = Rex::Endpoint::HTTP::Interface::Exec->create;
18 $out = $iface->exec($cmd);
19 };
20  
21 if($@) {
22 return $self->render_json({ok => Mojo::JSON->false, output => "$@", retval => 1});
23 }
24  
25 $self->render_json({ok => Mojo::JSON->true, output => $out, retval => $?});
26 }
27  
28 1;