The boot.php had been cleared of most functions

This commit is contained in:
Michael 2021-11-04 20:29:59 +00:00
parent 4989d1fa99
commit 63da4a75e9
37 changed files with 279 additions and 401 deletions

View file

@ -277,6 +277,44 @@ class Worker
return DBA::exists('workerqueue', $condition);
}
/**
* Checks if the given file is valid to be included
*
* @param mixed $file
* @return bool
*/
private static function validateInclude(&$file)
{
$orig_file = $file;
$file = realpath($file);
if (strpos($file, getcwd()) !== 0) {
return false;
}
$file = str_replace(getcwd() . "/", "", $file, $count);
if ($count != 1) {
return false;
}
if ($orig_file !== $file) {
return false;
}
$valid = false;
if (strpos($file, "include/") === 0) {
$valid = true;
}
if (strpos($file, "addon/") === 0) {
$valid = true;
}
// Simply return flag
return $valid;
}
/**
* Execute a worker entry
*
@ -360,7 +398,7 @@ class Worker
$include = "include/".$include.".php";
}
if (!validate_include($include)) {
if (!self::validateInclude($include)) {
Logger::warning("Include file is not valid", ['file' => $argv[0]]);
$stamp = (float)microtime(true);
DBA::delete('workerqueue', ['id' => $queue["id"]]);