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/Utils/IRC.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
namespace PHPDaemon\Utils;
3
4
/**
5
 * IRC
6
 * @package PHPDaemon\Utils
7
 * @author  Vasily Zorin <[email protected]>
8
 */
9
class IRC
10
{
11
    use \PHPDaemon\Traits\ClassWatchdog;
12
    use \PHPDaemon\Traits\StaticObjectWatchdog;
13
14
    /**
15
     * @var array IRC codes
16
     */
17
    public static $codes = [
18
        '1' => 'RPL_WELCOME',
19
        2 => 'RPL_YOURHOST',
20
        3 => 'RPL_CREATED',
21
        4 => 'RPL_MYINFO',
22
        5 => 'RPL_BOUNCE',
23
        200 => 'RPL_TRACELINK',
24
        201 => 'RPL_TRACECONNECTING',
25
        202 => 'RPL_TRACEHANDSHAKE',
26
        203 => 'RPL_TRACEUNKNOWN',
27
        204 => 'RPL_TRACEOPERATOR',
28
        205 => 'RPL_TRACEUSER',
29
        206 => 'RPL_TRACESERVER',
30
        207 => 'RPL_TRACESERVICE',
31
        208 => 'RPL_TRACENEWTYPE',
32
        209 => 'RPL_TRACECLASS',
33
        210 => 'RPL_TRACERECONNECT',
34
        211 => 'RPL_STATSLINKINFO',
35
        212 => 'RPL_STATSCOMMANDS',
36
        219 => 'RPL_ENDOFSTATS',
37
        221 => 'RPL_UMODEIS',
38
        234 => 'RPL_SERVLIST',
39
        235 => 'RPL_SERVLISTEND',
40
        242 => 'RPL_STATSUPTIME',
41
        243 => 'RPL_STATSOLINE',
42
        250 => 'RPL_STATSCONN',
43
        251 => 'RPL_LUSERCLIENT',
44
        252 => 'RPL_LUSEROP',
45
        253 => 'RPL_LUSERUNKNOWN',
46
        254 => 'RPL_LUSERCHANNELS',
47
        255 => 'RPL_LUSERME',
48
        256 => 'RPL_ADMINME',
49
        257 => 'RPL_ADMINLOC1',
50
        258 => 'RPL_ADMINLOC2',
51
        259 => 'RPL_ADMINEMAIL',
52
        261 => 'RPL_TRACELOG',
53
        262 => 'RPL_TRACEEND',
54
        263 => 'RPL_TRYAGAIN',
55
        265 => 'RRPL_LOCALUSERS',
56
        266 => 'RPL_GLOBALUSERS',
57
        301 => 'RPL_AWAY',
58
        302 => 'RPL_USERHOST',
59
        303 => 'RPL_ISON',
60
        305 => 'RPL_UNAWAY',
61
        306 => 'RPL_NOWAWAY',
62
        311 => 'RPL_WHOISUSER',
63
        312 => 'RPL_WHOISSERVER',
64
        313 => 'RPL_WHOISOPERATOR',
65
        314 => 'RPL_WHOWASUSER',
66
        315 => 'RPL_ENDOFWHO',
67
        317 => 'RPL_WHOISIDLE',
68
        318 => 'RPL_ENDOFWHOIS',
69
        319 => 'RPL_WHOISCHANNELS',
70
        321 => 'RPL_LISTSTART',
71
        322 => 'RPL_LIST',
72
        323 => 'RPL_LISTEND',
73
        324 => 'RPL_CHANNELMODEIS',
74
        325 => 'RPL_UNIQOPIS',
75
        328 => 'RPL_CHANNEL_URL',
76
        329 => 'RPL_CREATIONTIME',
77
        331 => 'RPL_NOTOPIC',
78
        332 => 'RPL_TOPIC',
79
        333 => 'RPL_TOPIC_TS',
80
        341 => 'RPL_INVITING',
81
        342 => 'RPL_SUMMONING',
82
        346 => 'RPL_INVITELIST',
83
        347 => 'RPL_ENDOFINVITELIST',
84
        348 => 'RPL_EXCEPTLIST',
85
        349 => 'RPL_ENDOFEXCEPTLIST',
86
        351 => 'RPL_VERSION',
87
        352 => 'RPL_WHOREPLY',
88
        353 => 'RPL_NAMREPLY',
89
        364 => 'RPL_LINKS',
90
        365 => 'RPL_ENDOFLINKS',
91
        366 => 'RPL_ENDOFNAMES',
92
        367 => 'RPL_BANLIST',
93
        368 => 'RPL_ENDOFBANLIST',
94
        369 => 'RPL_ENDOFWHOWAS',
95
        371 => 'RPL_INFO',
96
        372 => 'RPL_MOTD',
97
        374 => 'RPL_ENDOFINFO',
98
        375 => 'RPL_MOTDSTART',
99
        376 => 'RPL_ENDOFMOTD',
100
        381 => 'RPL_YOUREOPER',
101
        382 => 'RPL_REHASHING',
102
        383 => 'RPL_YOURESERVICE',
103
        391 => 'RPL_TIME',
104
        392 => 'RPL_USERSSTART',
105
        393 => 'RPL_USERS',
106
        394 => 'RPL_ENDOFUSERS',
107
        395 => 'RPL_NOUSERS',
108
        401 => 'ERR_NOSUCHNICK',
109
        402 => 'ERR_NOSUCHSERVER',
110
        403 => 'ERR_NOSUCHCHANNEL',
111
        404 => 'ERR_CANNOTSENDTOCHAN',
112
        405 => 'ERR_TOOMANYCHANNELS',
113
        406 => 'ERR_WASNOSUCHNICK',
114
        407 => 'ERR_TOOMANYTARGETS',
115
        408 => 'ERR_NOSUCHSERVICE',
116
        409 => 'ERR_NOORIGIN',
117
        411 => 'ERR_NORECIPIENT',
118
        412 => 'ERR_NOTEXTTOSEND',
119
        413 => 'ERR_NOTOPLEVEL',
120
        414 => 'ERR_WILDTOPLEVEL',
121
        415 => 'ERR_BADMASK',
122
        421 => 'ERR_UNKNOWNCOMMAND',
123
        422 => 'ERR_NOMOTD',
124
        423 => 'ERR_NOADMININFO',
125
        424 => 'ERR_FILEERROR',
126
        431 => 'ERR_NONICKNAMEGIVEN',
127
        432 => 'ERR_ERRONEUSNICKNAME',
128
        433 => 'ERR_NICKNAMEINUSE',
129
        436 => 'ERR_NICKCOLLISION',
130
        437 => 'ERR_UNAVAILRESOURCE',
131
        441 => 'ERR_USERNOTINCHANNEL',
132
        442 => 'ERR_NOTONCHANNEL',
133
        443 => 'ERR_USERONCHANNEL',
134
        444 => 'ERR_NOLOGIN',
135
        445 => 'ERR_SUMMONDISABLED',
136
        446 => 'ERR_USERSDISABLED',
137
        451 => 'ERR_NOTREGISTERED',
138
        461 => 'ERR_NEEDMOREPARAMS',
139
        462 => 'ERR_ALREADYREGISTRED',
140
        463 => 'ERR_NOPERMFORHOST',
141
        464 => 'ERR_PASSWDMISMATCH',
142
        465 => 'ERR_YOUREBANNEDCREEP',
143
        466 => 'ERR_YOUWILLBEBANNED',
144
        467 => 'ERR_KEYSET',
145
        471 => 'ERR_CHANNELISFULL',
146
        472 => 'ERR_UNKNOWNMODE',
147
        473 => 'ERR_INVITEONLYCHAN',
148
        474 => 'ERR_BANNEDFROMCHAN',
149
        475 => 'ERR_BADCHANNELKEY',
150
        476 => 'ERR_BADCHANMASK',
151
        477 => 'ERR_NOCHANMODES',
152
        478 => 'ERR_BANLISTFULL',
153
        481 => 'ERR_NOPRIVILEGES',
154
        482 => 'ERR_CHANOPRIVSNEEDED',
155
        483 => 'ERR_CANTKILLSERVER',
156
        484 => 'ERR_RESTRICTED',
157
        485 => 'ERR_UNIQOPPRIVSNEEDED',
158
        491 => 'ERR_NOOPERHOST',
159
        501 => 'ERR_UMODEUNKNOWNFLAG',
160
        502 => 'ERR_USERSDONTMATCH',
161
    ];
162
163
    /**
164
     * @var array Flipped IRC codes
165
     */
166
    public static $codesFlip;
167
168
    /**
169
     * @param  integer $code Code
170
     * @return string
171
     */
172
    public static function getCommandByCode($code)
173
    {
174
        if (isset(self::$codes[$code])) {
175
            return self::$codes[$code];
176
        }
177
        return false;
178
    }
179
180
    /**
181
     * @param  string $cmd Command
182
     * @return integer
0 ignored issues
show
Should the return type not be string?

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...
183
     */
184
    public static function getCodeByCommand($cmd)
185
    {
186
        if (self::$codesFlip === null) {
187
            self::$codesFlip = array_flip(self::$codes);
188
        }
189
        if (isset(self::$codesFlip[$cmd])) {
190
            return sprintf('%03u', self::$codesFlip[$cmd]);
191
        }
192
        return $cmd;
193
    }
194
195
    /**
196
     * @param  string $mask
197
     * @return array
198
     */
199
    public static function parseUsermask($mask)
200
    {
201
        preg_match('~^(?:(.*?)!(\~?)(.*?)@)?(.*)$~D', $mask, $m);
202
        return [
203
            'nick' => $m[1],
204
            'unverified' => $m[2] === '~',
205
            'user' => $m[3],
206
            'host' => $m[4],
207
            'orig' => $mask,
208
        ];
209
    }
210
}
211