dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxApi_security_test.php
Go to the documentation of this file.
1<?php
2
3require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
4require_once dirname(__DIR__) . '/dbxKernel.php';
5
6$fail = static function (string $message, int $code): void {
7 fwrite(STDERR, "FAIL: $message\n");
8 exit($code);
9};
10
11$password = dbx()->new_password(96, '-_!');
12if (strlen($password) !== 96 || preg_match('/^[a-zA-Z0-9_!\-]+$/', $password) !== 1) {
13 $fail('new_password() liefert keine gueltige Laenge oder Zeichenmenge.', 1);
14}
15
16$webAppFile = dirname(__DIR__) . '/dbxWebApp.class.php';
17$webAppSource = file_get_contents($webAppFile);
18if (!is_string($webAppSource) || preg_match('/\\blogin\\s*\\(\\s*2\\s*\\)/', $webAppSource) === 1) {
19 $fail('Ein Request-Parameter kann weiterhin den API-Benutzer anmelden.', 2);
20}
21
22$loadConfig = static function (string $file): array {
23 $config = array();
24 require $file;
25 return is_array($config) ? $config : array();
26};
27$baseFile = dirname(__DIR__, 2) . '/modules/dbx/cfg/config.php';
28$localFile = dirname(__DIR__, 2) . '/modules/dbx/cfg/config.local.php';
30$local = is_file($localFile) ? $loadConfig($localFile) : array();
31
33 array('db', 'dbxApp', 'pass'),
34 array('db', 'dbxTestCodex', 'pass'),
35 array('ftp', 'web', 'sftp_pass'),
36 array('mail', 'dbxApp', 'pass'),
37);
38$readPath = static function (array $data, array $path) {
39 foreach ($path as $part) {
40 if (!is_array($data) || !array_key_exists($part, $data)) {
41 return null;
42 }
43 $data = $data[$part];
44 }
45 return $data;
46};
47
48foreach ($secretPaths as $path) {
49 if ((string)$readPath($base, $path) !== '') {
50 $fail('Ein Geheimnis steht weiterhin in der versionierten config.php.', 3);
51 }
52}
53
54if ($local) {
55 $runtime = dbx()->get_config('dbx');
56 foreach ($secretPaths as $path) {
57 $localValue = $readPath($local, $path);
58 if ($localValue !== null && $readPath($runtime, $path) !== $localValue) {
59 $fail('config.local.php wird nicht korrekt ueber die Basis gelegt.', 4);
60 }
61 }
62}
63
64echo "OK dbxApi security\n";
if(substr_count($sessionSource, 'dbx() ->invalidate_action_tokens();')< 2) $webAppSource
if($resolved !==$expectedBase . 'files/test/') $config
if(!is_string($webAppSource)||preg_match('/\\blogin\\s *\\‍(\\s *2\\s *\\‍)/', $webAppSource)===1 $loadConfig)
if(strlen($password) !==96||preg_match('/^ $webAppFile[a-zA-Z0-9_!\-]+$/', $password) !==1)
exit
Definition index.php:146
DBX schema administration.