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/Dispatcher/Dispatcher.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\Dispatcher;
4
5
namespace PEIP\Dispatcher;
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
 * Dispatcher
17
 * Basic dispatcher implementation
18
 *
19
 * @author Timo Michna <timomichna/yahoo.de>
20
 * @package PEIP
21
 * @subpackage dispatcher
22
 * @extends \PEIP\ABS\Dispatcher\Dispatcher
23
 * @implements \PEIP\INF\Dispatcher\Dispatcher
24
 */
25
26
use PEIP\Util\Test;
27
28
class Dispatcher extends \PEIP\ABS\Dispatcher\Dispatcher implements
29
        \PEIP\INF\Dispatcher\Dispatcher,
30
        \PEIP\INF\Base\Plugable
31
{
32
    protected $listeners = [];
33
34
    /**
35
     * Connects a listener.
36
     *
37
     * @param callable|PEIP\INF\Handler\Handler $listener
38
     *
39
     * @return void
40
     */
41
    public function connect($listener)
42
    {
43
        Test::ensureHandler($listener);
44
        $this->listeners[] = $listener;
45
    }
46
47
    /**
48
     * Disconnects a listener.
49
     *
50
     * @param callable|PEIP\INF\Handler\Handler $listener
51
     *
52
     * @return void
53
     */
54
    public function disconnect($listener)
55
    {
56
        Test::ensureHandler($listener);
57
        foreach ($this->listeners as $i => $callable) {
58
            if ($listener === $callable) {
59
                unset($this->listeners[$i]);
60
            }
61
        }
62
    }
63
64
    /**
65
     * Disconnects all listeners.
66
     *
67
     * @param callable|PEIP\INF\Handler\Handler $listener
0 ignored issues
show
There is no parameter named $listener. 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...
68
     *
69
     * @return void
70
     */
71
    public function disconnectAll()
72
    {
73
        $this->listeners = [];
74
    }
75
76
    /**
77
     * returns wether any listeners are registered.
78
     *
79
     * @return bool wether any listeners are registered
80
     */
81
    public function hasListeners()
82
    {
83
        return (bool) count($this->listeners);
84
    }
85
86
    /**
87
     * notifies all listeners on a subject.
88
     *
89
     * @param mixed $subject the subject
90
     *
91
     * @return void
92
     */
93 View Code Duplication
    public function notify($subject)
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...
94
    {
95
        $res = null;
96
        if ($this->hasListeners()) {
97
            $res = self::doNotify($this->getListeners(), $subject);
0 ignored issues
show
Are you sure the assignment to $res is correct as self::doNotify($this->getListeners(), $subject) (which targets PEIP\ABS\Dispatcher\Dispatcher::doNotify()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
98
        }
99
100
        return $res;
101
    }
102
103
    /**
104
     * notifies all listeners on a subject until one returns a boolean true value.
105
     *
106
     * @param mixed $subject the subject
107
     *
108
     * @return \PEIP\INF\Handler\Handler the listener which returned a boolean true value
109
     */
110
    public function notifyUntil($subject)
111
    {
112
        if ($this->hasListeners()) {
113
            $res = self::doNotifyUntil($this->getListeners(), $subject);
114
        }
115
116
        return $res;
0 ignored issues
show
The variable $res does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
117
    }
118
119
    /**
120
     * returns all listeners.
121
     *
122
     * @return array the listeners
123
     */
124
    public function getListeners()
125
    {
126
        return $this->listeners;
127
    }
128
}
129