/** * @return int */ protected function getTimeout() { if ($this->sessionData->getString("timeout") > 0) { return intval($this->sessionData->getString("timeout")); } else { return self::DEFAULT_RECEIVE_RESULTS_TIME; } }
/** * @param array $params * @return array */ public function check($params = array()) { $this->initializeParams($params); $testID = $this->getParam('TEST_ID', $this->internalName); $sessionData = new CSecurityTemporaryStorage($testID); if (!$sessionData->isExists('current_user')) { $userId = static::getNextUserId(0); $passwordId = 0; } else { $userId = $sessionData->getInt('current_user'); $passwordId = $sessionData->getInt('current_password'); } if ($userId > 0) { $userChecked = true; $passwordDictionary = static::getPasswordDictionary(); list($salt, $password) = $this->getUserPassword($userId); for ($i = $passwordId, $max = count($passwordDictionary); $i < $max; $i++) { if ($this->isTimeOut()) { $sessionData->setData('current_password', $i); $userChecked = false; break; } if (static::isUserPassword($salt, $password, $passwordDictionary[$i])) { $sessionData->pushToArray('weak_users', $userId); break; } } if ($userChecked) { $sessionData->setData('current_user', static::getNextUserId($userId)); } else { $sessionData->setData('current_user', $userId); } $result = array('name' => $this->getName(), 'timeout' => 1, 'in_progress' => true); } else { $weakUsers = $sessionData->getArray('weak_users'); $sessionData->flushData(); $result = array('name' => $this->getName(), 'problem_count' => !empty($weakUsers) ? 1 : 0, 'errors' => array(array('title' => GetMessage('SECURITY_SITE_CHECKER_ADMIN_WEAK_PASSWORD'), 'critical' => CSecurityCriticalLevel::HIGHT, 'detail' => GetMessage('SECURITY_SITE_CHECKER_ADMIN_WEAK_PASSWORD_DETAIL'), 'recommendation' => static::formatRecommendation($weakUsers))), 'status' => empty($weakUsers)); } return $result; }
/** * @param string|array $pTests * @return bool */ protected function initializeNeededTests($pTests) { if (is_string($pTests) && $pTests != "") { $this->neededTests = array($pTests); } elseif (is_array($pTests) && !empty($pTests)) { $this->neededTests = $pTests; } else { $this->neededTests = $this->allTests; } if (!$this->sessionData->isExists("NEEDED_TESTS")) { $this->sessionData->setData("NEEDED_TESTS", $this->neededTests); } return true; }