mirror of
https://github.com/e107inc/e107.git
synced 2025-07-16 20:41:27 +02:00
e_file_inspector: No longer conflate insecure files and cached old files
Related ticket: https://github.com/e107inc/e107/issues/4312
This commit is contained in:
@@ -139,7 +139,7 @@ class admin_start
|
|||||||
|
|
||||||
// Files that can cause comflicts and problems.
|
// Files that can cause comflicts and problems.
|
||||||
$fileInspector = e107::getFileInspector();
|
$fileInspector = e107::getFileInspector();
|
||||||
$this->deprecated = $fileInspector->insecureFiles;
|
$this->deprecated = $fileInspector::getCachedDeprecatedFiles();
|
||||||
|
|
||||||
$this->checkCoreVersion();
|
$this->checkCoreVersion();
|
||||||
|
|
||||||
|
@@ -53,6 +53,11 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
|||||||
private $existingInsecureFiles = array();
|
private $existingInsecureFiles = array();
|
||||||
private $existingInsecureDirectories = array();
|
private $existingInsecureDirectories = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var null|resource File pointer resource opened in write mode or null if not initialized yet
|
||||||
|
*/
|
||||||
|
private $deprecatedLogFileHandle = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* e_file_inspector constructor
|
* e_file_inspector constructor
|
||||||
* @param string $database The database from which integrity data may be read or to which integrity data may be
|
* @param string $database The database from which integrity data may be read or to which integrity data may be
|
||||||
@@ -62,8 +67,6 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
|||||||
{
|
{
|
||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
|
|
||||||
$this->checkDeprecatedFilesLog();
|
|
||||||
|
|
||||||
$appRoot = e107::getInstance()->file_path;
|
$appRoot = e107::getInstance()->file_path;
|
||||||
$this->undeterminable = array_map(function ($path)
|
$this->undeterminable = array_map(function ($path)
|
||||||
{
|
{
|
||||||
@@ -86,27 +89,27 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate insecureFiles list if deprecatedFiles.log found.
|
* Get a list of deprecated files cached in deprecatedFiles.log from the last File Inspector scan
|
||||||
* @return void
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function checkDeprecatedFilesLog()
|
public static function getCachedDeprecatedFiles()
|
||||||
{
|
{
|
||||||
$log = e_LOG.'fileinspector/deprecatedFiles.log';
|
$log = e_LOG.'fileinspector/deprecatedFiles.log';
|
||||||
|
|
||||||
if(!file_exists($log))
|
if(!file_exists($log))
|
||||||
{
|
{
|
||||||
return;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = file_get_contents($log);
|
$content = file_get_contents($log);
|
||||||
|
|
||||||
if(empty($content))
|
if(empty($content))
|
||||||
{
|
{
|
||||||
return;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp = explode("\n", $content);
|
$tmp = explode("\n", $content);
|
||||||
$this->insecureFiles = [];
|
$cachedDeprecatedFiles = [];
|
||||||
foreach($tmp as $line)
|
foreach($tmp as $line)
|
||||||
{
|
{
|
||||||
if(empty($line))
|
if(empty($line))
|
||||||
@@ -114,10 +117,10 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->insecureFiles[] = e_BASE.$line;
|
$cachedDeprecatedFiles[] = e_BASE.$line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $cachedDeprecatedFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,6 +214,8 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
|||||||
|
|
||||||
$message = $relativePath."\n";
|
$message = $relativePath."\n";
|
||||||
|
|
||||||
|
if (!is_resource($this->deprecatedLogFileHandle))
|
||||||
|
{
|
||||||
$logPath = e_LOG."fileinspector/";
|
$logPath = e_LOG."fileinspector/";
|
||||||
|
|
||||||
if(!is_dir($logPath))
|
if(!is_dir($logPath))
|
||||||
@@ -218,7 +223,10 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
|||||||
mkdir($logPath, 0775);
|
mkdir($logPath, 0775);
|
||||||
}
|
}
|
||||||
|
|
||||||
file_put_contents($logPath."deprecatedFiles.log", $message, FILE_APPEND);
|
$this->deprecatedLogFileHandle = fopen($logPath."deprecatedFiles.log", 'w');
|
||||||
|
}
|
||||||
|
|
||||||
|
fwrite($this->deprecatedLogFileHandle, $message);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user