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/ABS/Base/Connectable.php (4 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\ABS\Base;
4
5
/*
6
 * This file is part of the PEIP package.
7
 * (c) 2009-2016 Timo Michna <timomichna/yahoo.de>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
/**
14
 * PEIP\ABS\Base\Connectable.
15
 *
16
 * @author Timo Michna <timomichna/yahoo.de>
17
 */
18
abstract class Connectable implements \PEIP\INF\Event\Connectable
19
{
20
    const
21
        DEFAULT_CLASS_MESSAGE_DISPATCHER = '\PEIP\Dispatcher\Dispatcher',
22
        DEFAULT_CLASS_EVENT_DISPATCHER = '\PEIP\Dispatcher\ObjectEventDispatcher',
23
        DEFAULT_EVENT_CLASS = '\PEIP\Event\Event',
24
        EVENT_CONNECT = 'connect',
25
        EVENT_DISCONNECT = 'disconnect',
26
        EVENT_SET_EVENT_DISPATCHER = 'setEventDispatcher',
27
        HEADER_DISPATCHER = 'DISPATCHER',
28
        HEADER_LISTENER = 'LISTENER',
29
        HEADER_EVENT = 'EVENT';
30
31
    protected static $sharedEventDispatcher;
32
33
    protected $eventDispatcher;
34
35
    /**
36
     * @param string                            $name
37
     * @param callable|PEIP\INF\Handler\Handler $listener
38
     *
39
     * @return
40
     */
41 View Code Duplication
    public function connect($name, $listener)
0 ignored issues
show
This method seems to be duplicated in 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...
42
    {
43
        \PEIP\Util\Test::ensureHandler($listener);
44
        $this->getEventDispatcher()->connect($name, $this, $listener);
45
        $this->doFireEvent(
46
            self::EVENT_CONNECT,
47
            [
48
                self::HEADER_EVENT    => $name,
49
                self::HEADER_LISTENER => $listener,
50
            ]
51
        );
52
    }
53
54
    /**
55
     * @param $name
56
     * @param callable|PEIP\INF\Handler\Handler $listener
57
     *
58
     * @return
59
     */
60 View Code Duplication
    public function disconnect($name, $listener)
0 ignored issues
show
This method seems to be duplicated in 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...
61
    {
62
        \PEIP\Util\Test::ensureHandler($listener);
63
        $this->getEventDispatcher()->disconnect($name, $this, $listener);
64
        $this->doFireEvent(
65
            self::EVENT_DISCONNECT,
66
            [
67
                self::HEADER_EVENT    => $name,
68
                self::HEADER_LISTENER => $listener,
69
            ],
70
            false,
0 ignored issues
show
false is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
71
            ''
0 ignored issues
show
'' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
72
73
        );
74
    }
75
76
    /**
77
     * @param $name
78
     *
79
     * @return
80
     */
81
    public function hasListeners($name)
82
    {
83
        return $this->getEventDispatcher()->hasListeners($name, $this);
84
    }
85
86
    /**
87
     * @param $name
88
     *
89
     * @return
90
     */
91
    public function getListeners($name)
92
    {
93
        return $this->getEventDispatcher()->getListeners($name, $this);
94
    }
95
96
    /**
97
     * @param $eventName
98
     * @param $callable
99
     *
100
     * @return
101
     */
102
    public function disconnectAll($name)
103
    {
104
        $this->getEventDispatcher()->disconnectAll($name, $this);
105
    }
106
107
    /**
108
     * @param $dispatcher
109
     * @param $transferListners
110
     *
111
     * @return
112
     */
113
    public function setEventDispatcher(\PEIP\Dispatcher\ObjectEventDispatcher $dispatcher, $transferListners = true)
114
    {
115
        if ($transferListners) {
116
            foreach ($this->getEventDispatcher()->getEventNames($this) as $name) {
117
                if ($this->getEventDispatcher()->hasListeners($name, $this)) {
118
                    foreach ($this->getEventDispatcher()->getListeners($name, $this) as $listener) {
119
                        $dispatcher->connect($name, $this, $listener);
120
                    }
121
                }
122
            }
123
        }
124
        $this->eventDispatcher = $dispatcher;
125
        $this->doFireEvent(self::EVENT_SET_EVENT_DISPATCHER, [self::HEADER_DISPATCHER => $dispatcher]);
126
    }
127
128
    /**
129
     * @return
130
     */
131
    public function getEventDispatcher()
132
    {
133
        return $this->eventDispatcher ? $this->eventDispatcher : $this->eventDispatcher = self::getSharedEventDispatcher();
134
    }
135
136
    protected static function getSharedEventDispatcher()
137
    {
138
        $defaultDispatcher = self::DEFAULT_CLASS_EVENT_DISPATCHER;
139
140
        return self::$sharedEventDispatcher ? self::$sharedEventDispatcher : self::$sharedEventDispatcher = new $defaultDispatcher();
141
    }
142
143
    /**
144
     * @param $name
145
     * @param $headers
146
     * @param $eventClass
147
     *
148
     * @return
149
     */
150
    protected function doFireEvent($name, array $headers = [], $eventClass = '', $type = false)
151
    {
152
        $eventClass = trim($eventClass) == '' ? static::DEFAULT_EVENT_CLASS : $eventClass;
153
154
        return $this->getEventDispatcher()->buildAndNotify($name, $this, $headers, $eventClass, $type);
155
    }
156
157
    protected static function getDefaultEventClass()
158
    {
159
        return self::DEFAULT_EVENT_CLASS;
160
    }
161
}
162