From 58581dfedb8b0562917e833b6eb5d4d3478d521b Mon Sep 17 00:00:00 2001 From: Eduardo Santos Date: Thu, 17 Apr 2014 12:23:56 -0300 Subject: [PATCH] Coleta de log dos dispositivos USB --- src/Cacic/WSBundle/Controller/ColetaController.php | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/Cacic/WSBundle/Controller/ColetaController.php b/src/Cacic/WSBundle/Controller/ColetaController.php index db2741d..4cf80a0 100644 --- a/src/Cacic/WSBundle/Controller/ColetaController.php +++ b/src/Cacic/WSBundle/Controller/ColetaController.php @@ -258,50 +258,55 @@ class ColetaController extends Controller public function gerColsSetUsbDetectAction(Request $request) { OldCacicHelper::autenticaAgente( $request ) ; - $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->getDadosRedePreColeta( $request ); $strNetworkAdapterConfiguration = OldCacicHelper::deCrypt( $request, $request->get('NetworkAdapterConfiguration') ); $data = new \DateTime('NOW'); + $netmask = TagValueHelper::getValueFromTags( 'IPSubnet', $strNetworkAdapterConfiguration ); + $ip_computador = $request->get('te_ip_computador'); + $rede = $this->getDoctrine()->getRepository('CacicCommonBundle:Rede')->getDadosRedePreColeta( $ip_computador, $netmask ); $te_node_adress = TagValueHelper::getValueFromTags( 'MACAddress', $strNetworkAdapterConfiguration ); $te_so = $request->get( 'te_so' ); $so = $this->getDoctrine()->getRepository('CacicCommonBundle:So')->findOneBy( array('teSo'=>$te_so) ); $computador = $this->getDoctrine()->getRepository('CacicCommonBundle:Computador')->findOneBy( array('idSo'=>$so, 'teNodeAddress'=>$te_node_adress) ); - $local = $this->getDoctrine()->getRepository('CacicCommonBundle:Local')->findOneBy(array( 'idLocal' => $rede->getIdLocal() )); + $local = $computador->getIdRede()->getIdLocal(); $te_usb_info = OldCacicHelper::deCrypt($request, $request->get('te_usb_info')); if ($te_usb_info <> '') { $arrUsbInfo = explode('_',$te_usb_info); - $usb_log = new UsbLog(); - $usb_log->setIdComputador($computador); - $usb_log->getCsEvent($arrUsbInfo[0]); - $usb_log->setDtEvent($arrUsbInfo[1]); - //$usb_log->setIdUsbVendor($arrUsbInfo[2]); - $usb_log->setIdUsbDevice($arrUsbInfo[3]); - $arrTeUsbFilter = $this->getDoctrine()->getRepository('CacicCommonBundle:ConfiguracaoLocal')->listarNotificacaoPropertyLocal( $local->getIdLocal() , 'te_usb_filter' ); $arrTeNotificarUtilizacaoUSB = $this->getDoctrine()->getRepository('CacicCommonBundle:ConfiguracaoLocal')->listarNotificacaoPropertyLocal( $rede->getIdLocal(), 'te_notificar_utilizacao_usb' ); - $arrDeviceData = $this->getDoctrine()->getRepository('CacicCommonBundle:UsbDevice')->findBy( array('idDevice'=>$arrUsbInfo[3], 'idVendor'=>$arrUsbInfo[2] )); - - if (trim($arrDeviceData[0]['nmDevice'])=='') - { - $usb_device = new UsbDevice(); - $usb_device->setIdUsbVendor($arrUsbInfo[2]); - $usb_device->setIdUsbDevice($arrUsbInfo[3]); - $usb_device->getNmUsbDevice('Dispositivo USB Desconhecido'); - } - $arrVendorData = $this->getDoctrine()->getRepository('CacicCommonBundle:UsbVendor ')->findBy( array('idVendor'=>$arrUsbInfo[2])); - if (trim($arrVendorData[0]['nmVendor'])=='') + if (empty($arrVendorData)) { $usb_vendor = new UsbVendor(); $usb_vendor->setIdUsbVendor($arrUsbInfo[2]); $usb_vendor->setNmUsbVendor('Fabricante de Dispositivos USB Desconhecido'); + + $arrVendorData = $usb_vendor; + } + + $arrDeviceData = $this->getDoctrine()->getRepository('CacicCommonBundle:UsbDevice')->findBy( array('idDevice'=>$arrUsbInfo[3], 'idVendor'=>$arrUsbInfo[2] )); + if (empty($arrDeviceData)) + { + $usb_device = new UsbDevice(); + $usb_device->setIdUsbVendor($arrVendorData); + $usb_device->setIdDevice($arrUsbInfo[3]); + $usb_device->setNmUsbDevice('Dispositivo USB Desconhecido'); + + $arrDeviceData = $usb_device; } + $usb_log = new UsbLog(); + $usb_log->setIdComputador($computador); + $usb_log->getCsEvent($arrUsbInfo[0]); + $usb_log->setDtEvent($arrUsbInfo[1]); + $usb_log->setIdUsbDevice($arrDeviceData); + + if ((trim($arrTeUsbFilter[0]['teUsbFilter'])<>'') && (trim($arrTeNotificarUtilizacaoUSB[0]['teNotificarUtilizacaoUsb']) <> '')) { $arrUSBfilter = explode('#',$arrTeUsbFilter[0]['te_usb_filter']); -- libgit2 0.21.2