Example #1
0
	/**
	 * Try to start checking (send special request to Bitrix)
	 */
	protected function doCheckRequest()
	{
		$response = new CSecurityCloudMonitorRequest("check");
		if($response->isOk())
		{
			$this->sessionData->flushData();
			$this->setTimeOut($response->getValue("processing_time"));
			$this->setCheckingToken($response->getValue("testing_token"));
		}
		elseif($response->isFatalError())
		{
			$this->stopChecking($response->getValue("error_text"));
		}
		else
		{
			if($this->sessionData->getBool("repeat_request"))
			{
				if($this->sessionData->getInt("check_repeat_count") > self::MAX_CHECKING_REQUEST_REPEATE_COUNT)
				{
					$this->stopChecking(GetMessage("SECURITY_SITE_CHECKER_CLOUD_UNAVAILABLE"));
				}
				else
				{
					$this->sessionData->increment("check_repeat_count");
				}
			}
			else
			{
				$this->sessionData->flushData();
				$this->sessionData->setData("repeat_request", true);
			}
		}
	}
Example #2
0
 /**
  * @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;
 }
Example #3
0
 /**
  * Try to start checking (send special request to Bitrix)
  */
 protected function doCheckRequest()
 {
     $response = new CSecurityCloudMonitorRequest('check', $this->protocolVersion);
     if ($response->isOk()) {
         $this->sessionData->flushData();
         $this->setTimeOut($response->getValue('processing_time'));
         $this->setCheckingToken($response->getValue('testing_token'));
     } elseif ($response->isFatalError()) {
         $this->stopChecking($response->getValue('error_text'));
     } else {
         if ($this->sessionData->getBool('repeat_request')) {
             if ($this->sessionData->getInt('check_repeat_count') > self::MAX_CHECKING_REQUEST_REPEATE_COUNT) {
                 $this->stopChecking(GetMessage('SECURITY_SITE_CHECKER_CLOUD_UNAVAILABLE'));
             } else {
                 $this->sessionData->increment('check_repeat_count');
             }
         } else {
             $this->sessionData->flushData();
             $this->sessionData->setData('repeat_request', true);
         }
     }
 }