dbxapp
4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
dbxapp.de
Portal
Start
Anwender
Entwickler
KI-Bereiche
Loading...
Searching...
No Matches
db_access_boundary_test.php
Go to the documentation of this file.
1
<?php
2
3
$root
= dirname(__DIR__, 3);
4
$allowed
= realpath(
$root
.
'/dbx/include/dbxDB.class.php'
);
5
$failures
= array();
6
$patterns
= array(
7
'/\bnew\s+\\\\?PDO\b/i'
,
8
'/\bPDO::/i'
,
9
'/\bmysqli_(?:connect|query|prepare)\b/i'
,
10
'/\bnew\s+mysqli\b/i'
,
11
);
12
13
$iterator
=
new
RecursiveIteratorIterator(
14
new
RecursiveDirectoryIterator(
$root
, FilesystemIterator::SKIP_DOTS)
15
);
16
foreach
(
$iterator
as
$file
) {
17
if
(!
$file
->isFile() || strtolower(
$file
->getExtension()) !==
'php'
) {
18
continue
;
19
}
20
$path =
$file
->getRealPath();
21
$normalized
= str_replace(
'\\'
,
'/'
, $path ?:
''
);
22
if
($path ===
$allowed
23
|| strpos(
$normalized
,
'/vendor/'
) !==
false
24
|| strpos(
$normalized
,
'/dbx/vendor/'
) !==
false
) {
25
continue
;
26
}
27
$source
= file_get_contents($path);
28
foreach
(
$patterns
as $pattern) {
29
if
(is_string(
$source
) && preg_match($pattern,
$source
) === 1) {
30
$failures
[] = str_replace(
'\\'
,
'/'
, substr($path, strlen(
$root
) + 1));
31
break
;
32
}
33
}
34
}
35
36
if
(
$failures
) {
37
fwrite(STDERR,
"FAIL: Direkter DB-Treiberzugriff ausserhalb dbxDB: "
. implode(
', '
,
$failures
) .
"\n"
);
38
exit
(1);
39
}
40
41
echo
"OK dbxDB access boundary\n"
;
$allowed
$allowed
Definition
db_access_boundary_test.php:4
$iterator
$iterator
Definition
db_access_boundary_test.php:13
$patterns
$patterns
Definition
db_access_boundary_test.php:6
$root
$root
Definition
db_access_boundary_test.php:3
$failures
$failures
Definition
db_access_boundary_test.php:5
$source
$source
Definition
dbxCmsEditorPerformance_contract_test.php:4
exit
exit
Definition
index.php:146
$file
$file
Definition
shop_repository_request_cache_test.php:3
$normalized
$normalized
Definition
workflow_roundtrip_test.php:213
dbx
include
tests
db_access_boundary_test.php
Generated by
1.17.0