Issues (150)

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/Pipe/Pipe.php (6 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
2
3
namespace PEIP\Pipe;
4
5
namespace PEIP\Pipe;
6
7
/*
8
 * This file is part of the PEIP package.
9
 * (c) 2009-2016 Timo Michna <timomichna/yahoo.de>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
/*
16
 * Pipe
17
 *
18
 * @author Timo Michna <timomichna/yahoo.de>
19
 * @package PEIP
20
 * @subpackage pipe
21
 * @extends \PEIP\ABS\Handler\ReplyProducingMessageHandler
22
 * @implements \PEIP\INF\Message\MessageBuilder, \PEIP\INF\Handler\Handler, \PEIP\INF\Channel\Channel, \PEIP\INF\Channel\SubscribableChannel, \PEIP\INF\Event\Connectable
23
 */
24
25
use PEIP\Util\Test;
26
27
class Pipe extends \PEIP\ABS\Handler\ReplyProducingMessageHandler implements
28
        \PEIP\INF\Channel\Channel,
29
        \PEIP\INF\Channel\SubscribableChannel,
30
        \PEIP\INF\Event\Connectable,
31
        \PEIP\INF\Message\MessageBuilder
32
{
33
    const
34
        DEFAULT_CLASS_MESSAGE_DISPATCHER = 'PEIP\Dispatcher\Dispatcher',
35
        DEFAULT_EVENT_CLASS = 'PEIP\Event\Event',
36
        EVENT_PRE_PUBLISH = 'prePublish',
37
        EVENT_POST_PUBLISH = 'postPublish',
38
        EVENT_SUBSCRIBE = 'subscribe',
39
        EVENT_UNSUBSCRIBE = 'unsubscribe',
40
        EVENT_PRE_COMMAND = 'preCommand',
41
        EVENT_POST_COMMAND = 'postCommand',
42
        EVENT_SET_MESSAGE_DISPATCHER = 'setMessageDispatcher',
43
        EVENT_SET_EVENT_DISPATCHER = 'setEventDispatcher',
44
        HEADER_MESSAGE = 'MESSAGE',
45
        HEADER_SUBSCRIBER = 'SUBSCRIBER';
46
47
    protected $eventDispatcher,
48
        $messageDispatcher,
49
        $name,
50
        $commands = [];
51
52
    /**
53
     * @param $name
54
     *
55
     * @return
56
     */
57
    public function setName($name)
58
    {
59
        $this->name = $name;
60
    }
61
62
    /**
63
     * @return
64
     */
65
    public function getName()
66
    {
67
        return $this->name;
68
    }
69
70
    /**
71
     * @param $message
72
     * @param $timeout
73
     *
74
     * @return
75
     */
76
    public function send(\PEIP\INF\Message\Message $message, $timeout = -1)
77
    {
78
        return $this->handle($message);
79
    }
80
81
    /**
82
     * @param $message
83
     *
84
     * @return
85
     */
86
    protected function doSend(\PEIP\INF\Message\Message $message)
87
    {
88
        $this->doFireEvent(self::EVENT_PRE_PUBLISH, [self::HEADER_MESSAGE => $message]);
89
        $this->getMessageDispatcher()->notify($message);
90
        $this->doFireEvent(self::EVENT_POST_PUBLISH, [self::HEADER_MESSAGE => $message]);
91
92
        return true;
93
    }
94
95
    /**
96
     * @param $content
97
     *
98
     * @return
99
     */
100
    protected function replyMessage($message)
101
    {
102
        $message = $this->ensureMessage($message);
103
        //if(\PEIP\Util\Test::assertMessage($message)){
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% 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...
104
            if ($this->getOutputChannel()) {
105
                $this->getOutputChannel()->send($message);
106
            } else {
107
                $this->doSend($message);
108
            }
109
        //}
110
    }
111
112
    /**
113
     * @param $message
114
     *
115
     * @return
116
     */
117
    protected function doReply(\PEIP\INF\Message\Message $message)
118
    {
119
        $this->replyMessage($message);
120
    }
121
122
    /**
123
     * @param $handler
124
     *
125
     * @return
126
     */
127
    public function subscribe($handler)
128
    {
129
        Test::ensureHandler($handler);
130
        $this->getMessageDispatcher()->connect($handler);
131
        $this->doFireEvent(self::EVENT_SUBSCRIBE, [self::HEADER_SUBSCRIBER => $handler]);
132
    }
133
134
    /**
135
     * @param $handler e
136
     *
137
     * @return
138
     */
139
    public function unsubscribe($handler)
140
    {
141
        Test::ensureHandler($handler);
142
        $this->getMessageDispatcher()->disconnect($handler);
143
        $this->doFireEvent(
144
            self::EVENT_UNSUBSCRIBE,
145
            [
146
                self::HEADER_SUBSCRIBER => $handler,
147
            ]
148
        );
149
    }
150
151
    /**
152
     * @param $dispatcher
153
     * @param $transferListeners
154
     *
155
     * @return
156
     */
157
    public function setMessageDispatcher(\PEIP\INF\Dispatcher\Dispatcher $dispatcher, $transferListeners = true)
158
    {
159 View Code Duplication
        if (isset($this->dispatcher) && $transferListeners) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
160
            foreach ($this->dispatcher->getListeners() as $listener) {
0 ignored issues
show
The property dispatcher does not seem to exist. Did you mean eventDispatcher?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
161
                $dispatcher->connect($listener);
162
                $this->dispatcher->disconnect($listener);
0 ignored issues
show
The property dispatcher does not seem to exist. Did you mean eventDispatcher?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
163
            }
164
        }
165
        $this->dispatcher = $dispatcher;
0 ignored issues
show
The property dispatcher does not seem to exist. Did you mean eventDispatcher?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
166
        $this->doFireEvent(self::EVENT_SET_MESSAGE_DISPATCHER, [self::HEADER_DISPATCHER => $dispatcher]);
167
    }
168
169
    /**
170
     * @return
171
     */
172
    public function getMessageDispatcher()
173
    {
174
        $defaultDispatcher = self::DEFAULT_CLASS_MESSAGE_DISPATCHER;
175
176
        return isset($this->dispatcher) ? $this->dispatcher : $this->dispatcher = new $defaultDispatcher();
0 ignored issues
show
The property dispatcher does not seem to exist. Did you mean eventDispatcher?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
177
    }
178
179
    /**
180
     * @param string $commandName
181
     * @param $callable
182
     *
183
     * @return
184
     */
185
    protected function registerCommand($commandName, $callable)
186
    {
187
        $this->commands[$commandName] = $callable;
188
    }
189
190
    /**
191
     * @param $cmdMessage
192
     *
193
     * @return
194
     */
195
    public function command(\PEIP\INF\Message\Message $cmdMessage)
196
    {
197
        $this->doFireEvent(self::EVENT_PRE_COMMAND, [self::HEADER_MESSAGE => $cmdMessage]);
198
        $commandName = trim((string) $cmdMessage->getHeader('COMMAND'));
199
        if ($commandName != '' && array_key_exists($commandName, $this->commands)) {
200
            call_user_func($this->commands[$commandName], $cmdMessage->getContent());
201
        }
202
        $this->doFireEvent(self::EVENT_POST_COMMAND, [self::HEADER_MESSAGE => $cmdMessage]);
203
    }
204
}
205