deleteByCriteria(['tickets_id' => $ticket->getID()]); // Also remove any alert associations $alert = new PluginCveCveAlert(); $alert->deleteByCriteria(['tickets_id' => $ticket->getID()]); } /** * Create dashboard cards for the plugin * * @param array $cards * @return array */ function plugin_cve_dashboard_cards($cards) { $new_cards = []; // Add CVE statistics card $new_cards['plugin_cve_stats'] = [ 'widgettype' => 'statscard', 'title' => __('CVE Statistics', 'cve'), 'icon' => 'ti ti-shield', 'provider' => 'PluginCveCve::getCVEStatsDashboard' ]; // Add CVE severity distribution card $new_cards['plugin_cve_severity'] = [ 'widgettype' => 'donut', 'title' => __('CVE Severity Distribution', 'cve'), 'icon' => 'ti ti-chart-pie', 'provider' => 'PluginCveCve::getCVESeverityDashboard' ]; // Add recent CVEs card $new_cards['plugin_cve_recent'] = [ 'widgettype' => 'table', 'title' => __('Recent CVEs', 'cve'), 'icon' => 'ti ti-list', 'provider' => 'PluginCveCve::getRecentCVEsDashboard' ]; // Add software vulnerability statistics card $new_cards['plugin_cve_software_vulnerabilities'] = [ 'widgettype' => 'statscard', 'title' => __('Software Vulnerability Alerts', 'cve'), 'icon' => 'ti ti-alert-triangle', 'provider' => 'PluginCveCveAlert::getAlertStats' ]; return array_merge($cards, $new_cards); } /** * Create the tables needed to run plugin * * @return boolean */ function plugin_cve_createTables() { plugin_cve_install(); return true; } /** * Migration function * * @param string $version Version to upgrade from * @return boolean */ function plugin_cve_upgradeTables($version) { // Handle migrations based on version // This would be implemented with version-specific upgrades return true; } /** * Add plugin entries to GLPI's search engine * * @param string $itemtype * @return array */ function plugin_cve_getAddSearchOptions($itemtype) { $options = []; if ($itemtype == 'Ticket') { $options[9100] = [ 'table' => 'glpi_plugin_cve_tickets', 'field' => 'id', 'name' => __('Associated CVEs', 'cve'), 'massiveaction' => false, 'joinparams' => [ 'jointype' => 'child', 'condition' => "AND `REFTABLE`.`id` = `TABLE`.`tickets_id`" ] ]; } if ($itemtype == 'Software') { $options[9200] = [ 'table' => 'glpi_plugin_cve_alerts', 'field' => 'id', 'name' => __('Vulnerability Alerts', 'cve'), 'massiveaction' => false, 'joinparams' => [ 'jointype' => 'child', 'condition' => "AND `REFTABLE`.`id` = `TABLE`.`softwares_id`" ] ]; $options[9201] = [ 'table' => 'glpi_plugin_cve_alerts', 'field' => 'severity', 'name' => __('Vulnerability Severity', 'cve'), 'massiveaction' => false, 'joinparams' => [ 'jointype' => 'child', 'condition' => "AND `REFTABLE`.`id` = `TABLE`.`softwares_id`" ] ]; } return $options; } /** * Datainjection hook * * @param array $data * @return array */ function plugin_datainjection_populate_cve($data) { // Logic for data injection support // This would be implemented with actual data mapping logic return $data; }