Hello ,
i am facing a problem when running php cron_cve_computer.php,
after a while running it renders the following message: PHP Warning:
mysqli_fetch_array() expects parameter 1 to be mysqli_result,
bool given in /usr/share/ocsinventory-reports/ocsreports/crontab/cron_cve_computer.php
on line 36
this is the script I'm running in PHP:
#!/usr/bin/php
<?php
require_once('../var.php');
require_once(CONF_MYSQL);
require_once('../require/function_commun.php');
require_once('../require/cve/Cve.php');
require_once('../require/config/include.php');
require_once('../require/fichierConf.class.php');
$_SESSION['OCS']["writeServer"] = dbconnect(SERVER_WRITE, COMPTE_BASE, PSWD_BASE, DB_NAME, SSL_KEY, SSL_CERT, CA_CERT, SERVER_PORT);
$_SESSION['OCS']["readServer"] = dbconnect(SERVER_READ, COMPTE_BASE, PSWD_BASE, DB_NAME, SSL_KEY, SSL_CERT, CA_CERT, SERVER_PORT);
$cve = new Cve();
$date = null;
$clean = false;
//Check if CVE is activate
if($cve->CVE_ACTIVE == 1) {
print("Please wait, cve processing is in progress. It could take a few minutes ...\n");
$sql = "TRUNCATE TABLE `cve_search_computer`";
mysql2_query_secure($sql, $_SESSION['OCS']["writeServer"]);
$sql = 'SELECT *, p.PUBLISHER, c.LINK as id, h.NAME as computer, h.ID as computerid, n.NAME as softname
FROM cve_search c
LEFT JOIN software_name n ON n.ID = c.NAME_ID
LEFT JOIN software_publisher p ON p.ID = c.PUBLISHER_ID
LEFT JOIN software_version v ON v.ID = c.VERSION_ID
LEFT JOIN software s ON s.NAME_ID = n.ID AND p.ID = s.PUBLISHER_ID AND v.ID = s.VERSION_ID
INNER JOIN hardware h ON h.ID = s.HARDWARE_ID
GROUP BY h.ID, c.LINK, c.CVSS, c.NAME_ID, c.CVE';
$response = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], []);
$_SESSION['OCS']['DEBUG'] = "ON";
while ($value = mysqli_fetch_array($response)) {
$sql_insert = "INSERT INTO `cve_search_computer` (`HARDWARE_ID`, `HARDWARE_NAME`, `PUBLISHER`, `VERSION`, `SOFTWARE_NAME`, `CVSS`, `CVE`, `LINK`) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')";
$arg_sql = array($value['computerid'], $value['computer'], $value['PUBLISHER'], $value['VERSION'], $value['softname'], $value['CVSS'], $value['CVE'], $value['LINK']);
$res = mysql2_query_secure($sql_insert, $_SESSION['OCS']["writeServer"], $arg_sql);
if (!$res){
}
}
} else {
$cve->verbose($cve->CVE_VERBOSE, 3);
exit();
}?>
Server information
Operating system
- OS Name : Linux x86_64
- Version : 3.10.0-1160.62.1.el7.x86_64
- RAM installed : 32250 MB
- Free RAM : 29587 MB
- CPU : Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz
- Distribution : CentOS Linux 7 (Core)
Software
- PHP Version : 7.3.33
- Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.3.33 mod_perl/2.0.11 Perl/v5.16.3
- Database Server : MariaDB Server version 5.5.68-MariaDB
- Version OCSReports: 2.9.2
Could you help me with this problem I'm facing?