dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxActionTokenUsageAudit_test.php
Go to the documentation of this file.
1<?php
2
3$root = dirname(__DIR__, 2);
4$modulesRoot = $root . '/modules';
5
6$fail = static function (string $message, int $code): void {
7 fwrite(STDERR, "FAIL: $message\n");
8 exit($code);
9};
10
19 'dbxAdmin/include/dbxUser.class.php' =>
20 'verify, lock, unlock und reset_password mit RID',
21 'dbxContent_admin/include/dbxContent_cms.class.php' =>
22 'CMS-JSON, Upload, Medien- und Sprachaktionen',
23 'dbxContent_admin/include/dbxContent_seo.class.php' =>
24 'SEO-JSON und gemeinsam genutzte CMS-Medienendpunkte',
25 'dbxKi/include/dbxKiCmsService.class.php' =>
26 'zweistufige plan/execute-API mit expliziter Bestaetigung',
27 'dbxLogin/include/login.class.php' =>
28 'Tokenausgabe fuer erneuten Versand der Registrierung',
29 'dbxLogin/include/register.class.php' =>
30 'Tokenpruefung fuer erneuten Versand der Registrierung',
31 'dbxSetup/include/dbxInstall.class.php' =>
32 'zustandsgebundene Schritte des Erstinstallationsassistenten',
33 'dbxSelfTest/include/dbxSelfTestController.class.php' =>
34 'JSON-Testorchestrierung mit eigenem, admininternem Aktionsscope',
35 'dbxShop_admin/include/dbxShopAdmin.class.php' =>
36 'Shop-Sammel-, Medien-, Installations- und Statusaktionen',
37 'dbxWorkflow/include/dbxWorkflowEngine.class.php' =>
38 'Workflow-Start und instanzgebundene Prozesskommandos',
39 'dbxWorkflow_admin/include/dbxWorkflowAdmin.class.php' =>
40 'Erzeugung instanzgebundener Workflow-Fortsetzungslinks',
41);
42
43$calls = array('action_token', 'check_action_token');
44$iterator = new RecursiveIteratorIterator(
45 new RecursiveDirectoryIterator($modulesRoot, FilesystemIterator::SKIP_DOTS)
46);
47
48foreach ($iterator as $file) {
49 if (!$file->isFile() || strtolower($file->getExtension()) !== 'php') {
50 continue;
51 }
52
53 $path = str_replace('\\', '/', $file->getPathname());
54 if (strpos($path, '/tests/') !== false) {
55 continue;
56 }
57
58 $relative = ltrim(substr($path, strlen(str_replace('\\', '/', $modulesRoot))), '/');
59 $source = (string)file_get_contents($file->getPathname());
60 $tokens = token_get_all($source);
61 $found = array();
62
63 foreach ($tokens as $token) {
64 if (!is_array($token) || $token[0] !== T_STRING) {
65 continue;
66 }
67 $name = strtolower((string)$token[1]);
68 if (in_array($name, $calls, true)) {
69 $found[$name] = true;
70 }
71 }
72
73 if ($found && !isset($manualScopeAllowlist[$relative])) {
74 $fail(
75 'Nicht dokumentierte manuelle Action-Token-Logik in ' . $relative
76 . ': ' . implode(', ', array_keys($found)),
77 1
78 );
79 }
80
81 if (strpos($source, 'enable_delete_tab(') !== false
82 && isset($found['check_action_token'])) {
83 $fail(
84 'dbxReport delete_tab wird in ' . $relative
85 . ' zusaetzlich im Modul geprueft.',
86 2
87 );
88 }
89}
90
91foreach ($manualScopeAllowlist as $relative => $reason) {
92 $file = $modulesRoot . '/' . $relative;
93 if (!is_file($file)) {
94 $fail('Dokumentierte Token-Ausnahme fehlt: ' . $relative, 3);
95 }
96}
97
98$formSource = (string)file_get_contents($root . '/include/dbxForm.class.php');
99if (strpos($formSource, 'substr($secure') !== false
100 || strpos($formSource, 'substr($posted') !== false) {
101 $fail('dbxForm protokolliert weiterhin Teile eines Security-Tokens.', 4);
102}
103
104echo 'OK dbx action token usage audit ('
105 . count($manualScopeAllowlist)
106 . " documented exceptions)\n";
$manualScopeAllowlist
Bewusste Ausnahmen vom zentralen Standardweg.
foreach( $iterator as $file) foreach($manualScopeAllowlist as $relative=> $reason) $formSource
exit
Definition index.php:146