1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
user.php
См. документацию.
1<?
8
14 extends CSecurityBaseTest
15{
16 protected $internalName = 'UsersTest';
18 protected $sessionData = null;
19 protected $maximumExecutionTime = 0.0;
20 protected $savedMaxExecutionTime = 0.0;
21
22 public function __construct()
23 {
24 IncludeModuleLangFile(__FILE__);
25 $this->savedMaxExecutionTime = ini_get("max_execution_time");
26 if ($this->savedMaxExecutionTime <= 0)
27 {
28 $phpMaxExecutionTime = 30;
29 }
30 else
31 {
32 $phpMaxExecutionTime = $this->savedMaxExecutionTime - 2;
33 }
34 $this->maximumExecutionTime = time() + $phpMaxExecutionTime;
35 set_time_limit(0);
36 }
37
38 public function __destruct()
39 {
40 set_time_limit($this->savedMaxExecutionTime);
41 }
42
47 public function check(array $params = [])
48 {
49 if (count($this->tests))
50 {
51 return parent::check($params);
52 }
53
55 $testID = $this->getParam('TEST_ID', $this->internalName);
57
58 if (!$sessionData->isExists('current_user'))
59 {
60 $user = static::getNextUser(0);
61 $passwordId = 0;
62 }
63 else
64 {
65 $user = static::getNextUser($sessionData->getInt('current_user'));
66 $passwordId = $sessionData->getInt('current_password');
67 }
68
69 if ($user && (int)$user['ID'] > 0)
70 {
71 $userChecked = true;
72 $passwordDictionary = static::getPasswordDictionary();
73 $hash = $user['PASSWORD'];
74 for ($i = $passwordId, $max = count($passwordDictionary); $i < $max; $i++)
75 {
76 if ($this->isTimeOut())
77 {
78 $sessionData->setData('current_password', $i);
79 $userChecked = false;
80 break;
81 }
82 if (\Bitrix\Main\Security\Password::equals($hash, $passwordDictionary[$i]))
83 {
84 $sessionData->pushToArray('weak_users', (int)$user['ID']);
85 break;
86 }
87 }
88
89 if ($userChecked)
90 {
91 $sessionData->setData('current_user', (int)$user['ID']);
92 }
93 else
94 {
95 $sessionData->setData('current_user', (int)$user['ID'] - 1);
96 }
97
98 $result = [
99 'name' => $this->getName(),
100 'timeout' => 1,
101 'in_progress' => true,
102 ];
103 }
104 else
105 {
106 $weakUsers = $sessionData->getArray('weak_users');
107 $sessionData->flushData();
108 $result = [
109 'name' => $this->getName(),
110 'problem_count' => !empty($weakUsers) ? 1 : 0,
111 'errors' => [
112 [
113 'title' => GetMessage('SECURITY_SITE_CHECKER_ADMIN_WEAK_PASSWORD'),
114 'critical' => CSecurityCriticalLevel::HIGHT,
115 'detail' => GetMessage('SECURITY_SITE_CHECKER_ADMIN_WEAK_PASSWORD_DETAIL'),
116 'recommendation' => $result = GetMessage('SECURITY_SITE_CHECKER_ADMIN_WEAK_PASSWORD_RECOMMENDATIONS'),
117 'additional_info' => !empty($weakUsers) ? static::formatRecommendation($weakUsers) : '',
118 ],
119 ],
120 'status' => empty($weakUsers),
121 ];
122 }
123
124 return $result;
125 }
126
131 protected static function formatRecommendation(array $weakUsers)
132 {
133 $result = getMessage('SECURITY_SITE_CHECKER_ADMIN_WEAK_PASSWORD_USER_LIST');
134 foreach (static::getUsersLogins($weakUsers) as $id => $login)
135 {
136 $result .= sprintf(
137 '<br><a href="/bitrix/admin/user_edit.php?ID=%d" target="_blank">%s<a/>',
139 );
140 }
141
142 return $result;
143 }
144
149 protected static function getNextUser($id)
150 {
151 $result = null;
152 $users = static::getAdminUserList(1, $id);
153 if ($user = $users->fetch())
154 {
155 $result = $user;
156 }
157
158 return $result;
159 }
160
165 protected static function getUsersLogins(array $ids)
166 {
167 if (empty($ids))
168 {
169 return [];
170 }
171
172 $dbUser = CUser::GetList(
173 'ID',
174 'ASC',
175 [
176 'ID' => implode('|', $ids),
177 'ACTIVE' => 'Y',
178 ],
179 [
180 'FIELDS' => 'LOGIN',
181 ]
182 );
183
184 $result = [];
185 if ($dbUser)
186 {
187 while ($user = $dbUser->fetch())
188 {
189 $result[$user['ID']] = $user['LOGIN'];
190 }
191 }
192
193 return $result;
194 }
195
196 protected static function getPasswordDictionary()
197 {
198 static $passwords = null;
199
200 if (is_null($passwords))
201 {
202 $passwords = file($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/security/data/passwordlist.txt',
203 FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
204 }
205
206 return $passwords;
207 }
208
214 protected static function getAdminUserList($limit = 0, $minId = 0)
215 {
216 $dbUser = CUser::GetList(
217 'ID',
218 'ASC',
219 [
220 'GROUPS_ID' => 1,
221 '>ID' => $minId,
222 'ACTIVE' => 'Y',
223 ],
224 [
225 'FIELDS' => 'ID',
226 'NAV_PARAMS' => [
227 'nTopCount' => $limit,
228 ],
229 ]
230 );
231
232 if ($dbUser)
233 {
234 return $dbUser;
235 }
236 else
237 {
238 return new CDBResult([]);
239 }
240 }
241
245 protected function isTimeOut()
246 {
247 return (time() >= $this->maximumExecutionTime);
248 }
249}
$hash
Определения ajax_redirector.php:8
$login
Определения change_password.php:8
Определения base_test.php:14
getName()
Определения base_test.php:28
initializeParams(array $params=array())
Определения base_test.php:115
getParam($name, $defaultValue="")
Определения base_test.php:182
$params
Определения base_test.php:20
const HIGHT
Определения critical_level.php:17
Определения user.php:15
check(array $params=[])
Определения user.php:47
$savedMaxExecutionTime
Определения user.php:20
__construct()
Определения user.php:22
isTimeOut()
Определения user.php:245
$maximumExecutionTime
Определения user.php:19
__destruct()
Определения user.php:38
static getNextUser($id)
Определения user.php:149
static getPasswordDictionary()
Определения user.php:196
$internalName
Определения user.php:16
static getAdminUserList($limit=0, $minId=0)
Определения user.php:214
$sessionData
Определения user.php:18
static getUsersLogins(array $ids)
Определения user.php:165
static formatRecommendation(array $weakUsers)
Определения user.php:131
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$max
Определения template_copy.php:262