line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SecurityCenter::API::Report; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
777
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
4
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
43
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
10
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
88
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
10
|
use parent 'Net::SecurityCenter::Base'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
16
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
118
|
use Net::SecurityCenter::Utils qw(:all); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1146
|
|
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 => '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
|
|
|
|
|
5
|
filter => $common_template->{'filter'}, |
46
|
|
|
|
|
|
|
raw => {}, |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
4
|
my $params = sc_check_params( $tmpl, \%args ); |
50
|
1
|
|
|
|
|
3
|
my $raw = delete( $params->{'raw'} ); |
51
|
1
|
|
|
|
|
8
|
my $reports = $self->client->get( '/report', $params ); |
52
|
|
|
|
|
|
|
|
53
|
1
|
50
|
|
|
|
3
|
return if ( !$reports ); |
54
|
|
|
|
|
|
|
|
55
|
1
|
50
|
|
|
|
3
|
if ($raw) { |
56
|
0
|
0
|
|
|
|
0
|
return wantarray ? @{$reports} : $reports; |
|
0
|
|
|
|
|
0
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
50
|
|
|
|
6
|
return wantarray ? @{ sc_merge($reports) } : sc_merge($reports); |
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get { |
66
|
|
|
|
|
|
|
|
67
|
1
|
|
|
1
|
1
|
4
|
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
|
|
|
|
|
4
|
my $params = sc_check_params( $tmpl, \%args ); |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
2
|
my $report_id = delete( $params->{'id'} ); |
78
|
1
|
|
|
|
|
2
|
my $raw = delete( $params->{'raw'} ); |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
4
|
my $report = $self->client->get( "/report/$report_id", $params ); |
81
|
|
|
|
|
|
|
|
82
|
1
|
50
|
|
|
|
4
|
return if ( !$report ); |
83
|
1
|
50
|
|
|
|
14
|
return $report if ($raw); |
84
|
1
|
|
|
|
|
4
|
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__ |