Issues (1507)

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.

PHPDaemon/Clients/IRC/Channel.php (6 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 PHPDaemon\Clients\IRC;
3
4
use PHPDaemon\Structures\ObjectStorage;
5
use PHPDaemon\Utils\IRC;
6
7
/**
8
 * @package    NetworkClients
9
 * @subpackage IRCClient
10
 * @author     Vasily Zorin <[email protected]>
11
 */
12
class Channel extends ObjectStorage
13
{
14
    use \PHPDaemon\Traits\EventHandlers;
15
16
    /**
17
     * @var Connection
18
     */
19
    public $irc;
20
21
    /**
22
     * @var string
23
     */
24
    public $name;
25
26
    /**
27
     * @var array
28
     */
29
    public $nicknames = [];
30
31
    /**
32
     * @var
33
     */
34
    public $self;
35
36
    /**
37
     * @var string
38
     */
39
    public $type;
40
41
    /**
42
     * @var string
43
     */
44
    public $topic;
45
46
    /**
47
     * @param Connection $irc
48
     * @param string $name
49
     */
50
    public function __construct($irc, $name)
51
    {
52
        $this->irc = $irc;
53
        $this->name = $name;
54
    }
55
56
    /**
57
     * @TODO DESCR
58
     */
59
    public function who()
60
    {
61
        $this->irc->command('WHO', $this->name);
62
    }
63
64
    /**
65
     * @TODO DESCR
66
     * @param array|string $mask
67
     * @param mixed $msg
68
     */
69
    public function onPart($mask, $msg = null)
0 ignored issues
show
The parameter $msg is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
70
    {
71
        if (is_string($mask)) {
72
            $mask = IRC::parseUsermask($mask);
73
        }
74
        if (($mask['nick'] === $this->irc->nick) && ($mask['user'] === $this->irc->user)) {
0 ignored issues
show
The property $user is declared protected in PHPDaemon\Clients\IRC\Connection. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
75
            $this->destroy();
76
        } else {
77
            unset($this->nicknames[$mask['nick']]);
78
        }
79
    }
80
81
    /**
82
     * @TODO DESCR
83
     */
84
    public function destroy()
85
    {
86
        unset($this->irc->channels[$this->name]);
87
    }
88
89
    /**
90
     * @TODO DESCR
91
     * @param string $type
92
     */
93
    public function setChanType($type)
94
    {
95
        $this->type = $type;
96
    }
97
98
    /**
99
     * @TODO DESCR
100
     * @return array
101
     */
102
    public function exportNicksArray()
103
    {
104
        $nicks = [];
105
        foreach ($this as $participant) {
106
            $nicks[] = $participant->flag . $participant->nick;
107
        }
108
        return $nicks;
109
    }
110
111
    /**
112
     * @TODO DESCR
113
     * @param string $msg
114
     */
115
    public function setTopic($msg)
116
    {
117
        $this->topic = $msg;
118
    }
119
120
    /**
121
     * @TODO DESCR
122
     * @param string $nick
123
     * @param string $mode
124
     */
125 View Code Duplication
    public function addMode($nick, $mode)
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...
126
    {
127
        if (!isset($this->nicknames[$nick])) {
128
            return;
129
        }
130
        $participant = $this->nicknames[$nick];
131
        if (mb_orig_strpos($participant->mode, $mode) === false) {
132
            $participant->mode .= $mode;
133
        }
134
        $participant->onModeUpdate();
135
    }
136
137
    /**
138
     * @TODO DESCR
139
     * @param string $target
140
     * @param string $mode
141
     */
142 View Code Duplication
    public function removeMode($target, $mode)
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...
143
    {
144
        if (!isset($this->nicknames[$target])) {
145
            return;
146
        }
147
        $participant = $this->nicknames[$target];
148
        $participant->mode = str_replace($mode, '', $participant->mode);
149
        $participant->onModeUpdate();
150
    }
151
152
    /**
153
     * @TODO DESCR
154
     */
155
    public function join()
156
    {
157
        $this->irc->join($this->name);
0 ignored issues
show
$this->name is of type string, but the function expects a array.

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...
158
    }
159
160
    /**
161
     * @TODO DESCR
162
     * @param mixed $msg
163
     */
164
    public function part($msg = null)
165
    {
166
        $this->irc->part($this->name, $msg);
0 ignored issues
show
$this->name is of type string, but the function expects a array.

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...
167
    }
168
169
    /**
170
     * @TODO DESCR
171
     * @param  string $type
172
     * @return $this
173
     */
174
    public function setType($type)
175
    {
176
        $this->type = $type;
177
        return $this;
178
    }
179
180
    /**
181
     * @TODO DESCR
182
     * @param object $obj
183
     */
184
    public function detach($obj)
185
    {
186
        parent::detach($obj);
187
        unset($this->nicknames[$obj->nick]);
188
    }
189
}
190