line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package QualysGuard::Response::HostInfo; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5577
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
81
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
50
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use base qw( QualysGuard::Response ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
214
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ============================================================= |
12
|
|
|
|
|
|
|
# - new |
13
|
|
|
|
|
|
|
# ============================================================= |
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
my ( $class, $xml ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $self = __PACKAGE__->SUPER::new( $xml ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
bless $self, $class; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# -- check for QualysGuard function error |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
if ( $self->exists('/HOST/ERROR') ) { |
24
|
|
|
|
|
|
|
$self->{error_code} = $self->findvalue('/HOST/ERROR/@number'); |
25
|
|
|
|
|
|
|
$self->{error_text} = $self->getNodeText('/HOST/ERROR'); |
26
|
|
|
|
|
|
|
$self->{error_text} =~ s/^\s+(.*)\s+$/$1/m; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return $self; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# ============================================================= |
35
|
|
|
|
|
|
|
# - various get methods |
36
|
|
|
|
|
|
|
# ============================================================= |
37
|
|
|
|
|
|
|
sub get_tracking_method { $_[0]->getNodeText( '/HOST/TRACKING_METHOD' )->string_value(); } |
38
|
|
|
|
|
|
|
sub get_security_risk { $_[0]->getNodeText( '/HOST/SECURITY_RISK' )->string_value(); } |
39
|
|
|
|
|
|
|
sub get_ip { $_[0]->getNodeText( '/HOST/IP' )->string_value(); } |
40
|
|
|
|
|
|
|
sub get_dns { $_[0]->getNodeText( '/HOST/DNS' )->string_value(); } |
41
|
|
|
|
|
|
|
sub get_netbios { $_[0]->getNodeText( '/HOST/NETBIOS' )->string_value(); } |
42
|
|
|
|
|
|
|
sub get_operating_system { $_[0]->getNodeText( '/HOST/OPERATING_SYSTEM' )->string_value(); } |
43
|
|
|
|
|
|
|
sub get_last_scan_date { $_[0]->getNodeText( '/HOST/LAST_SCAN_DATE' )->string_value(); } |
44
|
|
|
|
|
|
|
sub get_comment { $_[0]->getNodeText( '/HOST/COMMENT' )->string_value(); } |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# ============================================================= |
49
|
|
|
|
|
|
|
# - get_ticket_numbers |
50
|
|
|
|
|
|
|
# ============================================================= |
51
|
|
|
|
|
|
|
sub get_ticket_numbers { |
52
|
|
|
|
|
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
my @nodes = $self->findnodes('/HOST/TICKETS/*/*/TICKET_NUMBER'); |
54
|
|
|
|
|
|
|
my @tickets = (); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
foreach my $node ( @nodes ) { |
57
|
|
|
|
|
|
|
push( @tickets, $node->string_value() ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
return \@tickets; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# ============================================================= |
66
|
|
|
|
|
|
|
# - get_vuln_info |
67
|
|
|
|
|
|
|
# ============================================================= |
68
|
|
|
|
|
|
|
sub get_vuln_info { |
69
|
|
|
|
|
|
|
my $self = shift; |
70
|
|
|
|
|
|
|
my @nodes = $self->findnodes('/HOST/*/*/VULNINFO'); |
71
|
|
|
|
|
|
|
my @vulns = (); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
foreach my $node ( @nodes ) { |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my @children = $node->getChildNodes(); |
76
|
|
|
|
|
|
|
my $vuln = {}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$vuln->{VULN_LEVEL} = $node->getParentNode()->getParentNode()->getName(); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
foreach my $child ( @children ) { |
81
|
|
|
|
|
|
|
next unless ( $child->isa( "XML::XPath::Node::Element" ) ); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $key = $child->getName(); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# ------- CVSS_SCORE ------------------------------------------- |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
if ( $key eq "CVSS_SCORE" ) { |
88
|
|
|
|
|
|
|
$vuln->{$key} = {}; |
89
|
|
|
|
|
|
|
my @gc = $child->getChildNodes(); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
foreach my $c ( @gc ) { |
92
|
|
|
|
|
|
|
next unless ( $c->isa( "XML::XPath::Node::Element" ) ); |
93
|
|
|
|
|
|
|
my $ckey = $c->getName(); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
if ( defined $ckey ) { |
96
|
|
|
|
|
|
|
$vuln->{$key}->{$ckey} = $c->string_value(); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# ------- LISTS ------------------------------------------------- |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
elsif ( $key eq "VENDOR_REFERENCE_LIST" || $key eq "CVE_ID_LIST" || $key eq "BUGTRAQ_ID_LIST" ) { |
104
|
|
|
|
|
|
|
my @n = $child->findnodes( "*/ID" ); |
105
|
|
|
|
|
|
|
$vuln->{$key} = (); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
foreach my $id ( @n ) { |
108
|
|
|
|
|
|
|
push( @{$vuln->{$key}}, $id->string_value() ); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
else { |
113
|
|
|
|
|
|
|
$vuln->{$key} = $child->string_value(); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
push(@vulns, $vuln); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
return \@vulns; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
__END__ |