Start repository

This commit is contained in:
tips-of-mine
2025-05-31 10:03:48 +02:00
commit 194322c9fc
57 changed files with 14723 additions and 0 deletions

View File

@ -0,0 +1,57 @@
#!/usr/bin/env php
<?php
/**
* GLPI CVE Plugin - CLI Inventory Analysis Script
* This script can be called from cron to analyze software inventory
*/
// Define GLPI's constants
define('GLPI_ROOT', dirname(__FILE__, 4));
// Include necessary files
include(GLPI_ROOT . "/inc/autoload.function.php");
include(GLPI_ROOT . "/inc/db.function.php");
include_once(GLPI_ROOT . "/inc/includes.php");
// No time limit for potentially long-running operation
set_time_limit(0);
// Ensure CLI mode is used
if (PHP_SAPI != 'cli') {
echo "This script must be run from command line";
exit(1);
}
// Initialize GLPI
$DB = new DB();
Session::setPath();
Session::start();
Session::loadLanguage();
// Use GLPI's CLI mode
if (!Session::getLoginUserID()) {
Session::setGlpiSessionPath();
Session::setGlpiSessionID('cli_' . getmypid());
$_SESSION['glpi_use_mode'] = Session::NORMAL_MODE;
$_SESSION['glpiname'] = 'cli_cve_inventory';
Session::loadGroups();
}
// Run the inventory analysis
$task = new CronTask();
if ($task->getFromDBbyName('PluginCveCveInventory', 'AnalyzeInventory')) {
echo "Starting software vulnerability analysis...\n";
$result = PluginCveCveInventory::cronAnalyzeInventory($task);
if ($result) {
echo "Software vulnerability analysis completed successfully.\n";
exit(0);
} else {
echo "Software vulnerability analysis completed with no new alerts.\n";
exit(0);
}
} else {
echo "Software vulnerability analysis task not found.\n";
exit(1);
}

57
scripts/cleanup.php Normal file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env php
<?php
/**
* GLPI CVE Plugin - CLI Cleanup Script
* This script removes old CVE data no longer needed
*/
// Define GLPI's constants
define('GLPI_ROOT', dirname(__FILE__, 4));
// Include necessary files
include(GLPI_ROOT . "/inc/autoload.function.php");
include(GLPI_ROOT . "/inc/db.function.php");
include_once(GLPI_ROOT . "/inc/includes.php");
// No time limit for potentially long-running operation
set_time_limit(0);
// Ensure CLI mode is used
if (PHP_SAPI != 'cli') {
echo "This script must be run from command line";
exit(1);
}
// Initialize GLPI
$DB = new DB();
Session::setPath();
Session::start();
Session::loadLanguage();
// Use GLPI's CLI mode
if (!Session::getLoginUserID()) {
Session::setGlpiSessionPath();
Session::setGlpiSessionID('cli_' . getmypid());
$_SESSION['glpi_use_mode'] = Session::NORMAL_MODE;
$_SESSION['glpiname'] = 'cli_cve_cleanup';
Session::loadGroups();
}
// Run the CVE cleanup task
$task = new CronTask();
if ($task->getFromDBbyName('PluginCveCve', 'CleanOldCVEs')) {
echo "Starting CVE cleanup...\n";
$result = PluginCveCve::cronCleanOldCVEs($task);
if ($result) {
echo "CVE cleanup completed successfully.\n";
exit(0);
} else {
echo "CVE cleanup failed or no data to clean.\n";
exit(1);
}
} else {
echo "CVE cleanup task not found.\n";
exit(1);
}

57
scripts/sync_cve.php Normal file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env php
<?php
/**
* GLPI CVE Plugin - CLI Sync Script
* This script can be called from cron to sync CVE data
*/
// Define GLPI's constants
define('GLPI_ROOT', dirname(__FILE__, 4));
// Include necessary files
include(GLPI_ROOT . "/inc/autoload.function.php");
include(GLPI_ROOT . "/inc/db.function.php");
include_once(GLPI_ROOT . "/inc/includes.php");
// No time limit for potentially long-running operation
set_time_limit(0);
// Ensure CLI mode is used
if (PHP_SAPI != 'cli') {
echo "This script must be run from command line";
exit(1);
}
// Initialize GLPI
$DB = new DB();
Session::setPath();
Session::start();
Session::loadLanguage();
// Use GLPI's CLI mode
if (!Session::getLoginUserID()) {
Session::setGlpiSessionPath();
Session::setGlpiSessionID('cli_' . getmypid());
$_SESSION['glpi_use_mode'] = Session::NORMAL_MODE;
$_SESSION['glpiname'] = 'cli_cve_sync';
Session::loadGroups();
}
// Run the CVE synchronization
$task = new CronTask();
if ($task->getFromDBbyName('PluginCveCveSource', 'SyncCVESources')) {
echo "Starting CVE synchronization...\n";
$result = PluginCveCveSource::cronSyncSources($task);
if ($result) {
echo "CVE synchronization completed successfully.\n";
exit(0);
} else {
echo "CVE synchronization failed or no sources to sync.\n";
exit(1);
}
} else {
echo "CVE synchronization task not found.\n";
exit(1);
}