1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
php_configuration.php
См. документацию.
1
<?
8
13
class
CSecurityPhpConfigurationTest
14
extends
CSecurityBaseTest
15
{
16
protected
$internalName
=
"PhpConfigurationTest"
;
17
18
protected
$tests
=
array
(
19
"phpEntropy"
=>
array
(
20
"method"
=>
"checkPhpEntropy"
21
),
22
"phpInclude"
=>
array
(
23
"method"
=>
"isPhpConfVarOff"
,
24
"params"
=>
array
(
"allow_url_include"
),
25
"base_message_key"
=>
"SECURITY_SITE_CHECKER_PHP_INCLUDE"
,
26
"critical"
=>
CSecurityCriticalLevel::HIGHT
27
),
28
"phpFopen"
=>
array
(
29
"method"
=>
"isPhpConfVarOff"
,
30
"params"
=>
array
(
"allow_url_fopen"
),
31
"base_message_key"
=>
"SECURITY_SITE_CHECKER_PHP_FOPEN"
,
32
"critical"
=>
CSecurityCriticalLevel::MIDDLE
33
),
34
"aspTags"
=>
array
(
35
"method"
=>
"isPhpConfVarOff"
,
36
"params"
=>
array
(
"asp_tags"
),
37
"base_message_key"
=>
"SECURITY_SITE_CHECKER_PHP_ASP"
,
38
"critical"
=>
CSecurityCriticalLevel::HIGHT
39
),
40
"httpOnly"
=>
array
(
41
"method"
=>
"isPhpConfVarOn"
,
42
"params"
=>
array
(
"session.cookie_httponly"
),
43
"base_message_key"
=>
"SECURITY_SITE_CHECKER_PHP_HTTPONLY"
,
44
"critical"
=>
CSecurityCriticalLevel::MIDDLE
45
),
46
"cookieOnly"
=>
array
(
47
"method"
=>
"isPhpConfVarOn"
,
48
"params"
=>
array
(
"session.use_only_cookies"
),
49
"base_message_key"
=>
"SECURITY_SITE_CHECKER_PHP_COOKIEONLY"
,
50
"critical"
=>
CSecurityCriticalLevel::HIGHT
51
),
52
"mbstringSubstitute"
=>
array
(
53
"method"
=>
"checkMbstringSubstitute"
,
54
"params"
=>
array
(),
55
"base_message_key"
=>
"SECURITY_SITE_CHECKER_PHP_MBSTRING_SUBSTITUTE"
,
56
"critical"
=>
CSecurityCriticalLevel::HIGHT
57
),
58
// ToDo: need compatibility with PHP < 5.4.0?
59
"zendMultibyte"
=>
array
(
60
"method"
=>
"isPhpConfVarOff"
,
61
"params"
=>
array
(
"zend.multibyte"
),
62
"base_message_key"
=>
"SECURITY_SITE_CHECKER_ZEND_MULTIBYTE_ENABLED"
,
63
"critical"
=>
CSecurityCriticalLevel::HIGHT
64
),
65
"displayErrors"
=>
array
(
66
"method"
=>
"isPhpConfVarOff"
,
67
"params"
=>
array
(
"display_errors"
),
68
"base_message_key"
=>
"SECURITY_SITE_CHECKER_DISPLAY_ERRORS"
,
69
"critical"
=>
CSecurityCriticalLevel::LOW
70
),
71
"requestOrder"
=>
array
(
72
"method"
=>
"checkRequestOrder"
73
),
74
"mailAddHeader"
=>
array
(
75
"method"
=>
"isPhpConfVarOff"
,
76
"params"
=>
array
(
"mail.add_x_header"
),
77
"base_message_key"
=>
"SECURITY_SITE_CHECKER_MAIL_ADD_HEADER"
,
78
"critical"
=>
CSecurityCriticalLevel::LOW
79
),
80
"secure"
=>
array
(
81
"method"
=>
"isPhpConfVarOn"
,
82
"params"
=>
array
(
"session.cookie_secure"
),
83
"base_message_key"
=>
"SECURITY_SITE_CHECKER_PHP_SECURE"
,
84
"critical"
=>
CSecurityCriticalLevel::MIDDLE
85
),
86
"sameSite"
=>
array
(
87
"method"
=>
"checkSamesite"
,
88
"params"
=>
array
(
"session.cookie_samesite"
),
89
"base_message_key"
=>
"SECURITY_SITE_CHECKER_PHP_SAMESITE"
,
90
"critical"
=>
CSecurityCriticalLevel::MIDDLE
91
),
92
);
93
94
public
function
__construct
()
95
{
96
IncludeModuleLangFile
(__FILE__);
97
}
98
103
protected
function
checkPhpEntropy
()
104
{
105
if
(!self::checkPhpEntropyConfigs())
106
{
107
$this->
addUnformattedDetailError
(
"SECURITY_SITE_CHECKER_PHP_ENTROPY"
,
CSecurityCriticalLevel::MIDDLE
);
108
return
self::STATUS_FAILED;
109
}
110
return
self::STATUS_PASSED;
111
}
112
116
protected
function
checkPhpEntropyConfigs
()
117
{
118
$entropyFile = ini_get(
"session.entropy_file"
);
119
$entropyLength = ini_get(
"session.entropy_length"
);
120
121
if
(!in_array($entropyFile,
array
(
"/dev/random"
,
"/dev/urandom"
),
true
))
122
{
123
return
self::STATUS_FAILED;
124
}
125
126
if
(self::isRunOnWin() && !$entropyLength)
127
{
128
return
self::STATUS_FAILED;
129
}
130
elseif
($entropyLength < 128)
131
{
132
return
self::STATUS_FAILED;
133
}
134
135
return
self::STATUS_PASSED;
136
}
137
138
protected
function
checkRequestOrder
()
139
{
140
$order
= ini_get(
'request_order'
);
141
if
(!
$order
|| !in_array(
$order
,
array
(
'GP'
,
'PG'
),
true
))
142
{
143
$this->
addUnformattedDetailError
(
144
'SECURITY_SITE_CHECKER_PHP_REQUEST_ORDER'
,
145
CSecurityCriticalLevel::MIDDLE
,
146
getMessage(
'SECURITY_SITE_CHECKER_PHP_REQUEST_ORDER_ADDITIONAL'
,
array
(
147
'#CURRENT#'
=>
$order
,
148
'#RECOMMENDED#'
=>
'GP'
149
))
150
);
151
return
self::STATUS_FAILED;
152
}
153
154
return
self::STATUS_PASSED;
155
}
156
160
protected
function
checkMbstringSubstitute
()
161
{
162
if
($this->
isPhpConfVarEquals
(
'mbstring.substitute_character'
,
'none'
))
163
return
self::STATUS_FAILED;
164
165
return
self::STATUS_PASSED;
166
}
167
172
protected
function
isPhpConfVarOff
(
$name
)
173
{
174
return
(intval(ini_get(
$name
)) == 0 || mb_strtolower(trim(ini_get(
$name
))) ==
"off"
);
175
}
176
182
protected
function
isPhpConfVarOn
(
$name
)
183
{
184
return
(intval(ini_get(
$name
)) == 1 || mb_strtolower(trim(ini_get(
$name
))) ==
"on"
);
185
}
186
192
protected
function
isPhpConfVarEquals
(
$name
, $value)
193
{
194
return
ini_get(
$name
) == $value;
195
}
196
202
protected
function
isPhpConfVarNotEquals
(
$name
, $value)
203
{
204
return
ini_get(
$name
) != $value;
205
}
206
207
protected
function
checkSamesite
(
$name
)
208
{
209
$sameSite = ini_get(
$name
);
210
$sameSite = mb_strtolower(trim($sameSite));
211
212
if
($sameSite ===
""
|| $sameSite ===
"lax"
|| $sameSite ===
"strict"
)
213
{
214
return
self::STATUS_PASSED;
215
}
216
217
if
($sameSite ===
"none"
&& $this->
isPhpConfVarOn
(
"session.cookie_secure"
))
218
{
219
return
self::STATUS_PASSED;
220
}
221
222
return
self::STATUS_FAILED;
223
}
224
225
}
CSecurityBaseTest
Определения
base_test.php:14
CSecurityBaseTest\addUnformattedDetailError
addUnformattedDetailError($baseMessageKey, $critical, $additionalInfo="")
Определения
base_test.php:283
CSecurityCriticalLevel\LOW
const LOW
Определения
critical_level.php:15
CSecurityCriticalLevel\MIDDLE
const MIDDLE
Определения
critical_level.php:16
CSecurityCriticalLevel\HIGHT
const HIGHT
Определения
critical_level.php:17
CSecurityPhpConfigurationTest
Определения
php_configuration.php:15
CSecurityPhpConfigurationTest\__construct
__construct()
Определения
php_configuration.php:94
CSecurityPhpConfigurationTest\checkMbstringSubstitute
checkMbstringSubstitute()
Определения
php_configuration.php:160
CSecurityPhpConfigurationTest\isPhpConfVarOff
isPhpConfVarOff($name)
Определения
php_configuration.php:172
CSecurityPhpConfigurationTest\isPhpConfVarEquals
isPhpConfVarEquals($name, $value)
Определения
php_configuration.php:192
CSecurityPhpConfigurationTest\isPhpConfVarNotEquals
isPhpConfVarNotEquals($name, $value)
Определения
php_configuration.php:202
CSecurityPhpConfigurationTest\checkRequestOrder
checkRequestOrder()
Определения
php_configuration.php:138
CSecurityPhpConfigurationTest\$tests
$tests
Определения
php_configuration.php:18
CSecurityPhpConfigurationTest\checkSamesite
checkSamesite($name)
Определения
php_configuration.php:207
CSecurityPhpConfigurationTest\$internalName
$internalName
Определения
php_configuration.php:16
CSecurityPhpConfigurationTest\isPhpConfVarOn
isPhpConfVarOn($name)
Определения
php_configuration.php:182
CSecurityPhpConfigurationTest\checkPhpEntropyConfigs
checkPhpEntropyConfigs()
Определения
php_configuration.php:116
CSecurityPhpConfigurationTest\checkPhpEntropy
checkPhpEntropy()
Определения
php_configuration.php:103
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
IncludeModuleLangFile
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения
tools.php:3778
$name
$name
Определения
menu_edit.php:35
$order
$order
Определения
payment.php:8
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
security
classes
general
tests
php_configuration.php
Создано системой
1.14.0