lib/Rex/Interface/Exec/HTTP.pm

filter: Statementstmt 25.0% 10 / 40 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 19.4% 13 / 67 CC 9 SCAR 38.2
CC
9
Cov
18%
exec
72.0
new
6.0
BEGIN
1.0
CRAP 45.5
« lib/Rex/Interface/Exec/IOReader.pm ↑ Summary lib/Rex/Pkg.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Interface::Exec::HTTP;
6  
7 1 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Rex::Commands;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = '1.16.1'; # VERSION
12  
13 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
14 0 my $that = shift;
15 0 ▶ my $proto = ref($that) || $that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
16 0 my $self = {@_};
17  
18 0 bless( $self, $proto );
19  
20 0 return $self;
21 }
22  
23 0 ▶sub exec {
Subroutine exec: not called CC=8 SCAR=42.8
Pod undocumented
24 0 my ( $self, $cmd, $path, $option ) = @_;
25  
26 0 Rex::Logger::debug("Executing: $cmd");
27  
28 0 ▶ if ( exists $option->{path} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $option->{"path"}) 0 0 0
29 0 $path = $option->{path};
30 }
31  
32 0 ▶ if ($path) { $path = "PATH=$path" }
Branch: 1 branch
BranchTrueFalseTotal
if ($path) 0 0 0
33 0 ▶ $path ||= "";
Condition0%0/2
$path ||= ""
l!l
00
MC/DC0%0/1
$path ||= ""
$path
Truth table0%0/2
A
A= $path
Aresult
11
00
34  
35 # let the other side descide if LC_ALL=C should be used
36 # for example, this will not work on windows
37 #$cmd = "LC_ALL=C $path " . $cmd;
38  
39 0 Rex::Commands::profiler()->start("exec: $cmd");
40  
41 0 my $new_cmd = $cmd;
42 0 ▶ if ( Rex::Config->get_source_global_profile ) {
Branch: 1 branch
BranchTrueFalseTotal
if ("Rex::Config"->get_source_global_profile) 0 0 0
43 0 $new_cmd = ". /etc/profile >/dev/null 2>&1; $new_cmd";
44 }
45  
46 0 my $resp =
47 connection->post( "/execute", { exec => $new_cmd, options => $option } );
48 0 Rex::Commands::profiler()->end("exec: $cmd");
49  
50 0 ▶ if ( $resp->{ok} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($resp->{'ok'}) { } 0 0 0
51 0 $? = $resp->{retval};
52 0 my ( $out, $err ) = ( $resp->{output}, "" );
53  
54 0 Rex::Logger::debug($out);
55  
56 0 ▶ if ($err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err) 0 0 0
57 0 Rex::Logger::debug("========= ERR ============");
58 0 Rex::Logger::debug($err);
59 0 Rex::Logger::debug("========= ERR ============");
60 }
61  
62 0 ▶ if (wantarray) { return ( $out, $err ); }
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
63  
64 0 return $out;
65 }
66 else {
67 0 $? = 1;
68 }
69  
70 }
71  
72 1 1;
« lib/Rex/Interface/Exec/IOReader.pm ↑ Summary lib/Rex/Pkg.pm »