@@ -6,6 +6,8 @@ use warnings;
66use parent ' GLPI::Agent::Task::Inventory::Module' ;
77
88use UNIVERSAL::require ;
9+ use File::Spec;
10+ use File::Basename qw( dirname) ;
911
1012use GLPI::Agent::Tools;
1113use GLPI::Agent::Tools::Win32;
@@ -160,14 +162,26 @@ sub doInventory {
160162 # Cortex XDR support
161163 name => " Cortex XDR" ,
162164 service => " cyserver" ,
163- command => " C:\\ Program Files\\ Palo Alto Networks\\ Traps\\ cytool.exe" ,
165+ path => " C:\\ Program Files\\ Palo Alto Networks\\ Traps" ,
166+ command => " cytool.exe" ,
164167 func => \&_setCortexInfos,
165168 }, {
166169 # BitDefender support
167170 name => " Bitdefender Endpoint Security" ,
168171 service => " EPSecurityService" ,
169- command => " C:\\ Program Files\\ Bitdefender\\ Endpoint Security\\ product.console.exe" ,
172+ path => " C:\\ Program Files\\ Bitdefender\\ Endpoint Security" ,
173+ command => " product.console.exe" ,
170174 func => \&_setBitdefenderInfos,
175+ }, {
176+ # Trellix/McAfee support
177+ name => " Trellix" ,
178+ service => " masvc" ,
179+ path => [
180+ " C:\\ Program Files\\ McAfee\\ Agent" ,
181+ " C:\\ Program Files (x86)\\ McAfee\\ Commmon Framework" ,
182+ ],
183+ command => " CmdAgent.exe" ,
184+ func => \&_setMcAfeeInfos,
171185 }) {
172186 my $antivirus ;
173187 my $service = $services -> {$support -> {service }}
@@ -176,8 +190,26 @@ sub doInventory {
176190 $antivirus -> {NAME } = $support -> {name } || $service -> {NAME };
177191 $antivirus -> {ENABLED } = $service -> {STATUS } =~ / running/i ? 1 : 0;
178192
179- if (my $cmd = $support -> {command }) {
180- &{$support -> {func }}($antivirus , $logger , $cmd ) if canRun($cmd );
193+ if ($support -> {command }) {
194+ my @path ;
195+ if ($service -> {PATHNAME }) {
196+ # First use pathname extracted from service PATHNAME
197+ my ($path ) = $service -> {PATHNAME } =~ / ^"/ ?
198+ $service -> {PATHNAME } =~ / ^"([^"]+)\" / :
199+ $service -> {PATHNAME } =~ / ^(\S +)/ ;
200+ push @path , $path if $path ;
201+ }
202+ push @path , ref ($support -> {path }) ? @{$support -> {path }} : $support -> {path }
203+ if $support -> {path };
204+ my %tried ;
205+ foreach my $path (@path ) {
206+ next if $tried {$path };
207+ $tried {$path } = 1;
208+ my $cmd = File::Spec-> catfile($path , $support -> {command });
209+ next unless canRun($cmd );
210+ &{$support -> {func }}($antivirus , $logger , $cmd );
211+ last ;
212+ }
181213 }
182214
183215 # avoid duplicates
@@ -219,7 +251,17 @@ sub _getAntivirusUninstall {
219251}
220252
221253sub _setMcAfeeInfos {
222- my ($antivirus ) = @_ ;
254+ my ($antivirus , $logger , $command ) = @_ ;
255+
256+ if ($command ) {
257+ my $version = getFirstMatch(
258+ command => " \" $command \" /i" ,
259+ pattern => qr / ^Version: (.*)$ / ,
260+ logger => $logger
261+ );
262+ $antivirus -> {VERSION } = $version if $version ;
263+ $antivirus -> {COMPANY } = " Trellix" unless $antivirus -> {COMPANY };
264+ }
223265
224266 my %properties = (
225267 BASE_VERSION => [ qw( AVDatVersion AVDatVersionMinor) ],
0 commit comments