Issues (25)

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/AppserverIo/Collections/IdentityDictionary.php (3 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
/**
4
 * \AppserverIo\Collections\IdentityDictionary
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/collections
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Collections;
22
23
use AppserverIo\Lang\NullPointerException;
24
25
/**
26
 * This class is the implementation of a Dictionary.
27
 *
28
 * A dictionary uses objects as keys instead of integers
29
 * like a HashMap.
30
 *
31
 * @author    Tim Wagner <[email protected]>
32
 * @copyright 2015 TechDivision GmbH <[email protected]>
33
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
34
 * @link      https://github.com/appserver-io/collections
35
 * @link      http://www.appserver.io
36
 */
37
class IdentityDictionary extends Dictionary
38
{
39
40
    /**
41
     * This method returns the element that has the passed
42
     * key as a reference (has to be an object) from the
43
     * Dictionary.
44
     *
45
     * @param object $key Holds the key to the key of the element to return
46
     *
47
     * @return mixed The requested value
48
     * @throws \AppserverIo\Collections\InvalidKeyException Is thrown if the passed key is NOT an object
49
     * @throws \AppserverIo\Lang\NullPointerException Is thrown if the passed key OR value are NULL
50
     * @throws \AppserverIo\Collections\IndexOutOfBoundsException Is thrown if no element with the passed key exists in the Dictionary
51
     */
52 View Code Duplication
    public function get($key)
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...
53
    {
54
        if (is_null($key)) {
55
            throw new NullPointerException('Passed key is null');
56
        }
57
        if (!is_object($key)) {
58
            throw new InvalidKeyException('Passed key has to be an object');
59
        }
60
        // run over all keys and check if one is equal to the passed one
61
        foreach ($this->keys as $id => $value) {
62
            // if the actual is equal to the passed key ..
63
            if ($key === $value) {
64
                // return the item with the passed key
65
                if (array_key_exists($id, $this->items)) {
66
                    return $this->items[$id];
67
                }
68
            }
69
        }
70
        // if no value is found throw an exception
71
        throw new IndexOutOfBoundsException('Index out of bounds');
72
    }
73
74
    /**
75
     * This method checks if the element that has the passed
76
     * key as a reference (has to be an object) exists in
77
     * the Dictionary.
78
     *
79
     * @param object $key Holds the reference to the key of the element that should exists in the Dictionary
80
     *
81
     * @return boolean Returns TRUE if an element with the passed key exists in the Dictionary
82
     * @throws \AppserverIo\Collections\InvalidKeyException Is thrown if the passed key is NOT an object
83
     * @throws \AppserverIo\Lang\NullPointerException Is thrown if the passed key is NULL
84
     */
85 View Code Duplication
    public function exists($key)
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...
86
    {
87
        if (is_null($key)) {
88
            throw new NullPointerException('Passed key is null');
89
        }
90
        if (! is_object($key)) {
91
            throw new InvalidKeyException('Passed key has to be an object');
92
        }
93
        // run over all keys and check if one is equal to the passed one
94
        foreach ($this->keys as $id => $value) {
95
            // if the actual is equal to the passed key ..
96
            if ($key === $value) {
97
                // return TRUE if the key is found
98
                return true;
99
            }
100
        }
101
        // return FALSE if the key is not found
102
        return false;
103
    }
104
105
    /**
106
     * This method removes the element that has the passed
107
     * key as a reference (has to be an object) from the
108
     * Dictionary.
109
     *
110
     * @param object $key Holds the reference of the key of the element to remove
111
     *
112
     * @return void
113
     * @throws \AppserverIo\Collections\InvalidKeyException Is thrown if the passed key is NOT an object
114
     * @throws \AppserverIo\Lang\NullPointerException Is thrown if the passed key is NULL
115
     * @throws \AppserverIo\Collections\IndexOutOfBoundsException Is thrown if no element with the passed key exists in the Dictionary
116
     */
117 View Code Duplication
    public function remove($key)
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...
118
    {
119
        if (is_null($key)) {
120
            throw new NullPointerException('Passed key is null');
121
        }
122
        if (! is_object($key)) {
123
            throw new InvalidKeyException('Passed key has to be an object');
124
        }
125
        // run over all keys and check if one is a reference of the passed one
126
        foreach ($this->keys as $id => $value) {
127
            // if the actual is equal to the passed key ..
128
            if ($key === $value) {
129
                // unset the elements
130
                unset($this->items[$id]);
131
                unset($this->keys[$id]);
132
                return;
133
            }
134
        }
135
        // throw an exception if key is not found in internal array
136
        throw new IndexOutOfBoundsException('Index out of bounds');
137
    }
138
}
139