dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
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);
16foreach ($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
37 fwrite(STDERR, "FAIL: Direkter DB-Treiberzugriff ausserhalb dbxDB: " . implode(', ', $failures) . "\n");
38 exit(1);
39}
40
41echo "OK dbxDB access boundary\n";
exit
Definition index.php:146