Parser.pm

filter: Statementstmt 26.8% 11 / 41 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 28.5% 2 / 7 Podpod 100% 5 / 5 totaltotal 28.1% 18 / 64 CC 6 SCAR 30.8
CC
6
Cov
22%
parse_scan
42.0
parse_file
2.0
get_session
2.0
CRAP 21.8
« Parser/ScanDetails.pm ↑ Summary Parser/Session.pm »
1 # $Id: Parser.pm 142 2009-10-16 19:13:45Z jabra $
2 package Nikto::Parser;
3 {
4 1 our $VERSION = '0.01';
5 1 $VERSION = eval $VERSION;
6  
7 1 ▶ use Object::InsideOut;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶ use Nikto::Parser::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 my @session : Field : Arg(session) : Get(session) :
10 Type(Nikto::Parser::Session);
11  
12 # parse_file
13 #
14 # Input:
15 # argument - self obj -
16 # argument - xml scalar
17 #
18 # Ouptut:
19 #
20 0 ▶ sub parse_file {
Subroutine parse_file: not called CC=1 SCAR=6.9
Pod documented
21 0 my ( $self, $file ) = @_;
22 0 my $parser = XML::LibXML->new();
23  
24 0 my $doc = $parser->parse_file($file);
25 0 return Nikto::Parser->new(
26 session => Nikto::Parser::Session->parse( $parser, $doc ) );
27 }
28  
29 0 ▶ sub parse_scan {
Subroutine parse_scan: not called CC=6 SCAR=37.4
Pod documented
30 0 my ( $self, $ndir, $args, @ips ) = @_;
31 0 my $FH;
32  
33 0 ▶ if ( $args =~ /-Format/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args =~ /-Format/) 0 0 0
34 0 die
35 "[Nikto-Parser] Cannot pass option '-Format ' to parse_scan()";
36 }
37  
38 0 ▶ if ( $args =~ /-output/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args =~ /-output/) 0 0 0
39 0 die
40 "[Nikto-Parser] Cannot pass option '-output ' to parse_scan()";
41 }
42 0 ▶ if ( -d $ndir ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $ndir) { } 0 0 0
43 0 ▶ chdir $ndir or die "[Nikto-Parser] $ndir not a directory\n";
Branch: 1 branch
BranchTrueFalseTotal
chdir $ndir or die "[Nikto-Parser] $ndir not a directory\n" 0 0 0
44 }
45 else {
46 0 die "[Nikto-Parser] $ndir not a directory\n";
47 }
48  
49 0 my $cmd = "./nikto.pl -Format xml -output \"-\" -host "
50 . ( join ' ', @ips );
51 0 print "$cmd\n";
52 0 ▶ open $FH, "$cmd |"
Condition0%0/2
"$cmd |" || die("[Nikto-Parser] Could not perform nikto scan - $!")
l!l
00
MC/DC0%0/1
"$cmd |" || die("[Nikto-Parser] Could not perform nikto scan - $!")
"$cmd |"
Truth table0%0/2
A
A= "$cmd |"
Aresult
11
00
53 || die "[Nikto-Parser] Could not perform nikto scan - $!";
54 0 my $p = XML::LibXML->new();
55 0 my $doc = $p->parse_fh($FH);
56 0 my $parser = Nikto::Parser->new(
57 session => Nikto::Parser::Session->parse( $p, $doc ) );
58 0 close $FH;
59 0 return $parser;
60 }
61  
62 # return the session information for the current nikto scan
63 0 ▶ sub get_session {
Subroutine get_session: not called CC=1 SCAR=6.9
Pod documented
64 0 my ($self) = @_;
65 0 my $session = $self->session;
66 0 return $session;
67 }
68  
69 # return the host obj based on an ip address
70 0 ▶ sub get_host {
Subroutine get_host: not called CC=1 SCAR=6.9
Pod documented
71 0 my ( $self, $ip ) = @_;
72 0 my $host_obj = $self->session->scandetails->get_host_ip($ip);
73 0 return $host_obj;
74 }
75  
76 # return an ArrayRef containing all of the host objs
77 0 ▶ sub get_all_hosts {
Subroutine get_all_hosts: not called CC=1 SCAR=6.9
Pod documented
78 0 my ($self) = @_;
79 0 my @all_hosts = $self->session->scandetails->all_hosts();
80 0 return @all_hosts;
81 }
82 }
83 1 1;
84  
« Parser/ScanDetails.pm ↑ Summary Parser/Session.pm »