line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package QualysGuard::Response; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
26
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
2518
|
|
4
|
3
|
|
|
3
|
|
21
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
102
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
14
|
use base qw( XML::XPath ); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
6091
|
|
7
|
|
|
|
|
|
|
use IO::File; |
8
|
|
|
|
|
|
|
use Carp; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# new - constructor |
16
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
17
|
|
|
|
|
|
|
sub new { |
18
|
|
|
|
|
|
|
my ( $class, $xml ) = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if ( ! defined $xml ) { |
21
|
|
|
|
|
|
|
croak "Missing or undefined XML response"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $self = __PACKAGE__->SUPER::new( $xml ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# -- extract the DOCTYPE |
27
|
|
|
|
|
|
|
my $doctype = (split("\n", $xml))[1]; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
if ( $doctype !~ m/^/ ) { |
30
|
|
|
|
|
|
|
croak "Missing on unknown DOCTYPE"; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$self->{doctype} = $1; |
34
|
|
|
|
|
|
|
$self->{dtd} = $2; |
35
|
|
|
|
|
|
|
$self->{data} = undef; |
36
|
|
|
|
|
|
|
$self->{xsl_output} = undef; |
37
|
|
|
|
|
|
|
$self->{error_code} = undef; |
38
|
|
|
|
|
|
|
$self->{error_text} = undef; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return $self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
45
|
|
|
|
|
|
|
# is_error |
46
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
47
|
|
|
|
|
|
|
sub is_error { |
48
|
|
|
|
|
|
|
my $self = shift; |
49
|
|
|
|
|
|
|
return ( defined $self->{error_code} ) ? 1 : 0; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
55
|
|
|
|
|
|
|
# error_code |
56
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
57
|
|
|
|
|
|
|
sub error_code { |
58
|
|
|
|
|
|
|
my $self = shift; |
59
|
|
|
|
|
|
|
if ( $self->is_error() ) { |
60
|
|
|
|
|
|
|
return $self->{error_code}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
67
|
|
|
|
|
|
|
# get_error |
68
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
69
|
|
|
|
|
|
|
sub get_error { |
70
|
|
|
|
|
|
|
my $self = shift; |
71
|
|
|
|
|
|
|
if ( $self->is_error() ) { |
72
|
|
|
|
|
|
|
return sprintf("Qualys Error [%s] : %s", $self->{error_code}, $self->{error_text} ); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
79
|
|
|
|
|
|
|
# save_to |
80
|
|
|
|
|
|
|
# ------------------------------------------------------------------- |
81
|
|
|
|
|
|
|
sub save_to { |
82
|
|
|
|
|
|
|
my $self = shift; |
83
|
|
|
|
|
|
|
my $filename = shift; |
84
|
|
|
|
|
|
|
my $FH = IO::File->new(); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
if ( $FH->open("> $filename") ) { |
87
|
|
|
|
|
|
|
print $FH $self->get_xml(); |
88
|
|
|
|
|
|
|
$FH->close(); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
else { |
92
|
|
|
|
|
|
|
carp "Error : $!"; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |