Skip to content

Commit

Permalink
Add SentinelOne for Linux support (#531)
Browse files Browse the repository at this point in the history
Co-authored-by: Guillaume Bougard <[email protected]>
  • Loading branch information
MarcSamD and g-bougard authored Nov 20, 2023
1 parent 3c563ae commit 911e454
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions lib/GLPI/Agent/Task/Inventory/Linux/AntiVirus/Sentinelone.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package GLPI::Agent::Task::Inventory::Linux::AntiVirus::Sentinelone;

use strict;
use warnings;

use parent 'GLPI::Agent::Task::Inventory::Module';

use UNIVERSAL::require;

use GLPI::Agent::Tools;

sub isEnabled {
return canRun('/opt/sentinelone/bin/sentinelctl');
}

sub doInventory {
my (%params) = @_;

my $inventory = $params{inventory};
my $logger = $params{logger};

my $antivirus = _getSentineloneInfo(logger => $logger);
if ($antivirus) {
$inventory->addEntry(
section => 'ANTIVIRUS',
entry => $antivirus
);

$logger->debug2("Added $antivirus->{NAME}" . ($antivirus->{VERSION} ? " v$antivirus->{VERSION}" : ""))
if $logger;
}
}

sub _getSentineloneInfo {
my (%params) = @_;

my $cmd = '/opt/sentinelone/bin/sentinelctl';

my @output = getAllLines(
command => "$cmd version && $cmd engines status && $cmd control status && $cmd management status",
%params
)
or return;

my $av = {
NAME => 'SentinelAgent',
COMPANY => 'SentinelOne',
ENABLED => 0,
UPTODATE => 0,
};

foreach my $line (@output) {
my ($key, $value) = $line =~ /(.+)(?:: |(?<!\s)\s{2,})(.*)/
or next;
if ($key eq "Agent version") {
$av->{VERSION} = $value;
} elsif ($key eq "DFI library version") {
$av->{BASE_VERSION} = $value;
} elsif ($key eq "Agent state") {
$av->{ENABLED} = $value eq "Enabled" ? 1 : 0;
} elsif ($key eq "Connectivity") {
# SentinelAgent does not directly report "uptodate" status but we can assume it is updated if the cloud connectivity is working.
$av->{UPTODATE} = $value eq "On" ? 1 : 0;
}
}

return $av;
}

1;

0 comments on commit 911e454

Please sign in to comment.