getType(), ['Computer', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer'])) { $nb = 0; if ($_SESSION['glpishow_count_on_tabs']) { $nb = self::countForItem($item); } return self::createTabEntry(__('Wazuh Alerts', 'siem-wazuh'), $nb); } } return ''; } /** * Display tab content */ static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { if (in_array($item->getType(), ['Computer', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer'])) { self::showForItem($item); } return true; } /** * Count alerts for item */ static function countForItem(CommonGLPI $item) { global $DB; $itemtype = $item->getType(); $items_id = $item->getID(); $field_map = [ 'Computer' => 'computer_id', 'NetworkEquipment' => 'networkequipment_id', 'Peripheral' => 'peripheral_id', 'Phone' => 'phone_id', 'Printer' => 'printer_id' ]; if (!isset($field_map[$itemtype])) { return 0; } return countElementsInTable('glpi_plugin_siem_wazuh_alerts', [ $field_map[$itemtype] => $items_id ]); } /** * Show alerts for item */ static function showForItem(CommonGLPI $item) { global $DB, $CFG_GLPI; $itemtype = $item->getType(); $items_id = $item->getID(); $field_map = [ 'Computer' => 'computer_id', 'NetworkEquipment' => 'networkequipment_id', 'Peripheral' => 'peripheral_id', 'Phone' => 'phone_id', 'Printer' => 'printer_id' ]; if (!isset($field_map[$itemtype])) { return; } $field = $field_map[$itemtype]; $canupdate = Session::haveRight(static::$rightname, UPDATE); // Récupération des alertes $iterator = $DB->request([ 'SELECT' => [ 'glpi_plugin_siem_wazuh_alerts.*', 'glpi_plugin_siem_wazuh_servers.name AS server_name' ], 'FROM' => 'glpi_plugin_siem_wazuh_alerts', 'LEFT JOIN' => [ 'glpi_plugin_siem_wazuh_servers' => [ 'ON' => [ 'glpi_plugin_siem_wazuh_alerts' => 'wazuh_server_id', 'glpi_plugin_siem_wazuh_servers' => 'id' ] ] ], 'WHERE' => [$field => $items_id], 'ORDER' => ['timestamp DESC', 'rule_level DESC'], 'LIMIT' => 100 ]); $alerts = iterator_to_array($iterator); echo "
" . __('No Wazuh alerts found for this item', 'siem-wazuh') . "
"; echo "" . __('Alerts Summary', 'siem-wazuh') . " | "; echo "|||||||
---|---|---|---|---|---|---|---|
" . $stats['total'] . " " . __('Total', 'siem-wazuh') . " | ";
echo "" . $stats['new'] . " " . __('New', 'siem-wazuh') . " | ";
echo "" . $stats['processed'] . " " . __('Processed', 'siem-wazuh') . " | ";
echo "" . $stats['ticket_created'] . " " . __('Ticket Created', 'siem-wazuh') . " | ";
echo "" . $stats['critical'] . " " . __('Critical', 'siem-wazuh') . " | ";
echo "" . $stats['high'] . " " . __('High', 'siem-wazuh') . " | ";
echo "" . $stats['medium'] . " " . __('Medium', 'siem-wazuh') . " | ";
echo "" . $stats['low'] . " " . __('Low', 'siem-wazuh') . " | ";
echo "
" . __('Mass Actions', 'siem-wazuh') . " | "; echo "|
---|---|
" . __('Sync new alerts', 'siem-wazuh') . " | "; echo ""; echo ""; echo " | "; echo "
" . __('Export alerts', 'siem-wazuh') . " | "; echo ""; echo "getID() . "' class='btn'>"; echo __('Export CSV', 'siem-wazuh'); echo ""; echo " | "; echo "