Issues (81)

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/Plugins/onMessage/config.php (4 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
3
namespace Sovereign\Plugins\onMessage;
4
5
use Discord\Discord;
6
use Discord\Parts\Channel\Message;
7
use Monolog\Logger;
8
use Sovereign\Lib\cURL;
9
use Sovereign\Lib\Db;
10
use Sovereign\Lib\Permissions;
11
use Sovereign\Lib\ServerConfig;
12
use Sovereign\Lib\Settings;
13
use Sovereign\Lib\Users;
14
15
class config extends \Threaded implements \Collectable
16
{
17
    /**
18
     * @var Message
19
     */
20
    private $message;
21
    /**
22
     * @var Discord
23
     */
24
    private $discord;
25
    /**
26
     * @var Logger
27
     */
28
    private $log;
29
    /**
30
     * @var array
31
     */
32
    private $channelConfig;
33
    /**
34
     * @var Config
35
     */
36
    private $config;
37
    /**
38
     * @var Db
39
     */
40
    private $db;
41
    /**
42
     * @var cURL
43
     */
44
    private $curl;
45
    /**
46
     * @var Settings
47
     */
48
    private $settings;
49
    /**
50
     * @var Permissions
51
     */
52
    private $permissions;
53
    /**
54
     * @var ServerConfig
55
     */
56
    private $serverConfig;
57
    /**
58
     * @var Users
59
     */
60
    private $users;
61
    /**
62
     * @var array
63
     */
64
    private $extras;
65
66 View Code Duplication
    public function __construct($message, $discord, $channelConfig, $log, $config, $db, $curl, $settings, $permissions, $serverConfig, $users, $extras)
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...
67
    {
68
        $this->message = $message;
69
        $this->discord = $discord;
70
        $this->channelConfig = $channelConfig;
71
        $this->log = $log;
72
        $this->config = $config;
73
        $this->db = $db;
74
        $this->curl = $curl;
75
        $this->settings = $settings;
76
        $this->permissions = $permissions;
77
        $this->serverConfig = $serverConfig;
78
        $this->users = $users;
79
        $this->extras = $extras;
80
    }
81
82
    public function run()
83
    {
84
        $guildID = $this->message->full_channel->guild->id;
85
        $input = explode(" ", $this->message->content);
86
        unset($input[0]);
87
        $type = isset($input[1]) ? $input[1] : "";
88
        unset($input[1]);
89
90
        // Defaults
91
        $channelID = $this->message->channel_id;
92
        $msg = "";
93
94
        // Config options
95
        switch (trim($type)) {
96
            case "setTrigger":
97
                $trigger = $input[2];
98
                $orgTrigger = $this->serverConfig->get($guildID, "prefix") ? $this->serverConfig->get($guildID, "prefix") : $this->channelConfig->prefix;
99
                $this->serverConfig->set($guildID, "prefix", $trigger);
100
                $msg = "Trigger has been changed from {$orgTrigger} to {$trigger}";
101
                break;
102
            case "enablePorn":
103
                $pornArray = $this->serverConfig->getAll($guildID)->porn->allowedChannels;
104
                if (!in_array($channelID, $pornArray)) {
105
                    $pornArray[] = $channelID;
106
                }
107
108
                $this->serverConfig->set($guildID, "porn", array("allowedChannels" => $pornArray));
109
                $msg = "Porn has now been enabled on this channel, enjoy, you perv ;)";
110
                break;
111
            case "disablePorn":
112
                $pornArray = $this->serverConfig->getAll($guildID)->porn->allowedChannels;
113
                foreach ($pornArray as $key => $value) {
114
                    if ($value == $channelID) {
115
                        unset($pornArray[$key]);
116
                    }
117
                }
118
119
                $this->serverConfig->set($guildID, "porn", array("allowedChannels" => $pornArray));
120
                $msg = "Porn has now been disabled on this channel. :(";
121
                break;
122
            case "addKillmails":
123
                // %config addKillmails character characterID
124
                $typeName = trim($input[2]);
125
                $typeID = trim($input[3]);
126
127
                switch ($typeName) {
128 View Code Duplication
                    case "character":
0 ignored issues
show
This code seems to be duplicated across 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...
129
                        // Check said char exists on the killboard..
130
                        $exists = json_decode($this->curl->get("https://evedata.xyz/api/character/information/{$typeID}/"));
131
                        if (isset($exists->characterID)) {
132
                            $this->db->execute("INSERT IGNORE INTO killmailPosting (channelID, typeName, typeID) VALUES (:channelID, :typeName, :typeID)", array(":channelID" => $channelID, ":typeName" => $typeName, ":typeID" => $typeID));
133
                            $msg = "**Success** killmails should start getting posted for {$exists->characterName} to this channel";
134
                        } else {
135
                            $msg = "**Error** characterID is not valid";
136
                        }
137
                        break;
138
139 View Code Duplication
                    case "corporation":
0 ignored issues
show
This code seems to be duplicated across 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...
140
                        // Check said char exists on the killboard..
141
                        $exists = json_decode($this->curl->get("https://evedata.xyz/api/corporation/information/{$typeID}/"));
142
                        if (isset($exists->corporationID)) {
143
                            $this->db->execute("INSERT IGNORE INTO killmailPosting (channelID, typeName, typeID) VALUES (:channelID, :typeName, :typeID)", array(":channelID" => $channelID, ":typeName" => $typeName, ":typeID" => $typeID));
144
                            $msg = "**Success** killmails should start getting posted for {$exists->corporationName} to this channel";
145
                        } else {
146
                            $msg = "**Error** corporationID is not valid";
147
                        }
148
149
                        break;
150
151 View Code Duplication
                    case "alliance":
0 ignored issues
show
This code seems to be duplicated across 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...
152
                        // Check said char exists on the killboard..
153
                        $exists = json_decode($this->curl->get("https://evedata.xyz/api/alliance/information/{$typeID}/"));
154
                        if (isset($exists->allianceID)) {
155
                            $this->db->execute("INSERT IGNORE INTO killmailPosting (channelID, typeName, typeID) VALUES (:channelID, :typeName, :typeID)", array(":channelID" => $channelID, ":typeName" => $typeName, ":typeID" => $typeID));
156
                            $msg = "**Success** killmails should start getting posted for {$exists->allianceName} to this channel";
157
                        } else {
158
                            $msg = "**Error** allianceID is not valid";
159
                        }
160
                        break;
161
                }
162
                break;
163
            case "removeKillmails":
164
                break;
165
            case "listKillmails":
166
                break;
167
            case "addTwitterOauth":
168
                // Add oauth settings for twitter, and send twitter messages to the channel it was enabled in, unless channelID was passed along
169
                break;
170
            case "removeTwitterOauth":
171
                // Disable twitter, and remove the oauth keys
172
                break;
173
            case "addSiphonKey":
174
                // Add an apikey used for checking for siphons, output to the channel it was enabled in, unless a channelID was passed along
175
                break;
176
            case "removeSiphonKey":
177
                break;
178
            case "addMailKey":
179
                // same as add siphon
180
                break;
181
            case "removeMailKey":
182
                break;
183
            case "addNotificationKey":
184
                // same as add siphon
185
                break;
186
            case "removeNotificationKey":
187
                break;
188
            case "addAuth":
189
                // Enable authentication for a characterID, corporationID or allianceID - have multiple, and let them map 1:1 to groups on Discord (if group doesn't exist, create it)
190
                break;
191
            case "removeAuth":
192
                break;
193
            case "addJabberReader":
194
                // Setup a socket to listen for messages, make them prepend a key for the channel it was enabled in (unless a channelID was specified)
195
                break;
196
            case "removeJabberReader":
197
                break;
198
            default:
199
                $msg = "Error, no configuration option picked. Available configuration options are: setTrigger, enablePorn, disablePorn, addTwitterOauth, removeTwitterOauth, addSiphonKey, removeSiphonKey, addMailKey, removeMailKey, addNotificationKey, removeNotificationKey, addJabberReader, removeJabberReader, addAuth, removeAuth";
200
                break;
201
        }
202
203
        $this->message->reply($msg);
204
205
        // Mark this as garbage
206
        $this->isGarbage();
207
    }
208
}
209