mirror of
https://github.com/tips-of-mine/GLPI-Plugin-CVE-Prototype.git
synced 2025-06-28 15:18:45 +02:00
Update plugin configuration files for proper GLPI detection
This commit is contained in:
88
front/cve.form.php
Normal file
88
front/cve.form.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
/**
|
||||
* GLPI CVE Plugin - CVE Form
|
||||
*/
|
||||
|
||||
include ("../../../inc/includes.php");
|
||||
|
||||
Session::checkRight("plugin_cve_cve", READ);
|
||||
|
||||
$cve = new PluginCveCve();
|
||||
|
||||
if (isset($_POST["add"])) {
|
||||
$cve->check(-1, CREATE, $_POST);
|
||||
if ($cve->add($_POST)) {
|
||||
Event::log(
|
||||
$cve->fields['id'],
|
||||
"plugin_cve_cve",
|
||||
4,
|
||||
"inventory",
|
||||
sprintf(__('%1$s adds the CVE %2$s'), $_SESSION["glpiname"], $_POST["cve_id"])
|
||||
);
|
||||
}
|
||||
Html::back();
|
||||
} else if (isset($_POST["delete"])) {
|
||||
$cve->check($_POST["id"], DELETE);
|
||||
if ($cve->delete($_POST)) {
|
||||
Event::log(
|
||||
$_POST["id"],
|
||||
"plugin_cve_cve",
|
||||
4,
|
||||
"inventory",
|
||||
sprintf(__('%1$s deletes the CVE %2$s'), $_SESSION["glpiname"], $_POST["id"])
|
||||
);
|
||||
}
|
||||
$cve->redirectToList();
|
||||
} else if (isset($_POST["restore"])) {
|
||||
$cve->check($_POST["id"], DELETE);
|
||||
if ($cve->restore($_POST)) {
|
||||
Event::log(
|
||||
$_POST["id"],
|
||||
"plugin_cve_cve",
|
||||
4,
|
||||
"inventory",
|
||||
sprintf(__('%1$s restores the CVE %2$s'), $_SESSION["glpiname"], $_POST["id"])
|
||||
);
|
||||
}
|
||||
$cve->redirectToList();
|
||||
} else if (isset($_POST["purge"])) {
|
||||
$cve->check($_POST["id"], PURGE);
|
||||
if ($cve->delete($_POST, 1)) {
|
||||
Event::log(
|
||||
$_POST["id"],
|
||||
"plugin_cve_cve",
|
||||
4,
|
||||
"inventory",
|
||||
sprintf(__('%1$s purges the CVE %2$s'), $_SESSION["glpiname"], $_POST["id"])
|
||||
);
|
||||
}
|
||||
$cve->redirectToList();
|
||||
} else if (isset($_POST["update"])) {
|
||||
$cve->check($_POST["id"], UPDATE);
|
||||
if ($cve->update($_POST)) {
|
||||
Event::log(
|
||||
$_POST["id"],
|
||||
"plugin_cve_cve",
|
||||
4,
|
||||
"inventory",
|
||||
sprintf(__('%1$s updates the CVE %2$s'), $_SESSION["glpiname"], $_POST["id"])
|
||||
);
|
||||
}
|
||||
Html::back();
|
||||
} else {
|
||||
Html::header(
|
||||
PluginCveCve::getTypeName(Session::getPluralNumber()),
|
||||
$_SERVER['PHP_SELF'],
|
||||
"tools",
|
||||
"PluginCveCveMenu",
|
||||
"cve"
|
||||
);
|
||||
|
||||
$id = 0;
|
||||
if (isset($_GET["id"])) {
|
||||
$id = $_GET["id"];
|
||||
}
|
||||
|
||||
$cve->display(['id' => $id]);
|
||||
Html::footer();
|
||||
}
|
20
front/cve.php
Normal file
20
front/cve.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* GLPI CVE Plugin - Main CVE list
|
||||
*/
|
||||
|
||||
include ("../../../inc/includes.php");
|
||||
|
||||
Session::checkRight("plugin_cve_cve", READ);
|
||||
|
||||
Html::header(
|
||||
PluginCveCve::getTypeName(Session::getPluralNumber()),
|
||||
$_SERVER['PHP_SELF'],
|
||||
"tools",
|
||||
"PluginCveCveMenu",
|
||||
"cve"
|
||||
);
|
||||
|
||||
Search::show('PluginCveCve');
|
||||
|
||||
Html::footer();
|
176
front/dashboard.php
Normal file
176
front/dashboard.php
Normal file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* GLPI CVE Plugin - Dashboard Page
|
||||
*/
|
||||
|
||||
include ("../../../inc/includes.php");
|
||||
|
||||
Session::checkRight("plugin_cve_cve", READ);
|
||||
|
||||
Html::header(
|
||||
__('Dashboard', 'cve'),
|
||||
$_SERVER['PHP_SELF'],
|
||||
"tools",
|
||||
"PluginCveCveMenu",
|
||||
"dashboard"
|
||||
);
|
||||
|
||||
// Get statistical data
|
||||
$cve_stats = PluginCveCve::getCVEStatsDashboard();
|
||||
$severity_data = PluginCveCve::getCVESeverityDashboard();
|
||||
$recent_cves = PluginCveCve::getRecentCVEsDashboard();
|
||||
$alert_stats = PluginCveCveAlert::getAlertStats();
|
||||
|
||||
// Display dashboard
|
||||
echo "<div class='center'>";
|
||||
|
||||
// Statistics cards
|
||||
echo "<div class='dashboard-card-container'>";
|
||||
|
||||
// Critical vulnerabilities card
|
||||
echo "<div class='dashboard-card dashboard-card-critical'>";
|
||||
echo "<div class='dashboard-card-icon'><i class='fas fa-exclamation-triangle'></i></div>";
|
||||
echo "<div class='dashboard-card-content'>";
|
||||
echo "<div class='dashboard-card-title'>" . __('Critical Vulnerabilities', 'cve') . "</div>";
|
||||
echo "<div class='dashboard-card-value'>" . ($cve_stats['severity']['CRITICAL'] ?? 0) . "</div>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
|
||||
// High risk card
|
||||
echo "<div class='dashboard-card dashboard-card-high'>";
|
||||
echo "<div class='dashboard-card-icon'><i class='fas fa-exclamation-circle'></i></div>";
|
||||
echo "<div class='dashboard-card-content'>";
|
||||
echo "<div class='dashboard-card-title'>" . __('High Vulnerabilities', 'cve') . "</div>";
|
||||
echo "<div class='dashboard-card-value'>" . ($cve_stats['severity']['HIGH'] ?? 0) . "</div>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
|
||||
// New alerts card
|
||||
echo "<div class='dashboard-card dashboard-card-new'>";
|
||||
echo "<div class='dashboard-card-icon'><i class='fas fa-bell'></i></div>";
|
||||
echo "<div class='dashboard-card-content'>";
|
||||
echo "<div class='dashboard-card-title'>" . __('New Alerts', 'cve') . "</div>";
|
||||
echo "<div class='dashboard-card-value'>" . ($alert_stats['by_status']['NEW'] ?? 0) . "</div>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
|
||||
// Resolved card
|
||||
echo "<div class='dashboard-card dashboard-card-resolved'>";
|
||||
echo "<div class='dashboard-card-icon'><i class='fas fa-check-circle'></i></div>";
|
||||
echo "<div class='dashboard-card-content'>";
|
||||
echo "<div class='dashboard-card-title'>" . __('Resolved', 'cve') . "</div>";
|
||||
echo "<div class='dashboard-card-value'>" . ($cve_stats['status']['RESOLVED'] ?? 0) . "</div>";
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
|
||||
echo "</div>";
|
||||
|
||||
// Severity distribution chart
|
||||
if (!empty($severity_data)) {
|
||||
echo "<div class='dashboard-chart-container'>";
|
||||
echo "<h2>" . __('CVE Severity Distribution', 'cve') . "</h2>";
|
||||
|
||||
echo "<div id='severity-chart'>";
|
||||
// This would be replaced with an actual chart library in production
|
||||
echo "<div class='severity-chart-bars'>";
|
||||
foreach ($severity_data['labels'] as $i => $label) {
|
||||
$value = $severity_data['series'][$i]['data'][0] ?? 0;
|
||||
$color = $severity_data['series'][$i]['color'] ?? '#999999';
|
||||
|
||||
echo "<div class='severity-chart-bar-container'>";
|
||||
echo "<div class='severity-chart-label'>" . $label . "</div>";
|
||||
echo "<div class='severity-chart-bar' style='height: " . min(100, max(5, ($value / max(1, array_sum(array_column($severity_data['series'], 'data')[0])) * 100))) . "%; background-color: " . $color . ";'></div>";
|
||||
echo "<div class='severity-chart-value'>" . $value . "</div>";
|
||||
echo "</div>";
|
||||
}
|
||||
echo "</div>";
|
||||
echo "</div>";
|
||||
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
// Recent CVEs table
|
||||
if (!empty($recent_cves)) {
|
||||
echo "<div class='dashboard-table-container'>";
|
||||
echo "<h2>" . __('Recent CVEs', 'cve') . "</h2>";
|
||||
|
||||
echo "<table class='tab_cadre_fixehov'>";
|
||||
echo "<tr>";
|
||||
foreach ($recent_cves['headers'] as $header) {
|
||||
echo "<th>" . $header . "</th>";
|
||||
}
|
||||
echo "</tr>";
|
||||
|
||||
foreach ($recent_cves['rows'] as $row) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td><a href='" . PluginCveCve::getFormURLWithID($row['id'] ?? 0) . "'>" . $row['cve_id'] . "</a></td>";
|
||||
echo "<td><span class='" . PluginCveCve::getSeverityClass($row['severity']) . "'>" . $row['severity'] . "</span></td>";
|
||||
echo "<td>" . $row['cvss_score'] . "</td>";
|
||||
echo "<td>" . Html::convDateTime($row['published']) . "</td>";
|
||||
echo "<td><span class='" . PluginCveCve::getStatusClass($row['status']) . "'>" . $row['status'] . "</span></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
echo "<div class='center'><a href='cve.php'>" . __('View all CVEs', 'cve') . "</a></div>";
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
// Device Vulnerability Alerts
|
||||
echo "<div class='dashboard-table-container'>";
|
||||
echo "<h2>" . __('Alerts by Device', 'cve') . "</h2>";
|
||||
echo "<table class='tab_cadre_fixehov'>";
|
||||
echo "<tr>";
|
||||
echo "<th>" . __('Device', 'cve') . "</th>";
|
||||
echo "<th>" . __('Total Alerts', 'cve') . "</th>";
|
||||
echo "<th>" . __('Critical', 'cve') . "</th>";
|
||||
echo "<th>" . __('High', 'cve') . "</th>";
|
||||
echo "<th></th>";
|
||||
echo "</tr>";
|
||||
|
||||
// This would be populated with actual data from the database
|
||||
// Placeholder for demonstration purposes
|
||||
$deviceAlerts = [
|
||||
['name' => 'Windows Server 2019', 'alerts' => 12, 'critical' => 3, 'high' => 6],
|
||||
['name' => 'Ubuntu 20.04 LTS', 'alerts' => 8, 'critical' => 2, 'high' => 3],
|
||||
['name' => 'macOS Monterey', 'alerts' => 5, 'critical' => 0, 'high' => 2],
|
||||
['name' => 'Cisco IOS Router', 'alerts' => 7, 'critical' => 4, 'high' => 2],
|
||||
['name' => 'Database Server', 'alerts' => 9, 'critical' => 1, 'high' => 5],
|
||||
];
|
||||
|
||||
foreach ($deviceAlerts as $device) {
|
||||
echo "<tr class='tab_bg_1'>";
|
||||
echo "<td>" . $device['name'] . "</td>";
|
||||
echo "<td>" . $device['alerts'] . "</td>";
|
||||
|
||||
// Critical alerts with badge
|
||||
echo "<td>";
|
||||
if ($device['critical'] > 0) {
|
||||
echo "<span class='cve-severity-critical badge'>" . $device['critical'] . "</span>";
|
||||
} else {
|
||||
echo "0";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
// High alerts with badge
|
||||
echo "<td>";
|
||||
if ($device['high'] > 0) {
|
||||
echo "<span class='cve-severity-high badge'>" . $device['high'] . "</span>";
|
||||
} else {
|
||||
echo "0";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
echo "<td class='center'>";
|
||||
echo "<a href='alert.php?criteria[0][field]=2&criteria[0][searchtype]=contains&criteria[0][value]=" . urlencode($device['name']) . "'>" . __('View', 'cve') . "</a>";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
echo "<div class='center'><a href='alert.php'>" . __('View all alerts', 'cve') . "</a></div>";
|
||||
echo "</div>";
|
||||
|
||||
echo "</div>"; // End of dashboard container
|
||||
|
||||
Html::footer();
|
Reference in New Issue
Block a user