line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OpenVAS::OMP::Response; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1127
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
63
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
49
|
|
5
|
2
|
|
|
2
|
|
9
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
6
|
2
|
|
|
2
|
|
63
|
use feature ':5.10'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
245
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
455
|
use Net::OpenVAS::Error; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
56
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
111
|
|
11
|
2
|
|
|
2
|
|
559
|
use XML::Hash::XS; |
|
2
|
|
|
|
|
1147
|
|
|
2
|
|
|
|
|
115
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
12
|
use overload q|""| => 'raw', fallback => 1; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.200'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
1
|
5
|
my ( $class, %args ) = @_; |
20
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
2
|
my $request = $args{'request'}; |
22
|
1
|
|
|
|
|
2
|
my $response = $args{'response'}; |
23
|
1
|
|
|
|
|
3
|
my $command = $request->command; |
24
|
|
|
|
|
|
|
|
25
|
1
|
50
|
|
|
|
4
|
croak q/Net::OpenVAS::OMP::Response ( 'request' => ... ) must be "Net::OpenVAS::OMP::Request" instance/ |
26
|
|
|
|
|
|
|
if ( !ref $request eq 'Net::OpenVAS::OMP::Request' ); |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
3
|
$response =~ s/<\?xml.*?\?>//; # Remove XML version and encoding from the response for XML report |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
7
|
my $status = ( $response =~ /(status)="([^"]*)"/ )[1]; |
31
|
1
|
|
|
|
|
5
|
my $status_text = ( $response =~ /(status_text)="([^"]*)"/ )[1]; |
32
|
1
|
|
|
|
|
2
|
my $error = undef; |
33
|
|
|
|
|
|
|
|
34
|
1
|
50
|
|
|
|
4
|
if ( $status >= 400 ) { |
35
|
0
|
|
|
|
|
0
|
$error = Net::OpenVAS::Error->new( $status_text, $status ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $self = { |
39
|
|
|
|
|
|
|
status => $status + 0, |
40
|
|
|
|
|
|
|
raw => $response, |
41
|
|
|
|
|
|
|
request => $request, |
42
|
|
|
|
|
|
|
status_text => $status_text, |
43
|
|
|
|
|
|
|
error => $error, |
44
|
1
|
|
|
|
|
3
|
result => eval { xml2hash $response }, |
|
1
|
|
|
|
|
72
|
|
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
7
|
return bless $self, $class; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub result { |
52
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
53
|
0
|
|
|
|
|
0
|
return $self->{result}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub error { |
57
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
58
|
1
|
|
|
|
|
5
|
return $self->{error}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub status { |
62
|
2
|
|
|
2
|
1
|
7
|
my ($self) = @_; |
63
|
2
|
|
|
|
|
36
|
return $self->{status}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub is_ok { |
67
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
68
|
1
|
50
|
|
|
|
4
|
return ( $self->status == 200 ) ? 1 : 0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub is_created { |
72
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
73
|
0
|
0
|
|
|
|
0
|
return ( $self->status == 201 ) ? 1 : 0; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub is_accepted { |
77
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
78
|
0
|
0
|
|
|
|
0
|
return ( $self->status == 202 ) ? 1 : 0; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub is_forbidden { |
82
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
83
|
0
|
0
|
|
|
|
0
|
return ( $self->status == 403 ) ? 1 : 0; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub is_not_found { |
87
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
88
|
0
|
0
|
|
|
|
0
|
return ( $self->status == 404 ) ? 1 : 0; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub is_busy { |
92
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
93
|
0
|
0
|
|
|
|
0
|
return ( $self->status == 409 ) ? 1 : 0; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub is_server_error { |
97
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
98
|
0
|
0
|
|
|
|
0
|
return ( $self->status >= 500 ) ? 1 : 0; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub status_text { |
102
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
103
|
1
|
|
|
|
|
5
|
return $self->{status_text}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub raw { |
107
|
1
|
|
|
1
|
1
|
3
|
my ($self) = @_; |
108
|
1
|
|
|
|
|
4
|
return $self->{raw}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub command { |
112
|
1
|
|
|
1
|
1
|
2
|
my ($self) = @_; |
113
|
1
|
|
|
|
|
4
|
return $self->{request}->command; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub request { |
117
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
118
|
0
|
|
|
|
|
|
return $self->{request}; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
122
|
|
|
|
|
|
|
__END__ |