public function updateSignatures() { $message = 'Updating signatures... '; $signatureInfos = $this->_Api->getSignatureVersionInfos(); if (empty($signatureInfos)) { $message .= ' failed. (API: ' . $this->_Api->getError() . ')'; $this->_auditMessages[] = $message; return false; } // check for regex-db update: $fileRegexDb = $this->_Settings->auditSettings['filecheck']['pathRegexDb']; $pathRegexDb = dirname($fileRegexDb); if (!is_writable($pathRegexDb)) { $message .= ' failed. (Target directory not writeable.)'; $this->_auditMessages[] = $message; return false; } $RegexDb = new FileStorageEngine($fileRegexDb); if (!empty($signatureInfos['signature_versions']['regex_complete'])) { if ((int) $signatureInfos['signature_versions']['regex_complete']['version'] > (int) $RegexDb->version) { $downloadResult = Helper::downloadFile($signatureInfos['signature_versions']['regex_complete']['downloadUrl'], $pathRegexDb . '/regex_complete.tmp'); if ($downloadResult === false) { $message .= ' failed. (Download failed.)'; $this->_auditMessages[] = $message; return false; } if (sha1_file($pathRegexDb . '/regex_complete.tmp') !== $signatureInfos['signature_versions']['regex_complete']['checksum']) { $message .= ' failed. (Checksum missmatch)'; $this->_auditMessages[] = $message; unlink($pathRegexDb . '/regex_complete.tmp'); return false; } unlink($fileRegexDb); rename($pathRegexDb . '/regex_complete.tmp', $pathRegexDb . '/regex_complete.wmdb'); } } // check for whitelist-db update: $fileRegexWhitelist = $this->_Settings->auditSettings['filecheck']['pathRegexWhitelist']; $pathRegexWhitelist = dirname($fileRegexWhitelist); if (!is_writable($pathRegexWhitelist)) { $message .= ' failed. (Target directory not writeable.)'; $this->_auditMessages[] = $message; return false; } $RegexWhitelist = new FileStorageEngine($fileRegexWhitelist); if (!empty($signatureInfos['signature_versions']['regex_whitelist'])) { if ((int) $signatureInfos['signature_versions']['regex_whitelist']['version'] > (int) $RegexWhitelist->version) { $downloadResult = Helper::downloadFile($signatureInfos['signature_versions']['regex_whitelist']['downloadUrl'], $pathRegexWhitelist . '/regex_whitelist.tmp'); if ($downloadResult === false) { $message .= ' failed. (Download failed.)'; $this->_auditMessages[] = $message; return false; } if (sha1_file($pathRegexWhitelist . '/regex_whitelist.tmp') !== $signatureInfos['signature_versions']['regex_whitelist']['checksum']) { $message .= ' failed. (Checksum missmatch)'; $this->_auditMessages[] = $message; unlink($pathRegexWhitelist . '/regex_whitelist.tmp'); return false; } unlink($fileRegexWhitelist); rename($pathRegexWhitelist . '/regex_whitelist.tmp', $pathRegexWhitelist . '/regex_whitelist.wmdb'); } } $message .= ' Done.'; $this->_auditMessages[] = $message; return true; }
public function __construct(Database $Database) { $this->Database = $Database; $this->runMode = Helper::getRunMode(); }