Issues (183)

Security Analysis    not enabled

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/Queue/Channel/Settings.php (2 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
namespace FMUP\Queue\Channel;
3
4
use FMUP\Queue\Exception as QueueException;
5
6
/**
7
 * Class Settings - Global channel settings
8
 * @package FMUP\Queue\Channel
9
 */
10
class Settings
11
{
12
    //(int) in bytes (default system)
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% 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...
13
    const PARAM_MAX_MESSAGE_SIZE = 'PARAM_MAX_MESSAGE_SIZE';
14
    //(int) max send retry time, default DEFAULT_RETRY_TIMES
15
    const PARAM_MAX_SEND_RETRY_TIME = 'PARAM_MAX_SEND_RETRY_TIME';
16
    const PARAM_CONSUMER_NAME = 'PARAM_CONSUMER_NAME';//(string) define consumer name - default empty
17
18
    //(bool) if process must wait to be sure the message is sent (default false)
19
    const PARAM_BLOCK_SEND = 'PARAM_BLOCK_SEND';
20
    //(bool) process will be blocked while no message is received (default false)
21
    const PARAM_BLOCK_RECEIVE = 'PARAM_BLOCK_RECEIVE';
22
    //(bool) must serialize a message (default true)
23
    const PARAM_SERIALIZE = 'PARAM_SERIALIZE';
24
    const PARAM_AUTO_ACK = 'PARAM_AUTO_ACK'; //(bool) must ack a message as soon as it is retrieved (default false)
25
26
    const DEFAULT_RETRY_TIMES = 3;
27
28
    const FLAG_BLOCK_SEND = 1;
29
    const FLAG_BLOCK_RECEIVE = 2;
30
    const FLAG_SERIALIZE = 4;
31
    const FLAG_AUTO_ACK = 8;
32
33
    private $settings = array();
34
    private $consumerName = '';
35
    private $flags = self::FLAG_SERIALIZE;
36
37
    /**
38
     * @param array $settings
39
     */
40 14
    public function __construct(array $settings = array())
41
    {
42 14
        $this->defineByArray($settings);
43 12
    }
44
45
    /**
46
     * Define multiple settings by a single array
47
     * @param array $settings
48
     * @return $this
49
     * @throws QueueException
50
     */
51 14
    public function defineByArray(array $settings)
52
    {
53 14
        foreach ($settings as $setting => $value) {
54 4
            $this->define($setting, $value);
55
        }
56 12
        return $this;
57
    }
58
59
    /**
60
     * Define a single setting by its name
61
     * @param string $setting
62
     * @param mixed $value
63
     * @return $this
64
     * @throws QueueException
65
     */
66 3
    public function define($setting, $value)
67
    {
68
        switch ($setting) {
69 3
            case self::PARAM_MAX_MESSAGE_SIZE:
70 1
                $this->setMaxMessageSize($value);
71 1
                break;
72 3
            case self::PARAM_BLOCK_SEND:
73 1
                $this->setBlockSend($value);
74 1
                break;
75 3
            case self::PARAM_SERIALIZE:
76 1
                $this->setSerialize($value);
77 1
                break;
78 3
            case self::PARAM_BLOCK_RECEIVE:
79 1
                $this->setBlockReceive($value);
80 1
                break;
81 3
            case self::PARAM_MAX_SEND_RETRY_TIME:
82 1
                $this->setMaxSendRetryTime($value);
83 1
                break;
84 3
            case self::PARAM_AUTO_ACK:
85 1
                $this->setAutoAck($value);
86 1
                break;
87 3
            case self::PARAM_CONSUMER_NAME:
88 1
                $this->setConsumerName($value);
89 1
                break;
90
            default:
91 2
                throw new QueueException('Setting is not defined');
92
                break;
0 ignored issues
show
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
93
        }
94 1
        return $this;
95
    }
96
97
    /**
98
     * Define consumer name
99
     * @param string $consumerName
100
     * @return $this
101
     */
102 1
    public function setConsumerName($consumerName = '')
103
    {
104 1
        $this->consumerName = (string)$consumerName;
105 1
        return $this;
106
    }
107
108
    /**
109
     * Retrieve defined consumer name
110
     * @return string
111
     */
112 1
    public function getConsumerName()
113
    {
114 1
        return (string)$this->consumerName;
115
    }
116
117
    /**
118
     * Define max message size (default system)
119
     * @param int $size
120
     * @return $this
121
     */
122 4
    public function setMaxMessageSize($size = 0)
123
    {
124 4
        $this->settings[self::PARAM_MAX_MESSAGE_SIZE] = (int)$size;
125 4
        return $this;
126
    }
127
128
    /**
129
     * Get max message size (default system)
130
     * @return int
131
     */
132 3
    public function getMaxMessageSize()
133
    {
134 3
        return isset($this->settings[self::PARAM_MAX_MESSAGE_SIZE])
135 3
            ? (int)$this->settings[self::PARAM_MAX_MESSAGE_SIZE]
136 3
            : 0;
137
    }
138
139
    /**
140
     * Define if process must wait to be sure the message is sent (default false)
141
     * @param bool|false $blockSend
142
     * @return $this
143
     */
144 3
    public function setBlockSend($blockSend = false)
145
    {
146 3
        $this->flags = ($blockSend) ? $this->flags | self::FLAG_BLOCK_SEND : $this->flags & ~self::FLAG_BLOCK_SEND;
147 3
        return $this;
148
    }
149
150
    /**
151
     * Get if process must wait to be sure the message is sent (default false)
152
     * @return bool
153
     */
154 3
    public function getBlockSend()
155
    {
156 3
        return (bool)($this->flags & self::FLAG_BLOCK_SEND);
157
    }
158
159
    /**
160
     * Define if process must serialize a message (default true)
161
     * @param bool|true $serialize
162
     * @return $this
163
     */
164 3
    public function setSerialize($serialize = true)
165
    {
166 3
        $this->flags = ($serialize) ? $this->flags | self::FLAG_SERIALIZE : $this->flags & ~self::FLAG_SERIALIZE;
167 3
        return $this;
168
    }
169
170
    /**
171
     * Get if process must serialize a message (default true)
172
     * @return bool
173
     */
174 5
    public function getSerialize()
175
    {
176 5
        return (bool)($this->flags & self::FLAG_SERIALIZE);
177
    }
178
179
    /**
180
     * Define if process will be blocked while no message is received (default false)
181
     * @param bool|false $blockReceive
182
     * @return $this
183
     */
184 3
    public function setBlockReceive($blockReceive = false)
185
    {
186 3
        $this->flags = ($blockReceive)
187 2
            ? $this->flags | self::FLAG_BLOCK_RECEIVE
188 2
            : $this->flags & ~self::FLAG_BLOCK_RECEIVE;
189 3
        return $this;
190
    }
191
192
    /**
193
     * Get if process will be blocked while no message is received (default false)
194
     * @return bool
195
     */
196 3
    public function getBlockReceive()
197
    {
198 3
        return (bool)($this->flags & self::FLAG_BLOCK_RECEIVE);
199
    }
200
201
    /**
202
     * Define if message are auto ack-ed (default false)
203
     * @param bool|false $autoAck
204
     * @return $this
205
     */
206 2
    public function setAutoAck($autoAck = false)
207
    {
208 2
        $this->flags = ($autoAck) ? $this->flags | self::FLAG_AUTO_ACK : $this->flags & ~self::FLAG_AUTO_ACK;
209 2
        return $this;
210
    }
211
212
    /**
213
     * Get if message are auto acked on this channel
214
     * @return bool
215
     */
216 1
    public function getAutoAck()
217
    {
218 1
        return (bool)($this->flags & self::FLAG_AUTO_ACK);
219
    }
220
221
    /**
222
     * Define max send retry time, default DEFAULT_RETRY_TIMES
223
     * @param int $maxRetry
224
     * @return $this
225
     */
226 3
    public function setMaxSendRetryTime($maxRetry = 0)
227
    {
228 3
        $this->settings[self::PARAM_MAX_SEND_RETRY_TIME] = (int)$maxRetry;
229 3
        return $this;
230
    }
231
232
    /**
233
     * Get max message size (default system)
234
     * @return int
235
     */
236 3
    public function getMaxSendRetryTime()
237
    {
238 3
        return isset($this->settings[self::PARAM_MAX_SEND_RETRY_TIME])
239 3
            ? (int)$this->settings[self::PARAM_MAX_SEND_RETRY_TIME]
240 3
            : self::DEFAULT_RETRY_TIMES;
241
    }
242
}
243