mirror of
https://github.com/e107inc/e107.git
synced 2025-08-11 17:14:42 +02:00
Validation bits improvement for e_file_inspector
Now File Inspector detects old files regardless of their hash value.
This commit is contained in:
@@ -69,18 +69,20 @@ abstract class e_file_inspector implements e_file_inspector_interface
|
||||
|
||||
$bits = 0x0;
|
||||
$absolutePath = realpath(e_BASE . $path);
|
||||
$dbChecksums = $this->getChecksums($path);
|
||||
$dbChecksum = $this->getChecksum($path, $version);
|
||||
$actualChecksum = $dbChecksum ? $this->checksumPath($absolutePath) : null;
|
||||
|
||||
if ($dbChecksum !== false) $bits |= self::VALIDATED_RELEVANCE;
|
||||
if (file_exists($absolutePath)) $bits |= self::VALIDATED_PRESENCE;
|
||||
if (!$this->isInsecure($path)) $bits |= self::VALIDATED_SECURITY;
|
||||
if ($this->isDeterminable($absolutePath)) $bits |= self::VALIDATED_DETERMINABLE;
|
||||
if ($actualChecksum === $dbChecksum) $bits |= self::VALIDATED_UPTODATE;
|
||||
if (!empty($dbChecksums)) $bits |= self::VALIDATED_PATH_KNOWN;
|
||||
if ($dbChecksum !== false) $bits |= self::VALIDATED_PATH_VERSION;
|
||||
if (file_exists($absolutePath)) $bits |= self::VALIDATED_FILE_EXISTS;
|
||||
if (!$this->isInsecure($path)) $bits |= self::VALIDATED_FILE_SECURITY;
|
||||
if ($this->isDeterminable($absolutePath)) $bits |= self::VALIDATED_HASH_CALCULABLE;
|
||||
if ($actualChecksum === $dbChecksum) $bits |= self::VALIDATED_HASH_CURRENT;
|
||||
|
||||
foreach ($this->getChecksums($path) as $dbVersion => $dbChecksum)
|
||||
foreach ($dbChecksums as $dbVersion => $dbChecksum)
|
||||
{
|
||||
if ($dbChecksum === $actualChecksum) $bits |= self::VALIDATED_HASH;
|
||||
if ($dbChecksum === $actualChecksum) $bits |= self::VALIDATED_HASH_EXISTS;
|
||||
}
|
||||
|
||||
if ($bits + self::VALIDATED === $this->getValidatedBitmask()) $bits |= self::VALIDATED;
|
||||
|
@@ -18,32 +18,37 @@ interface e_file_inspector_interface
|
||||
* TRUE: The file path is known in this database, regardless of version.
|
||||
* FALSE: The file path is not in this database.
|
||||
*/
|
||||
const VALIDATED_RELEVANCE = 1 << 1;
|
||||
const VALIDATED_PATH_KNOWN = 1 << 1;
|
||||
/**
|
||||
* TRUE: The file path and specified version have a hash in this database.
|
||||
* FALSE: There is no hash for the file path and specified version.
|
||||
*/
|
||||
const VALIDATED_PATH_VERSION = 1 << 2;
|
||||
/**
|
||||
* TRUE: The file exists.
|
||||
* FALSE: The file doesn't exist.
|
||||
*/
|
||||
const VALIDATED_PRESENCE = 1 << 2;
|
||||
const VALIDATED_FILE_EXISTS = 1 << 3;
|
||||
/**
|
||||
* TRUE: The file's hash matches a known version.
|
||||
* TRUE: The file's hash matches any known version.
|
||||
* FALSE: The file's hash does not match any known versions.
|
||||
*/
|
||||
const VALIDATED_HASH = 1 << 3;
|
||||
const VALIDATED_HASH_EXISTS = 1 << 4;
|
||||
/**
|
||||
* TRUE: The file's hash matches the specified version.
|
||||
* FALSE: The file's hash matches a newer or older version than the one specified.
|
||||
*/
|
||||
const VALIDATED_UPTODATE = 1 << 4;
|
||||
const VALIDATED_HASH_CURRENT = 1 << 5;
|
||||
/**
|
||||
* TRUE: The file hash is calculable.
|
||||
* FALSE: The file hash is not calculable (e.g. the core image itself, a user config file, a nonexistent file).
|
||||
*/
|
||||
const VALIDATED_DETERMINABLE = 1 << 5;
|
||||
const VALIDATED_HASH_CALCULABLE = 1 << 6;
|
||||
/**
|
||||
* TRUE: The file is not known to be insecure.
|
||||
* FALSE: The file should be deleted due to security concerns.
|
||||
*/
|
||||
const VALIDATED_SECURITY = 1 << 6;
|
||||
const VALIDATED_FILE_SECURITY = 1 << 7;
|
||||
|
||||
/**
|
||||
* Return an Iterator that can enumerate every path in the image database
|
||||
|
Reference in New Issue
Block a user