Issues (205)

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/onTick/siphons.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
 * The MIT License (MIT)
4
 *
5
 * Copyright (c) 2016 Robert Sardinia
6
 *
7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
8
 * of this software and associated documentation files (the "Software"), to deal
9
 * in the Software without restriction, including without limitation the rights
10
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
 * copies of the Software, and to permit persons to whom the Software is
12
 * furnished to do so, subject to the following conditions:
13
 *
14
 * The above copyright notice and this permission notice shall be included in all
15
 * copies or substantial portions of the Software.
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
 * SOFTWARE.
24
 */
25
26
use discord\discord;
27
28
/**
29
 * Class siphons
30
 */
31
class siphons
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
32
{
33
    public $guild;
34
    /**
35
     * @var
36
     */
37
    private $config;
38
    /**
39
     * @var
40
     */
41
    private $discord;
42
    /**
43
     * @var
44
     */
45
    private $logger;
46
    /**
47
     * @var
48
     */
49
    private $groupConfig;
50
51
    /**
52
     * @param $config
53
     * @param $discord
54
     * @param $logger
55
     */
56
    public function init($config, $discord, $logger)
57
    {
58
        $this->config = $config;
59
        $this->discord = $discord;
60
        $this->logger = $logger;
61
        $this->guild = $config['bot']['guild'];
62
        $this->groupConfig = $config['plugins']['siphons']['groupConfig'];
63
    }
64
65
    /**
66
     *
67
     */
68
    public function tick()
69
    {
70
        // If config is outdated
71
        if (null === $this->groupConfig) {
72
            $this->logger->addInfo('Siphons: Update your config file to the latest version.');
73
            $msg = '**Siphon Failure:** Please update the bots config to the latest version.';
74
            queueMessage($msg, $this->config['notifications']['channelID'], $this->guild);
75
        }
76
77
        // What was the servers last reported state
78
        $lastStatus = getPermCache('serverState');
79
        if ($lastStatus === 'online') {
80
            foreach ($this->groupConfig as $siphonCorp) {
81
                //If group channel is set to 0 skip
82
                if ($siphonCorp['channelID'] === 0) {
83
                    continue;
84
                }
85
                $lastChecked = getPermCache("siphonLastChecked{$siphonCorp['keyID']}");
86
                if ($lastChecked === NULL) {
87
                    // Schedule it for right now if first run
88
                    $lastChecked = 1;
89
                }
90
91
                if ($lastChecked <= time()) {
92
                    $this->logger->addInfo("Siphons: Checking keyID - {$siphonCorp['keyID']} for siphons");
93
                    $this->checkTowers();
94
                }
95
            }
96
        }
97
    }
98
99
    private function checkTowers()
100
    {
101
        foreach ($this->groupConfig as $siphonCorp) {
102
            //If group channel is set to 0 skip
103
            if ($siphonCorp['channelID'] === 0) {
104
                continue;
105
            }
106
            $url = "https://api.eveonline.com/corp/AssetList.xml.aspx?keyID={$siphonCorp['keyID']}&vCode={$siphonCorp['vCode']}";
107
            $xml = makeApiRequest($url);
108
            $rawGoo = array(16634, 16643, 16647, 16641, 16640, 16635, 16648, 16633, 16646, 16651, 16650, 16644, 16652, 16639, 16636, 16649, 16653, 16638, 16637, 16642);
109
            foreach (@$xml->result->rowset->row as $structures) {
110
                //Check silos
111 View Code Duplication
                if ((int) @$structures->attributes()->typeID === 14343) {
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...
112
                    if (isset($structures->rowset->row)) {
113
                        foreach (@$structures->rowset->row as $silo) {
114
                            //Avoid reporting empty silos
115
                            if ((int) @$silo->attributes()->quantity !== 0 && in_array(@$silo->attributes()->typeID, $rawGoo, false)) {
116
                                $siloID = $structures->attributes()->itemID;
117
                                $lastAmount = getPermCache("silo{$siloID}Amount");
118
                                $gooAmount = $silo->attributes()->quantity;
119
                                $gooDifference = (int) $gooAmount - (int) $lastAmount;
120
                                //Check if silo has been checked before
121
                                if (null === $lastAmount || $gooDifference < 0) {
122
                                    setPermCache("silo{$siloID}Amount", $gooAmount);
123
                                    continue;
124
                                }
125
                                //Check for a multiple of 50 in the difference
126
                                if ($gooDifference % 50 !== 0) {
127
                                    $gooType = getTypeName($silo->attributes()->typeID);
128
                                    $systemName = getSystemName($structures->attributes()->locationID);
129
                                    $msg = "{$siphonCorp['prefix']}";
130
                                    $msg .= "**POSSIBLE SIPHON**\n";
131
                                    $msg .= "**System: **{$systemName} has a possible siphon stealing {$gooType} from a silo.\n";
132
                                    // Queue the message
133
                                    priorityQueueMessage($msg, $siphonCorp['channelID'], $this->guild);
134
                                    $this->logger->addInfo("Siphons: {$msg}");
135
                                    setPermCache("silo{$siloID}Amount", $gooAmount);
136
                                } else {
137
                                    setPermCache("silo{$siloID}Amount", $gooAmount);
138
                                }
139
                            }
140
                        }
141
                    }
142
                }
143 View Code Duplication
                if ((int) @$structures->attributes()->typeID === 17982) {
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...
144
                    if (isset($structures->rowset->row)) {
145
                        foreach (@$structures->rowset->row as $coupling) {
146
                            //Avoid reporting empty coupling arrays
147
                            if ((int) @$coupling->attributes()->quantity !== 0 && in_array(@$coupling->attributes()->typeID, $rawGoo, false)) {
148
                                $couplingID = $structures->attributes()->itemID;
149
                                $lastAmount = getPermCache("couplingArray{$couplingID}Amount");
150
                                $gooAmount = $coupling->attributes()->quantity;
151
                                $gooDifference = (int) $gooAmount - (int) $lastAmount;
152
                                //Check if silo has been checked before
153
                                if (null === $lastAmount || $gooDifference < 0) {
154
                                    setPermCache("couplingArray{$couplingID}Amount", $gooAmount);
155
                                    continue;
156
                                }
157
                                //Check for a multiple of 50 in the difference
158
                                if ($gooDifference % 50 !== 0) {
159
                                    $gooType = getTypeName($coupling->attributes()->typeID);
160
                                    $systemName = getSystemName($structures->attributes()->locationID);
161
                                    $msg = "{$siphonCorp['prefix']}";
162
                                    $msg .= "**POSSIBLE SIPHON**\n";
163
                                    $msg .= "**System: **{$systemName} has a possible siphon stealing {$gooType} from a coupling array.\n";
164
                                    // Queue the message
165
                                    priorityQueueMessage($msg, $siphonCorp['channelID'], $this->guild);
166
                                    $this->logger->addInfo("Siphons: {$msg}");
167
                                    setPermCache("couplingArray{$couplingID}Amount", $gooAmount);
168
                                } else {
169
                                    setPermCache("couplingArray{$couplingID}Amount", $gooAmount);
170
                                }
171
                            }
172
                        }
173
                    }
174
                }
175
            }
176
            $cached = $xml->cachedUntil[0];
177
            $baseUnix = strtotime($cached);
178
            $cacheClr = $baseUnix - 13500;
179 View Code Duplication
            if ($cacheClr <= time()) {
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...
180
                $weirdTime = time() + 21700;
181
                $cacheTimer = gmdate('Y-m-d H:i:s', $weirdTime);
182
                setPermCache("siphonLastChecked{$siphonCorp['keyID']}", $weirdTime);
183
            } else {
184
                $cacheTimer = gmdate('Y-m-d H:i:s', $cacheClr);
185
                setPermCache("siphonLastChecked{$siphonCorp['keyID']}", $cacheClr);
186
            }
187
            $this->logger->addInfo("Siphons: Siphon Check Complete Next Check At {$cacheTimer}");
188
            return null;
189
        }
190
    }
191
}
192