Issues (201)

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/Api/Server/ServerCollection.php (1 issue)

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
 * This file is part of the puli/manager package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Manager\Api\Server;
13
14
use ArrayAccess;
15
use ArrayIterator;
16
use Countable;
17
use IteratorAggregate;
18
use LogicException;
19
20
/**
21
 * A collection of {@link Server} instances.
22
 *
23
 * @since  1.0
24
 *
25
 * @author Bernhard Schussek <[email protected]>
26
 */
27
class ServerCollection implements IteratorAggregate, ArrayAccess, Countable
28
{
29
    /**
30
     * @var Server[]
31
     */
32
    private $servers = array();
33
34
    /**
35
     * Creates the collection.
36
     *
37
     * @param Server[] $servers The servers to initially fill into the
38
     *                          collection.
39
     */
40 147
    public function __construct(array $servers = array())
41
    {
42 147
        $this->merge($servers);
43 147
    }
44
45
    /**
46
     * Adds a server to the collection.
47
     *
48
     * @param Server $server The server to add.
49
     */
50 126
    public function add(Server $server)
51
    {
52 126
        $this->servers[$server->getName()] = $server;
53 126
    }
54
55
    /**
56
     * Returns the server with the given name.
57
     *
58
     * @param string $serverName The server name.
59
     *
60
     * @return Server The server.
61
     *
62
     * @throws NoSuchServerException If the server does not exist.
63
     */
64 22
    public function get($serverName)
65
    {
66 22
        if (!isset($this->servers[$serverName])) {
67 3
            throw NoSuchServerException::forServerName($serverName);
68
        }
69
70 19
        return $this->servers[$serverName];
71
    }
72
73
    /**
74
     * Removes a server from the collection.
75
     *
76
     * If the server does not exist, this method does nothing.
77
     *
78
     * @param string $serverName The server name.
79
     */
80 15
    public function remove($serverName)
81
    {
82 15
        unset($this->servers[$serverName]);
83 15
    }
84
85
    /**
86
     * Returns whether a server exists.
87
     *
88
     * @param string $serverName The server name.
89
     *
90
     * @return bool Whether the server exists.
91
     */
92 31
    public function contains($serverName)
93
    {
94 31
        return isset($this->servers[$serverName]);
95
    }
96
97
    /**
98
     * Removes all servers from the collection.
99
     */
100 9
    public function clear()
101
    {
102 9
        $this->servers = array();
103 9
    }
104
105
    /**
106
     * Returns the names of all servers in the collection.
107
     *
108
     * @return string[] The server names.
0 ignored issues
show
Should the return type not be integer[]?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
109
     */
110 1
    public function getServerNames()
111
    {
112 1
        return array_keys($this->servers);
113
    }
114
115
    /**
116
     * Replaces the collection contents with the given servers.
117
     *
118
     * @param Server[] $servers The install servers to set.
119
     */
120 7
    public function replace(array $servers)
121
    {
122 7
        $this->clear();
123 7
        $this->merge($servers);
124 7
    }
125
126
    /**
127
     * Merges the given servers into the collection.
128
     *
129
     * @param Server[] $servers The install servers to add.
130
     */
131 147
    public function merge(array $servers)
132
    {
133 147
        foreach ($servers as $server) {
134 76
            $this->add($server);
135
        }
136 147
    }
137
138
    /**
139
     * Returns whether the collection is empty.
140
     *
141
     * @return bool Returns `true` if the collection contains no servers and
142
     *              `false` otherwise.
143
     */
144 5
    public function isEmpty()
145
    {
146 5
        return 0 === count($this->servers);
147
    }
148
149
    /**
150
     * Returns the collection contents as array.
151
     *
152
     * @return Server[] The servers in the collection indexed by their
153
     *                  names.
154
     */
155 36
    public function toArray()
156
    {
157 36
        return $this->servers;
158
    }
159
160
    /**
161
     * {@inheritdoc}
162
     */
163 1
    public function offsetExists($serverName)
164
    {
165 1
        return $this->contains($serverName);
166
    }
167
168
    /**
169
     * {@inheritdoc}
170
     */
171 1
    public function offsetGet($serverName)
172
    {
173 1
        return $this->get($serverName);
174
    }
175
176
    /**
177
     * {@inheritdoc}
178
     */
179 2
    public function offsetSet($key, $server)
180
    {
181 2
        if (null !== $key) {
182 1
            throw new LogicException('Keys are not accepted when setting a value by array access.');
183
        }
184
185 1
        $this->add($server);
186 1
    }
187
188
    /**
189
     * {@inheritdoc}
190
     */
191 1
    public function offsetUnset($serverName)
192
    {
193 1
        $this->remove($serverName);
194 1
    }
195
196
    /**
197
     * {@inheritdoc}
198
     */
199 47
    public function getIterator()
200
    {
201 47
        return new ArrayIterator($this->servers);
202
    }
203
204
    /**
205
     * {@inheritdoc}
206
     */
207 1
    public function count()
208
    {
209 1
        return count($this->servers);
210
    }
211
}
212