line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Armadito::Agent::Antivirus::Kaspersky::Task::AVConfig; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
18362976
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
62
|
|
5
|
1
|
|
|
1
|
|
7
|
use base 'Armadito::Agent::Task::AVConfig'; |
|
1
|
|
|
|
|
28
|
|
|
1
|
|
|
|
|
445
|
|
6
|
1
|
|
|
1
|
|
5
|
use IPC::System::Simple qw(capture $EXITVAL EXIT_ANY); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
77
|
|
7
|
1
|
|
|
1
|
|
5
|
use Armadito::Agent::Tools::File qw(rmFile); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
8
|
1
|
|
|
1
|
|
8
|
use Armadito::Agent::Tools qw(getOSTempDir); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
9
|
1
|
|
|
1
|
|
216
|
use XML::LibXML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Data::Dumper; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub run { |
13
|
|
|
|
|
|
|
my ( $self, %params ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$self = $self->SUPER::run(%params); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $export_path = getOSTempDir() . "exported_settings.xml"; |
18
|
|
|
|
|
|
|
rmFile( filepath => $export_path ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if ( $self->_exportSettings($export_path) == 0 ) { |
21
|
|
|
|
|
|
|
$self->_parseSettings($export_path); |
22
|
|
|
|
|
|
|
$self->_sendToGLPI(); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _exportSettings { |
27
|
|
|
|
|
|
|
my ( $self, $export_path ) = @_; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $bin_path = $self->{agent}->{antivirus}->{scancli_path}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $cmdline = "\"" . $bin_path . "\" EXPORT \"" . $export_path . "\""; |
32
|
|
|
|
|
|
|
my $output = capture( EXIT_ANY, $cmdline ); |
33
|
|
|
|
|
|
|
$self->{logger}->info($output); |
34
|
|
|
|
|
|
|
$self->{logger}->info( "Program exited with " . $EXITVAL . "\n" ); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return $EXITVAL; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _parseSettings { |
40
|
|
|
|
|
|
|
my ( $self, $export_path ) = @_; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $parser = XML::LibXML->new(); |
43
|
|
|
|
|
|
|
my $doc = $parser->parse_file($export_path); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my ($ondemand_settings) = $doc->findnodes('/root/ekaSettings/on_demand_tasks'); |
46
|
|
|
|
|
|
|
my ($monitoring_settings) = $doc->findnodes('/root/ekaSettings/monitoring_tasks'); |
47
|
|
|
|
|
|
|
my ($services_settings) = $doc->findnodes('/root/ekaSettings/services'); |
48
|
|
|
|
|
|
|
my ($persistent_data_settings) = $doc->findnodes('/root/persistentData'); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$self->_parseItemNode( $ondemand_settings, "On_demand" ); |
51
|
|
|
|
|
|
|
$self->_parseItemNode( $monitoring_settings, "Monitoring" ); |
52
|
|
|
|
|
|
|
$self->_parseItemNode( $services_settings, "Services" ); |
53
|
|
|
|
|
|
|
$self->_parseItemNode( $persistent_data_settings, "PersistentData" ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _parseItemNode { |
57
|
|
|
|
|
|
|
my ( $self, $node, $path ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
foreach ( $node->findnodes('./item') ) { |
60
|
|
|
|
|
|
|
$self->_parseSubNode( $_, $path . ":" . $_->getAttribute('name') ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _parseSubNode { |
65
|
|
|
|
|
|
|
my ( $self, $node, $path ) = @_; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
foreach ( $node->findnodes('./*') ) { |
68
|
|
|
|
|
|
|
my $nodeName = $_->nodeName; |
69
|
|
|
|
|
|
|
my @attributes = $_->attributes; |
70
|
|
|
|
|
|
|
foreach my $attr (@attributes) { |
71
|
|
|
|
|
|
|
$self->_addConfEntry( $path . ":" . $nodeName . ":" . $attr->nodeName, $attr->value ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$self->_parseSubNode( $_, $path . ":" . $nodeName ); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Armadito::Agent::Antivirus::Kaspersky::Task::AVConfig - AVConfig Task for Kaspersky Antivirus. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 DESCRIPTION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This task inherits from L<Armadito::Agent::Task:AVConfig>. Get Antivirus configuration and then send it in a json formatted POST request to Armadito plugin for GLPI. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 FUNCTIONS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 run ( $self, %params ) |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Run the task. |