line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SecurityCenter::API::Scanner; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
940
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
4
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
89
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
11
|
use parent 'Net::SecurityCenter::Base'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
108
|
use Net::SecurityCenter::Utils qw(:all); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1314
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.310'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $common_template = { |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
id => { |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
allow => qr/^\d+$/, |
19
|
|
|
|
|
|
|
messages => { |
20
|
|
|
|
|
|
|
required => 'Scanner ID is required', |
21
|
|
|
|
|
|
|
allow => 'Invalid Scanner ID', |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
fields => { |
26
|
|
|
|
|
|
|
filter => \&sc_filter_array_to_string, |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
32
|
|
|
|
|
|
|
# METHODS |
33
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub list { |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
1
|
3
|
my ( $self, %args ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $tmpl = { |
40
|
1
|
|
|
|
|
5
|
fields => $common_template->{'fields'}, |
41
|
|
|
|
|
|
|
raw => {} |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
5
|
my $params = sc_check_params( $tmpl, \%args ); |
45
|
1
|
|
|
|
|
3
|
my $raw = delete( $params->{'raw'} ); |
46
|
1
|
|
|
|
|
8
|
my $scanners = $self->client->get( '/scanner', $params ); |
47
|
|
|
|
|
|
|
|
48
|
1
|
50
|
|
|
|
4
|
return if ( !$scanners ); |
49
|
|
|
|
|
|
|
|
50
|
1
|
50
|
|
|
|
4
|
if ($raw) { |
51
|
0
|
0
|
|
|
|
0
|
return wantarray ? @{$scanners} : $scanners; |
|
0
|
|
|
|
|
0
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
50
|
|
|
|
7
|
return wantarray ? @{ sc_normalize_array($scanners) } : sc_normalize_array($scanners); |
|
0
|
|
|
|
|
0
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub get { |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
2
|
1
|
7
|
my ( $self, %args ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $tmpl = { |
65
|
|
|
|
|
|
|
fields => $common_template->{'fields'}, |
66
|
2
|
|
|
|
|
7
|
id => $common_template->{'id'}, |
67
|
|
|
|
|
|
|
raw => {}, |
68
|
|
|
|
|
|
|
}; |
69
|
|
|
|
|
|
|
|
70
|
2
|
|
|
|
|
7
|
my $params = sc_check_params( $tmpl, \%args ); |
71
|
2
|
|
|
|
|
4
|
my $scanner_id = delete( $params->{'id'} ); |
72
|
2
|
|
|
|
|
5
|
my $raw = delete( $params->{'raw'} ); |
73
|
2
|
|
|
|
|
7
|
my $scanner = $self->client->get( "/scanner/$scanner_id", $params ); |
74
|
|
|
|
|
|
|
|
75
|
2
|
50
|
|
|
|
7
|
return if ( !$scanner ); |
76
|
2
|
50
|
|
|
|
6
|
return $scanner if ($raw); |
77
|
2
|
|
|
|
|
8
|
return sc_normalize_hash($scanner); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub status { |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
1
|
1
|
4
|
my ( $self, %args ) = @_; |
86
|
|
|
|
|
|
|
|
87
|
1
|
|
|
|
|
4
|
my $tmpl = { id => $common_template->{'id'}, }; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
5
|
my $params = sc_check_params( $tmpl, \%args ); |
90
|
1
|
|
|
|
|
3
|
my $scanner_id = delete( $params->{'id'} ); |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
6
|
my $scanner = $self->get( id => $scanner_id, fields => [ 'id', 'status' ] ); |
93
|
|
|
|
|
|
|
|
94
|
1
|
50
|
|
|
|
6
|
return if ( !$scanner ); |
95
|
1
|
|
|
|
|
5
|
return sc_decode_scanner_status( $scanner->{'status'} ); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub health { |
102
|
|
|
|
|
|
|
|
103
|
1
|
|
|
1
|
1
|
4
|
my ( $self, %args ) = @_; |
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
5
|
my $tmpl = { id => $common_template->{'id'}, count => {} }; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
5
|
my $params = sc_check_params( $tmpl, \%args ); |
108
|
1
|
|
|
|
|
4
|
my $scanner_id = delete( $params->{'id'} ); |
109
|
|
|
|
|
|
|
|
110
|
1
|
|
|
|
|
4
|
my $scanner = $self->client->get("/scanner/$scanner_id/health"); |
111
|
|
|
|
|
|
|
|
112
|
1
|
50
|
|
|
|
4
|
return if ( !$scanner ); |
113
|
1
|
|
|
|
|
8
|
return $scanner; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub bug_report { |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
0
|
0
|
|
my ( $self, %args ) = @_; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
my $tmpl = { id => $common_template->{'id'}, scrub_mode => {}, full_mode => {} }; |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
my $params = sc_check_params( $tmpl, \%args ); |
126
|
0
|
|
|
|
|
|
my $scanner_id = delete( $params->{'id'} ); |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $scanner = $self->client->get( "/scanner/$scanner_id/bug_report", $params ); |
129
|
|
|
|
|
|
|
|
130
|
0
|
0
|
|
|
|
|
return if ( !$scanner ); |
131
|
0
|
|
|
|
|
|
return $scanner; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
__END__ |