@@ -68,7 +68,7 @@ sub doInventory {
68
68
69
69
# Also support WMI access to Windows Defender
70
70
if (!$antivirus -> {VERSION } && $antivirus -> {NAME } =~ / Windows Defender/i ) {
71
- &_setWinDefenderInfos($antivirus , $logger , " " );
71
+ &_setWinDefenderInfos($antivirus );
72
72
$found_enabled ++ if $antivirus -> {ENABLED };
73
73
}
74
74
@@ -133,7 +133,6 @@ sub doInventory {
133
133
# Windows Defender support, path key is not set as it depends on installed version string
134
134
name => " Windows Defender" ,
135
135
service => " WinDefend" ,
136
- command => " MsMpEng.exe" ,
137
136
func => \&_setWinDefenderInfos,
138
137
}, {
139
138
# Cortex XDR support
@@ -174,6 +173,8 @@ sub doInventory {
174
173
my ($path ) = $service -> {PATHNAME } =~ / ^"/ ?
175
174
$service -> {PATHNAME } =~ / ^"([^"]+)\" / :
176
175
$service -> {PATHNAME } =~ / ^(\S +)/ ;
176
+ # Remove filename part
177
+ ($path ) = $path =~ / ^(.*)[\\ ][^\\ ]+$ / if !has_folder($path ) && $path =~ / \\ [^\\ ]+$ / ;
177
178
push @path , $path if $path ;
178
179
}
179
180
push @path , ref ($support -> {path }) ? @{$support -> {path }} : $support -> {path }
@@ -187,6 +188,8 @@ sub doInventory {
187
188
&{$support -> {func }}($antivirus , $logger , $cmd );
188
189
last ;
189
190
}
191
+ } elsif ($support -> {func }) {
192
+ &{$support -> {func }}($antivirus );
190
193
}
191
194
192
195
# avoid duplicates
@@ -228,7 +231,7 @@ sub _getAntivirusUninstall {
228
231
}
229
232
230
233
sub _setWinDefenderInfos {
231
- my ($antivirus , $logger , $command ) = @_ ;
234
+ my ($antivirus ) = @_ ;
232
235
233
236
my $defender ;
234
237
# Don't try to access Windows Defender class if not enabled as
@@ -250,11 +253,6 @@ sub _setWinDefenderInfos {
250
253
$antivirus -> {BASE_VERSION } = $defender -> {AntivirusSignatureVersion }
251
254
if $defender -> {AntivirusSignatureVersion };
252
255
}
253
- unless ($antivirus -> {VERSION } || empty($command )) {
254
- my ($version ) = $command =~ m { /([0-9.]+)[-/]} ;
255
- $antivirus -> {VERSION } = $version
256
- unless empty($version );
257
- }
258
256
$antivirus -> {COMPANY } = " Microsoft Corporation" ;
259
257
# Finally try registry for base version
260
258
if (!$antivirus -> {BASE_VERSION }) {
0 commit comments