Issues (29)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/WorkerChild.php (8 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php declare(strict_types=1);
2
3
namespace WyriHaximus\React\Cake\Orm;
4
5
use Cake\Cache\Cache;
6
use Cake\Core\Configure;
7
use Cake\Datasource\ConnectionManager;
8
use Cake\Datasource\Exception\PageOutOfBoundsException;
9
use Cake\Datasource\Paginator;
10
use Cake\ORM\Query;
11
use Cake\ORM\TableRegistry;
12
use React\EventLoop\LoopInterface;
13
use React\Promise\Deferred;
14
use function React\Promise\resolve;
15
use WyriHaximus\React\ChildProcess\Messenger\ChildInterface;
16
use WyriHaximus\React\ChildProcess\Messenger\Messages\Payload;
17
use WyriHaximus\React\ChildProcess\Messenger\Messenger;
18
use function WyriHaximus\React\futurePromise;
19
20
final class WorkerChild implements ChildInterface
21
{
22
    private $messenger;
23
    private $loop;
24
25
    /**
26
     * WorkerChild constructor.
27
     */
28
    public function __construct(Messenger $messenger, LoopInterface $loop)
29
    {
30
        $this->messenger = $messenger;
31
        $this->loop = $loop;
32
33
        $this->messenger->registerRpc('table.call', function (Payload $payload) {
34
            $deferred = new Deferred();
35
            $this->loop->futureTick(function () use ($payload, $deferred) {
36
                $this->handleTableCall($payload, $deferred);
37
            });
38
39
            return $deferred->promise();
40
        });
41
42
        $this->messenger->registerRpc('paginate', function (Payload $payload) {
43
            return futurePromise($this->loop, $payload)->then(function ($payload) {
44
                return $this->handlePaginateCall($payload);
45
            });
46
        });
47
    }
48
49
    /**
50
     * @inheritDoc
51
     */
52
    public static function create(Messenger $messenger, LoopInterface $loop)
53
    {
54
        require dirname(dirname(dirname(dirname(__DIR__)))) . '/config/paths.php';
55
        require CORE_PATH . 'config' . DS . 'bootstrap.php';
56
        Configure::config('default', new Configure\Engine\PhpConfig());
57
        Configure::load('app', 'default', false);
58
        Cache::setConfig(Configure::consume('Cache'));
0 ignored issues
show
It seems like \Cake\Core\Configure::consume('Cache') targeting Cake\Core\Configure::consume() can also be of type null; however, Cake\Core\StaticConfigTrait::setConfig() does only seem to accept string|array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
59
        ConnectionManager::setConfig(Configure::consume('Datasources'));
0 ignored issues
show
It seems like \Cake\Core\Configure::consume('Datasources') targeting Cake\Core\Configure::consume() can also be of type null; however, Cake\Datasource\ConnectionManager::setConfig() does only seem to accept string|array, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
60
61
        return new self($messenger, $loop);
62
    }
63
64
    /**
65
     * @param Payload  $payload
66
     * @param Deferred $deferred
67
     */
68
    protected function handleTableCall(Payload $payload, Deferred $deferred)
69
    {
70
        $result = call_user_func_array([
71
            TableRegistry::get(
0 ignored issues
show
Deprecated Code introduced by
The method Cake\ORM\TableRegistry::get() has been deprecated with message: 3.6.0 Use \Cake\ORM\Locator\TableLocator::get() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
72
                $payload['table']/*,
0 ignored issues
show
Unused Code Comprehensibility introduced by
68% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
73
                [
74
                    'className' => $payload['className'],
75
                    'table' => $payload['table'],
76
                ]*/
77
            ),
78
            $payload['function'],
79
        ], unserialize($payload['arguments']));
80
81
        if (!($result instanceof Query)) {
82
            $deferred->resolve([
83
                'result' => serialize($result),
84
            ]);
85
86
            return;
87
        }
88
89
        foreach ($result->all() as $row) {
90
            $deferred->notify([
0 ignored issues
show
Deprecated Code introduced by
The method React\Promise\Deferred::notify() has been deprecated with message: 2.6.0 Progress support is deprecated and should not be used anymore.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
91
                'row' => $row,
92
            ]);
93
        }
94
95
        $deferred->resolve();
96
    }
97
98
    /**
99
     * @param Payload  $payload
100
     * @param Deferred $deferred
0 ignored issues
show
There is no parameter named $deferred. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
101
     */
102
    protected function handlePaginateCall(Payload $payload)
103
    {
104
        $object = TableRegistry::get(
0 ignored issues
show
Deprecated Code introduced by
The method Cake\ORM\TableRegistry::get() has been deprecated with message: 3.6.0 Use \Cake\ORM\Locator\TableLocator::get() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
105
            $payload['table']/*,
0 ignored issues
show
Unused Code Comprehensibility introduced by
68% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
106
                [
107
                    'className' => $payload['className'],
108
                    'table' => $payload['table'],
109
                ]*/
110
        );
111
        $paginator = new Paginator();
112
113
        try {
114
            $items = $paginator->paginate($object, $payload['params'], $payload['settings'])->toArray();
115
            $eos = false;
116
        } catch (PageOutOfBoundsException $pageOutOfBoundsException) {
117
            $items = [];
118
            $eos = true;
119
        }
120
121
        return resolve([
122
            'items' => $items,
123
            'eos' => $eos,
124
            'pagingParams' => $paginator->getPagingParams(),
125
        ]);
126
    }
127
}
128