dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
workflow_security_test.php
Go to the documentation of this file.
1<?php
2
3$root = dirname(__DIR__);
4$engineFile = $root . '/include/dbxWorkflowEngine.class.php';
5$adminFile = dirname(__DIR__, 2) . '/dbxWorkflow_admin/include/dbxWorkflowAdmin.class.php';
6$engine = file_get_contents($engineFile);
7$admin = file_get_contents($adminFile);
8
9$fail = static function (string $message, int $code): void {
10 fwrite(STDERR, "FAIL: $message\n");
11 exit($code);
12};
13
14if (!is_string($engine) || !is_string($admin)) {
15 $fail('Workflow-Quellen konnten nicht gelesen werden.', 1);
16}
17
18if (strpos($engine, "check_action_token('dbxWorkflow.start'") === false
19 || strpos($engine, 'has_instance_action_token($iid)') === false) {
20 $fail('Start- oder Instanzmutationen sind nicht mit dbx_token abgesichert.', 2);
21}
22
23if (strpos($engine, 'guest_can_access_instance($iid)') === false
24 || !preg_match('/select\\(\\$this->ddInstance,[\\s\\S]*?,\\s*1\\s*\\);/', $engine)) {
25 $fail('Instanzzugriffe nutzen weder Gast-Sessionbindung noch DD-Pruefung.', 3);
26}
27
28if (substr_count($engine, '$db->begin($this->ddInstance)') < 3
29 || substr_count($engine, '$db->rollback($this->ddInstance)') < 3
30 || substr_count($engine, '$db->commit($this->ddInstance)') < 3) {
31 $fail('Workflow-Schritt, Automation und Abschluss sind nicht vollstaendig atomar.', 4);
32}
33
34if (strpos($engine, "'status' => 'finishing'") === false
35 || strpos($engine, "(int)\$db->_update_count !== 1") === false) {
36 $fail('Der externe Abschluss wird nicht atomar gegen Wiederholung beansprucht.', 5);
37}
38
39if (preg_match("/\\\\\$nextUrl\\s*\\.\\s*'&proc_cmd=/", $engine) === 1
40 || strpos($admin, "action_token('dbxWorkflow.instance.' . \$id)") === false) {
41 $fail('Ein zustandsaendernder Workflow-GET-Link wird noch ohne Token erzeugt.', 6);
42}
43
44echo "OK workflow security\n";
exit
Definition index.php:146