Skip to content

Commit c796621

Browse files
committed
fix: Update to support Windows Defender AV inventory on Windows Server
1 parent 160e975 commit c796621

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/GLPI/Agent/Task/Inventory/Win32/AntiVirus.pm

+6-8
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ sub doInventory {
6868

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

@@ -133,7 +133,6 @@ sub doInventory {
133133
# Windows Defender support, path key is not set as it depends on installed version string
134134
name => "Windows Defender",
135135
service => "WinDefend",
136-
command => "MsMpEng.exe",
137136
func => \&_setWinDefenderInfos,
138137
}, {
139138
# Cortex XDR support
@@ -174,6 +173,8 @@ sub doInventory {
174173
my ($path) = $service->{PATHNAME} =~ /^"/ ?
175174
$service->{PATHNAME} =~ /^"([^"]+)\"/ :
176175
$service->{PATHNAME} =~ /^(\S+)/ ;
176+
# Remove filename part
177+
($path) = $path =~ /^(.*)[\\][^\\]+$/ if !has_folder($path) && $path =~ /\\[^\\]+$/;
177178
push @path, $path if $path;
178179
}
179180
push @path, ref($support->{path}) ? @{$support->{path}} : $support->{path}
@@ -187,6 +188,8 @@ sub doInventory {
187188
&{$support->{func}}($antivirus, $logger, $cmd);
188189
last;
189190
}
191+
} elsif ($support->{func}) {
192+
&{$support->{func}}($antivirus);
190193
}
191194

192195
# avoid duplicates
@@ -228,7 +231,7 @@ sub _getAntivirusUninstall {
228231
}
229232

230233
sub _setWinDefenderInfos {
231-
my ($antivirus, $logger, $command) = @_;
234+
my ($antivirus) = @_;
232235

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

0 commit comments

Comments
 (0)