Skip to content

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 7 commits into from
Jun 23, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions lib/GLPI/Agent/Task/Inventory/Linux/AntiVirus/DrWeb.pm
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,
};

my $version_output = getFirstLine(
command => 'LANG=C drweb-ctl --version',
%params
);

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
);
$av->{ENABLED} = $service_status && $service_status eq 'active' ? 1 : 0;

my @baseinfo = getAllLines(
command => 'LANG=C drweb-ctl baseinfo',
%params
);

foreach my $line (@baseinfo) {
if ($line =~ /Virus database timestamp:\s+(.+)/) {
$av->{BASE_VERSION} = $1;
last;
}
}

return $av;
}

1;
77 changes: 77 additions & 0 deletions lib/GLPI/Agent/Task/Inventory/Linux/AntiVirus/KESL.pm
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};

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
);
$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
);

foreach my $line (@app_info) {

if (!$av->{VERSION} && $line =~ /Version:\s+([\d.]+)/) {
$av->{VERSION} = $1;
next;
}

if (!$av->{EXPIRATION} && $line =~ /license expiration date:\s+([\d-]+\s[\d:]+)/i) {
$av->{EXPIRATION} = $1;
next;
}

if (!$av->{BASE_VERSION} && $line =~ /Last release date of databases:\s+([\d-]+\s[\d:]+)/) {
$av->{BASE_VERSION} = $1;
next;
}
}

return $av;
}

1;