line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SecurityCenter::API::Ticket; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
765
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
55
|
|
4
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
41
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
8
|
use Carp; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
98
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
10
|
use parent 'Net::SecurityCenter::Base'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
8
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
125
|
use Net::SecurityCenter::Utils qw(:all); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1357
|
|
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 => 'Ticket ID is required', |
21
|
|
|
|
|
|
|
allow => 'Invalid Ticket ID', |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
fields => { |
26
|
|
|
|
|
|
|
filter => \&sc_filter_array_to_string, |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
assignee => { |
30
|
|
|
|
|
|
|
allow => qr/\d+/, |
31
|
|
|
|
|
|
|
errors => { allow => 'Invalid Asignee ID' }, |
32
|
|
|
|
|
|
|
filter => sub { |
33
|
|
|
|
|
|
|
return { 'id' => $_[0] }; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
status => { |
38
|
|
|
|
|
|
|
allow => [ 'assigned', 'resolved', 'feedback', 'na', 'duplicate', 'closed' ] |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
classification => { |
42
|
|
|
|
|
|
|
allow => [ |
43
|
|
|
|
|
|
|
'Information', |
44
|
|
|
|
|
|
|
'Configuration', |
45
|
|
|
|
|
|
|
'Patch', |
46
|
|
|
|
|
|
|
'Disable', |
47
|
|
|
|
|
|
|
'Firewall', |
48
|
|
|
|
|
|
|
'Schedule', |
49
|
|
|
|
|
|
|
'IDS', |
50
|
|
|
|
|
|
|
'Other', |
51
|
|
|
|
|
|
|
'Accept Risk', |
52
|
|
|
|
|
|
|
'Recast Risk', |
53
|
|
|
|
|
|
|
'Re-scan Request', |
54
|
|
|
|
|
|
|
'False Positive', |
55
|
|
|
|
|
|
|
'System Probe', |
56
|
|
|
|
|
|
|
'External Probe', |
57
|
|
|
|
|
|
|
'Investigation Needed', |
58
|
|
|
|
|
|
|
'Compromised System', |
59
|
|
|
|
|
|
|
'Virus Incident', |
60
|
|
|
|
|
|
|
'Bad Credentials', |
61
|
|
|
|
|
|
|
'Unauthorized Software', |
62
|
|
|
|
|
|
|
'Unauthorized System', |
63
|
|
|
|
|
|
|
'Unauthorized User' |
64
|
|
|
|
|
|
|
] |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
70
|
|
|
|
|
|
|
# METHODS |
71
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub list { |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
1
|
1
|
3
|
my ( $self, %args ) = @_; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $tmpl = { |
78
|
1
|
|
|
|
|
4
|
fields => $common_template->{'fields'}, |
79
|
|
|
|
|
|
|
raw => {}, |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
1
|
|
|
|
|
4
|
my $params = sc_check_params( $tmpl, \%args ); |
83
|
1
|
|
|
|
|
2
|
my $raw = delete( $params->{'raw'} ); |
84
|
1
|
|
|
|
|
10
|
my $tickets = $self->client->get( '/ticket', $params ); |
85
|
|
|
|
|
|
|
|
86
|
1
|
50
|
|
|
|
5
|
return if ( !$tickets ); |
87
|
|
|
|
|
|
|
|
88
|
1
|
50
|
|
|
|
3
|
if ($raw) { |
89
|
0
|
0
|
|
|
|
0
|
return wantarray ? @{$tickets} : $tickets; |
|
0
|
|
|
|
|
0
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
1
|
50
|
|
|
|
6
|
return wantarray ? @{ sc_merge($tickets) } : sc_merge($tickets); |
|
0
|
|
|
|
|
0
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub get { |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
1
|
1
|
4
|
my ( $self, %args ) = @_; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $tmpl = { |
103
|
|
|
|
|
|
|
fields => $common_template->{'fields'}, |
104
|
1
|
|
|
|
|
5
|
id => $common_template->{'id'}, |
105
|
|
|
|
|
|
|
raw => {}, |
106
|
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
|
108
|
1
|
|
|
|
|
5
|
my $params = sc_check_params( $tmpl, \%args ); |
109
|
1
|
|
|
|
|
2
|
my $raw = delete( $params->{'raw'} ); |
110
|
1
|
|
|
|
|
3
|
my $ticket_id = delete( $params->{'id'} ); |
111
|
1
|
|
|
|
|
3
|
my $ticket = $self->client->get( "/ticket/$ticket_id", $params ); |
112
|
|
|
|
|
|
|
|
113
|
1
|
50
|
|
|
|
4
|
return if ( !$ticket ); |
114
|
1
|
50
|
|
|
|
4
|
return $ticket if ($raw); |
115
|
1
|
|
|
|
|
4
|
return sc_normalize_hash($ticket); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub add { |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my $tmpl = { |
126
|
|
|
|
|
|
|
name => { |
127
|
|
|
|
|
|
|
required => 1, |
128
|
|
|
|
|
|
|
errors => { required => 'Specify ticket name' } |
129
|
|
|
|
|
|
|
}, |
130
|
|
|
|
|
|
|
assignee => $common_template->{'asignee'}, |
131
|
|
|
|
|
|
|
status => $common_template->{'status'}, |
132
|
0
|
|
|
|
|
|
classification => $common_template->{'classification'}, |
133
|
|
|
|
|
|
|
description => {}, |
134
|
|
|
|
|
|
|
notes => {}, |
135
|
|
|
|
|
|
|
queries => {}, |
136
|
|
|
|
|
|
|
query => {} |
137
|
|
|
|
|
|
|
}; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
my $params = sc_check_params( $tmpl, \%args ); |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
my $result = $self->client->post( '/ticket', $params ); |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
return $result->{id}; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub edit { |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
0
|
1
|
|
my ( $self, %args ) = @_; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my $tmpl = { |
154
|
|
|
|
|
|
|
id => $common_template->{'id'}, |
155
|
|
|
|
|
|
|
name => {}, |
156
|
|
|
|
|
|
|
assignee => $common_template->{'asignee'}, |
157
|
|
|
|
|
|
|
status => $common_template->{'status'}, |
158
|
0
|
|
|
|
|
|
classification => $common_template->{'classification'}, |
159
|
|
|
|
|
|
|
description => {}, |
160
|
|
|
|
|
|
|
notes => {}, |
161
|
|
|
|
|
|
|
queries => {}, |
162
|
|
|
|
|
|
|
query => {}, |
163
|
|
|
|
|
|
|
raw => {} |
164
|
|
|
|
|
|
|
}; |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
my $params = sc_check_params( $tmpl, \%args ); |
167
|
0
|
|
|
|
|
|
my $ticket_id = delete( $params->{'id'} ); |
168
|
0
|
|
|
|
|
|
my $raw = delete( $params->{'raw'} ); |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
my $ticket = $self->client->patch( "/ticket/$ticket_id", $params ); |
171
|
|
|
|
|
|
|
|
172
|
0
|
0
|
|
|
|
|
return $ticket if ($raw); |
173
|
0
|
|
|
|
|
|
return sc_normalize_hash($ticket); |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
__END__ |