-
Notifications
You must be signed in to change notification settings - Fork 77
Added modules for antivirus programs Dr.Web and KESL #931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ed761fc
Added modules for antivirus programs Dr.Web and Kaspersky Endpoint Se…
AnilAntari 3d46ea3
Updating modules DrWeb.pm and KESL.pm
AnilAntari 7b3d50f
Updating modules DrWeb.pm and KESL.pm
AnilAntari 5b65713
Correction for the module DrWeb.pm
AnilAntari d498218
Update DrWeb.pm
AnilAntari 2fb35df
Update DrWeb.pm
AnilAntari 7fd44e2
Update KESL.pm
AnilAntari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package GLPI::Agent::Task::Inventory::Linux::AntiVirus::DrWeb; | ||
|
||
use strict; | ||
use warnings; | ||
use parent 'GLPI::Agent::Task::Inventory::Module'; | ||
|
||
use GLPI::Agent::Tools; | ||
|
||
sub isEnabled { | ||
return canRun('drweb-ctl'); | ||
} | ||
|
||
sub doInventory { | ||
my (%params) = @_; | ||
|
||
my $inventory = $params{inventory}; | ||
my $logger = $params{logger}; | ||
|
||
my $antivirus = _getDrWebInfo(logger => $logger); | ||
if ($antivirus) { | ||
$inventory->addEntry( | ||
section => 'ANTIVIRUS', | ||
entry => $antivirus | ||
); | ||
|
||
$logger->debug2("Added $antivirus->{NAME}" . | ||
($antivirus->{VERSION} ? " v$antivirus->{VERSION}" : "") . | ||
($antivirus->{ENABLED} ? " [ENABLED]" : " [DISABLED]")) | ||
if $logger; | ||
} | ||
} | ||
|
||
sub _getDrWebInfo { | ||
my (%params) = @_; | ||
my $logger = $params{logger}; | ||
|
||
my $av = { | ||
NAME => 'Dr.Web', | ||
COMPANY => 'Doctor Web', | ||
ENABLED => 0, | ||
UPTODATE => 0, | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
my $version_output = getFirstLine( | ||
command => 'LANG=C drweb-ctl --version', | ||
%params | ||
); | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if ($version_output && $version_output =~ /drweb-ctl\s+([\d.]+)/) { | ||
$av->{VERSION} = $1; | ||
} | ||
|
||
my $service_status = getFirstLine( | ||
command => 'LANG=C systemctl is-active drweb-configd.service', | ||
%params | ||
); | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$av->{ENABLED} = $service_status && $service_status eq 'active' ? 1 : 0; | ||
|
||
my @baseinfo = getAllLines( | ||
command => 'LANG=C drweb-ctl baseinfo', | ||
%params | ||
); | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
foreach my $line (@baseinfo) { | ||
if ($line =~ /Virus database timestamp:\s+(.+)/) { | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$av->{BASE_VERSION} = $1; | ||
last; | ||
} | ||
} | ||
|
||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return $av; | ||
} | ||
|
||
1; | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package GLPI::Agent::Task::Inventory::Linux::AntiVirus::KESL; | ||
|
||
use strict; | ||
use warnings; | ||
use parent 'GLPI::Agent::Task::Inventory::Module'; | ||
|
||
use GLPI::Agent::Tools; | ||
|
||
sub isEnabled { | ||
return canRun('kesl-control'); | ||
} | ||
|
||
sub doInventory { | ||
my (%params) = @_; | ||
|
||
my $inventory = $params{inventory}; | ||
my $logger = $params{logger}; | ||
|
||
my $antivirus = _getKESLInfo(logger => $logger); | ||
if ($antivirus) { | ||
$inventory->addEntry( | ||
section => 'ANTIVIRUS', | ||
entry => $antivirus | ||
); | ||
|
||
$logger->debug2("Added $antivirus->{NAME}" . | ||
($antivirus->{VERSION} ? " v$antivirus->{VERSION}" : "") . | ||
($antivirus->{ENABLED} ? " [ENABLED]" : " [DISABLED]") . | ||
($antivirus->{EXPIRATION} ? " Expires: $antivirus->{EXPIRATION}" : "")) | ||
if $logger; | ||
} | ||
} | ||
|
||
sub _getKESLInfo { | ||
my (%params) = @_; | ||
my $logger = $params{logger}; | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
my $av = { | ||
NAME => 'Kaspersky Endpoint Security for Linux', | ||
COMPANY => 'Kaspersky Lab', | ||
ENABLED => 0, | ||
UPTODATE => 0, | ||
}; | ||
|
||
my $service_status = getFirstLine( | ||
command => 'LANG=en_US.UTF-8 systemctl is-active kesl.service', | ||
%params | ||
); | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$av->{ENABLED} = $service_status && $service_status eq 'active' ? 1 : 0; | ||
|
||
my @app_info = getAllLines( | ||
command => 'LANG=en_US.UTF-8 kesl-control --app-info', | ||
%params | ||
); | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
foreach my $line (@app_info) { | ||
|
||
if (!$av->{VERSION} && $line =~ /Version:\s+([\d.]+)/) { | ||
$av->{VERSION} = $1; | ||
next; | ||
} | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (!$av->{EXPIRATION} && $line =~ /license expiration date:\s+([\d-]+\s[\d:]+)/i) { | ||
$av->{EXPIRATION} = $1; | ||
next; | ||
} | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if (!$av->{BASE_VERSION} && $line =~ /Last release date of databases:\s+([\d-]+\s[\d:]+)/) { | ||
$av->{BASE_VERSION} = $1; | ||
next; | ||
} | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return $av; | ||
} | ||
|
||
1; | ||
g-bougard marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.