line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Armadito::Agent::HTTP::Client::ArmaditoAV::Event::OnDemandCompletedEvent; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
19709187
|
use strict; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
113
|
|
4
|
4
|
|
|
4
|
|
15
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
131
|
|
5
|
4
|
|
|
4
|
|
13
|
use base 'Armadito::Agent::HTTP::Client::ArmaditoAV::Event'; |
|
4
|
|
|
|
|
31
|
|
|
4
|
|
|
|
|
681
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
22
|
use JSON; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
43
|
|
8
|
4
|
|
|
4
|
|
2023
|
use Armadito::Agent::Tools::Security qw(isANumber); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1250
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
0
|
|
|
0
|
1
|
|
my ( $class, %params ) = @_; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(%params); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# TODO: Add more validation |
16
|
0
|
0
|
|
|
|
|
die "Invalid total_malware_count." if !isANumber( $self->{jobj}->{total_malware_count} ); |
17
|
0
|
0
|
|
|
|
|
die "Invalid total_suspicious_count." if !isANumber( $self->{jobj}->{total_suspicious_count} ); |
18
|
0
|
0
|
|
|
|
|
die "Invalid total_scanned_count." if !isANumber( $self->{jobj}->{total_scanned_count} ); |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
$self->{jobj}->{malware_count} = $self->{jobj}->{total_malware_count}; |
21
|
0
|
|
|
|
|
|
$self->{jobj}->{suspicious_count} = $self->{jobj}->{total_suspicious_count}; |
22
|
0
|
|
|
|
|
|
$self->{jobj}->{scanned_count} = $self->{jobj}->{total_scanned_count}; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
delete $self->{jobj}->{total_malware_count}; |
25
|
0
|
|
|
|
|
|
delete $self->{jobj}->{total_suspicious_count}; |
26
|
0
|
|
|
|
|
|
delete $self->{jobj}->{total_scanned_count}; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$self->{jobj}->{progress} = 100; |
29
|
0
|
|
|
|
|
|
$self->{jobj}->{job_id} = $self->{taskobj}->{job}->{job_id}; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
return $self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub run { |
35
|
0
|
|
|
0
|
1
|
|
my ( $self, %params ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
$self->{taskobj}->{jobj}->{task}->{obj} = $self->{jobj}; |
38
|
0
|
|
|
|
|
|
my $json_text = to_json( $self->{taskobj}->{jobj} ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $response = $self->{taskobj}->{glpi_client}->sendRequest( |
41
|
0
|
|
|
|
|
|
"url" => $self->{taskobj}->{agent}->{config}->{server}[0] . "/api/scans", |
42
|
|
|
|
|
|
|
message => $json_text, |
43
|
|
|
|
|
|
|
method => "POST" |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
|
|
|
if ( $response->is_success() ) { |
47
|
0
|
|
|
|
|
|
$self->{taskobj}->{logger}->info("Send Scan results successful..."); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
else { |
50
|
0
|
|
|
|
|
|
$self->{taskobj}->_handleError($response); |
51
|
0
|
|
|
|
|
|
$self->{taskobj}->{logger}->info("Send Scan results failed..."); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->{end_polling} = 1; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Armadito::Agent::HTTP::Client::ArmaditoAV::Event::OnDemandCompletedEvent - ArmaditoAV OnDemandCompletedEvent class |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
This is the class dedicated to OnDemandCompletedEvent of ArmaditoAV api. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 FUNCTIONS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 run ( $self, %params ) |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Run event related stuff. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 new ( $class, %params ) |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Instanciate this class. |
79
|
|
|
|
|
|
|
|