line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SecurityCenter::API::Report; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
939
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
70
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
39
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
25
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
120
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
15
|
use parent 'Net::SecurityCenter::Base'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
30
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
153
|
use Net::SecurityCenter::Utils qw(:all); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1461
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.300'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $common_template = { |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
id => { |
17
|
|
|
|
|
|
|
required => 1, |
18
|
|
|
|
|
|
|
allow => qr/^\d+$/, |
19
|
|
|
|
|
|
|
messages => { |
20
|
|
|
|
|
|
|
required => 'Report ID is required', |
21
|
|
|
|
|
|
|
allow => 'Invalid Report ID', |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
filter => { |
26
|
|
|
|
|
|
|
allow => [ 'running', 'completed', 'usable', 'manageable' ], |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
fields => { |
30
|
|
|
|
|
|
|
filter => \&sc_filter_array_to_string, |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
36
|
|
|
|
|
|
|
# METHODS |
37
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub list { |
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
1
|
1
|
3
|
my ( $self, %args ) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $tmpl = { |
44
|
|
|
|
|
|
|
fields => $common_template->{'fields'}, |
45
|
1
|
|
|
|
|
7
|
filter => $common_template->{'filter'}, |
46
|
|
|
|
|
|
|
raw => {}, |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
4
|
my $params = sc_check_params( $tmpl, \%args ); |
50
|
1
|
|
|
|
|
4
|
my $raw = delete( $params->{'raw'} ); |
51
|
1
|
|
|
|
|
13
|
my $reports = $self->client->get( '/report', $params ); |
52
|
|
|
|
|
|
|
|
53
|
1
|
50
|
|
|
|
6
|
return if ( !$reports ); |
54
|
|
|
|
|
|
|
|
55
|
1
|
50
|
|
|
|
4
|
if ($raw) { |
56
|
0
|
0
|
|
|
|
0
|
return wantarray ? @{$reports} : $reports; |
|
0
|
|
|
|
|
0
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
50
|
|
|
|
8
|
return wantarray ? @{ sc_merge($reports) } : sc_merge($reports); |
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get { |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
1
|
1
|
5
|
my ( $self, %args ) = @_; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $tmpl = { |
70
|
|
|
|
|
|
|
fields => $common_template->{'fields'}, |
71
|
1
|
|
|
|
|
6
|
id => $common_template->{'id'}, |
72
|
|
|
|
|
|
|
raw => {}, |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
5
|
my $params = sc_check_params( $tmpl, \%args ); |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
94
|
my $report_id = delete( $params->{'id'} ); |
78
|
1
|
|
|
|
|
7
|
my $raw = delete( $params->{'raw'} ); |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
6
|
my $report = $self->client->get( "/report/$report_id", $params ); |
81
|
|
|
|
|
|
|
|
82
|
1
|
50
|
|
|
|
6
|
return if ( !$report ); |
83
|
1
|
50
|
|
|
|
16
|
return $report if ($raw); |
84
|
1
|
|
|
|
|
5
|
return sc_normalize_hash($report); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub download { |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
my $tmpl = { |
95
|
|
|
|
|
|
|
filename => {}, |
96
|
0
|
|
|
|
|
|
id => $common_template->{'id'}, |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
my $params = sc_check_params( $tmpl, \%args ); |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my $report_id = delete( $params->{'id'} ); |
102
|
0
|
|
|
|
|
|
my $filename = delete( $params->{'filename'} ); |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my $report_data = $self->client->post("/report/$report_id/download"); |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
return $report_data if ( !$filename ); |
107
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
open my $fh, '>', $filename |
109
|
|
|
|
|
|
|
or croak("Could not open file '$filename': $!"); |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
print $fh $report_data; |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
close $fh |
114
|
|
|
|
|
|
|
or carp("Failed to close file '$filename': $!"); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return 1; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |