| 1 | # $Id: Parser.pm 302 2009-11-21 02:31:24Z jabra $ | ||||||||||||
| 2 | package Fierce::Parser; | ||||||||||||
| 3 | { | ||||||||||||
| 4 | 1 | our $VERSION = '0.08'; | |||||||||||
| 5 | 1 | $VERSION = eval $VERSION; | |||||||||||
| 6 | |||||||||||||
| 7 | 1 | ▶ | use Object::InsideOut; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 1 | ▶ | use Fierce::Parser::Session; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 1 | my @session : Field : Arg(session) : Get(session) : | |||||||||||
| 10 | Type(Fierce::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 Fierce::Parser->new( | |||||||||||
| 26 | session => Fierce::Parser::Session->parse( $parser, $doc ) ); | ||||||||||||
| 27 | } | ||||||||||||
| 28 | |||||||||||||
| 29 | 0 | ▶ | sub parse_scan { | ||||||||||
|
Subroutine
parse_scan: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||
| 30 | 0 | my ( $self, $args, @domains ) = @_; | |||||||||||
| 31 | 0 | my $FH; | |||||||||||
| 32 | |||||||||||||
| 33 | 0 | ▶ | if ( $args =~ /-format/i ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 34 | 0 | die | |||||||||||
| 35 | "[Fierce::Parser] Cannot pass option '-format ' to parse_scan()"; | ||||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | 0 | ▶ | if ( $args =~ /-output/i ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 39 | 0 | die | |||||||||||
| 40 | "[Fierce::Parser] Cannot pass option '-output ' to parse_scan()"; | ||||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | 0 | my $cmd = "fierce -format xml $args -dns " . ( join ',', @domains ); | |||||||||||
| 44 | |||||||||||||
| 45 | #print "$cmd\n"; | ||||||||||||
| 46 | 0 | ▶ | open $FH, "$cmd |" | ||||||||||
|
Condition0%0/2
"$cmd |" || die("[Fierce::Parser] Could not perform nikto scan - $!")
MC/DC0%0/1
"$cmd |" || die("[Fierce::Parser] Could not perform nikto scan - $!")
"$cmd |"
Truth table0%0/2
A
A= "$cmd |"
| |||||||||||||
| 47 | || die "[Fierce::Parser] Could not perform nikto scan - $!"; | ||||||||||||
| 48 | 0 | my $p = XML::LibXML->new(); | |||||||||||
| 49 | 0 | my $doc = $p->parse_fh($FH); | |||||||||||
| 50 | 0 | my $parser = Fierce::Parser->new( | |||||||||||
| 51 | session => Fierce::Parser::Session->parse( $p, $doc ) ); | ||||||||||||
| 52 | 0 | close $FH; | |||||||||||
| 53 | 0 | return $parser; | |||||||||||
| 54 | } | ||||||||||||
| 55 | |||||||||||||
| 56 | 0 | ▶ | sub get_session { | ||||||||||
|
Subroutine
get_session: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 57 | 0 | my ($self) = @_; | |||||||||||
| 58 | 0 | return $self->session; | |||||||||||
| 59 | } | ||||||||||||
| 60 | |||||||||||||
| 61 | 0 | ▶ | sub get_node { | ||||||||||
|
Subroutine
get_node: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 62 | 0 | my ( $self, $domain ) = @_; | |||||||||||
| 63 | 0 | return $self->session->domainscandetails->get_host_hostname($domain); | |||||||||||
| 64 | } | ||||||||||||
| 65 | |||||||||||||
| 66 | 0 | ▶ | sub get_all_nodes { | ||||||||||
|
Subroutine
get_all_nodes: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 67 | 0 | my ($self) = @_; | |||||||||||
| 68 | 0 | my @all_hosts = $self->session->domainscandetails->all_hosts(); | |||||||||||
| 69 | 0 | return @all_hosts; | |||||||||||
| 70 | } | ||||||||||||
| 71 | } | ||||||||||||
| 72 | 1 | 1; | |||||||||||
| 73 | |||||||||||||