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/Servers/IRCBouncer/Pool.php (9 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\Servers\IRCBouncer;
3
4
use PHPDaemon\Core\Daemon;
5
use PHPDaemon\Network\Server;
6
use PHPDaemon\Structures\ObjectStorage;
7
8
class Pool extends Server
9
{
10
11
    /**
12
     * @var Pool
13
     */
14
    public $client;
15
16
    /**
17
     * @var Connection
18
     */
19
    public $conn;
20
21
    /**
22
     * @var boolean
23
     */
24
    public $protologging = false;
25
26
    /**
27
     * @var Pool
28
     */
29
    public $db;
30
31
    /**
32
     * @var object
33
     */
34
    public $messages;
35
36
    /**
37
     * @var object
38
     */
39
    public $channels;
40
41
    /**
42
     * @TODO DESCR
43
     */
44
    protected function init()
45
    {
46
        $this->client = Pool::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \PHPDaemon\Servers\IRCBouncer\Pool::getInstance() of type object<PHPDaemon\Network\this> is incompatible with the declared type object<PHPDaemon\Servers\IRCBouncer\Pool> of property $client.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
        $this->client->protologging = $this->protologging;
48
        $this->db = Pool::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \PHPDaemon\Servers\IRCBouncer\Pool::getInstance() of type object<PHPDaemon\Network\this> is incompatible with the declared type object<PHPDaemon\Servers\IRCBouncer\Pool> of property $db.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
49
        $this->messages = $this->db->{$this->config->dbname->value . '.messages'};
0 ignored issues
show
The property dbname does not seem to exist in PHPDaemon\Config\Section.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
50
        $this->channels = $this->db->{$this->config->dbname->value . '.channels'};
51
    }
52
53
    /**
54
     * Setting default config options
55
     * Overriden from ConnectionPool::getConfigDefaults
56
     * @return array|bool
57
     */
58
    protected function getConfigDefaults()
59
    {
60
        return [
61
            /* [string|array] Listen addresses */
62
            'listen' => '0.0.0.0',
63
64
            /* [integer] Listen port */
65
            'port' => 6667,
66
67
            /* [string] URL */
68
            'url' => 'irc://user@host/nickname/realname',
69
70
            /* [string] Server name */
71
            'servername' => 'bnchost.tld',
72
73
            /* [string] Default channels */
74
            'defaultchannels' => '',
75
76
            /* [boolean] Logging? */
77
            'protologging' => 0,
78
79
            /* [string] Database name */
80
            'dbname' => 'bnc',
81
82
            /* [string] Password */
83
            'password' => 'SecretPwd',
84
        ];
85
    }
86
87
    /**
88
     * @TODO DESCR
89
     */
90
    public function applyConfig()
91
    {
92
        parent::applyConfig();
93
        $this->protologging = (bool)$this->config->protologging->value;
0 ignored issues
show
The property protologging does not seem to exist in PHPDaemon\Config\Section.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
94
        if (isset($this->client)) {
95
            $this->client->protologging = $this->protologging;
96
        }
97
    }
98
99
    /**
100
     * @TODO DESCR
101
     */
102
    public function onReady()
103
    {
104
        parent::onReady();
105
        $this->client->onReady();
106
        $this->getConnection($this->config->url->value);
0 ignored issues
show
The property url does not seem to exist in PHPDaemon\Config\Section.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
107
    }
108
109
    /**
110
     * @TODO DESCR
111
     * @param string $url
112
     */
113
    public function getConnection($url)
114
    {
115
        $this->client->getConnection($url, function ($conn) use ($url) {
0 ignored issues
show
The call to Pool::getConnection() has too many arguments starting with function ($conn) use($ur... . $url . ')'); } }.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
116
            $this->conn = $conn;
117
            $conn->attachedClients = new ObjectStorage;
118
            if ($conn->connected) {
119
                Daemon::log('IRC bot connected at ' . $url);
120
                $conn->join($this->config->defaultchannels->value);
0 ignored issues
show
The property defaultchannels does not seem to exist in PHPDaemon\Config\Section.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
121
                $conn->bind('motd', function ($conn) {
0 ignored issues
show
The parameter $conn 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...
122
                    //Daemon::log($conn->motd);
123
                });
124
                foreach ($this as $bouncerConn) {
125
                    if (!$bouncerConn->attachedServer) {
126
                        $bouncerConn->attachTo($conn);
127
                    }
128
                }
129
                $conn->bind('command', function ($conn, $from, $cmd, $args) {
130
                    if ($cmd === 'PONG') {
131
                        return;
132
                    } elseif ($cmd === 'PING') {
133
                        return;
134
                    }
135
                    if ($from['orig'] === $conn->servername) {
136
                        $from['orig'] = $this->config->servername->value;
0 ignored issues
show
The property servername does not seem to exist in PHPDaemon\Config\Section.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
137
                    }
138
                    $conn->attachedClients->each('commandArr', $from['orig'], $cmd, $args);
139
                });
140
                $conn->bind('privateMsg', function ($conn, $msg) {
141
                    Daemon::log('IRCBouncer: got private message \'' . $msg['body'] . '\' from \'' . $msg['from']['orig'] . '\'');
142
                });
143
                $conn->bind('msg', function ($conn, $msg) {
144
                    $msg['ts'] = microtime(true);
145
                    $msg['dir'] = 'i';
146
                    $this->messages->insert($msg);
147
                });
148
                $conn->bind('disconnect', function ($conn) use ($url) {
149
                    foreach ($this as $bouncerConn) {
150
                        if ($bouncerConn->attachedServer === $conn) {
151
                            $bouncerConn->detach();
152
                        }
153
                    }
154
                    $this->getConnection($url);
155
                });
156
            } else {
157
                Daemon::log('IRCBouncer: unable to connect (' . $url . ')');
158
            }
159
        });
160
    }
161
}
162