Skip to content

Commit

Permalink
fix: Update to support Windows Defender AV inventory on Windows Server
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Feb 17, 2025
1 parent 160e975 commit c796621
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/GLPI/Agent/Task/Inventory/Win32/AntiVirus.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ sub doInventory {

# Also support WMI access to Windows Defender
if (!$antivirus->{VERSION} && $antivirus->{NAME} =~ /Windows Defender/i) {
&_setWinDefenderInfos($antivirus, $logger, "");
&_setWinDefenderInfos($antivirus);
$found_enabled++ if $antivirus->{ENABLED};
}

Expand Down Expand Up @@ -133,7 +133,6 @@ sub doInventory {
# Windows Defender support, path key is not set as it depends on installed version string
name => "Windows Defender",
service => "WinDefend",
command => "MsMpEng.exe",
func => \&_setWinDefenderInfos,
}, {
# Cortex XDR support
Expand Down Expand Up @@ -174,6 +173,8 @@ sub doInventory {
my ($path) = $service->{PATHNAME} =~ /^"/ ?
$service->{PATHNAME} =~ /^"([^"]+)\"/ :
$service->{PATHNAME} =~ /^(\S+)/ ;
# Remove filename part
($path) = $path =~ /^(.*)[\\][^\\]+$/ if !has_folder($path) && $path =~ /\\[^\\]+$/;
push @path, $path if $path;
}
push @path, ref($support->{path}) ? @{$support->{path}} : $support->{path}
Expand All @@ -187,6 +188,8 @@ sub doInventory {
&{$support->{func}}($antivirus, $logger, $cmd);
last;
}
} elsif ($support->{func}) {
&{$support->{func}}($antivirus);
}

# avoid duplicates
Expand Down Expand Up @@ -228,7 +231,7 @@ sub _getAntivirusUninstall {
}

sub _setWinDefenderInfos {
my ($antivirus, $logger, $command) = @_;
my ($antivirus) = @_;

my $defender;
# Don't try to access Windows Defender class if not enabled as
Expand All @@ -250,11 +253,6 @@ sub _setWinDefenderInfos {
$antivirus->{BASE_VERSION} = $defender->{AntivirusSignatureVersion}
if $defender->{AntivirusSignatureVersion};
}
unless ($antivirus->{VERSION} || empty($command)) {
my ($version) = $command =~ m{/([0-9.]+)[-/]};
$antivirus->{VERSION} = $version
unless empty($version);
}
$antivirus->{COMPANY} = "Microsoft Corporation";
# Finally try registry for base version
if (!$antivirus->{BASE_VERSION}) {
Expand Down

0 comments on commit c796621

Please sign in to comment.