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/fleetUpOperations.php (3 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 fleetUpOperations
30
 * @property  userID
31
 * @property  apiKey
32
 * @property  groupID
33
 */
34
class fleetUpOperations
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...
35
{
36
    public $config;
37
    public $discord;
38
    public $logger;
39
    protected $keyID;
40
    protected $vCode;
41
    protected $prefix;
42
    private $toDiscordChannel;
43
    private $userID;
44
    private $groupID;
45
    private $apiKey;
46
    private $guild;
47
48
    /**
49
     * @param $config
50
     * @param $discord
51
     * @param $logger
52
     */
53
    public function init($config, $discord, $logger)
54
    {
55
        $this->config = $config;
56
        $this->discord = $discord;
57
        $this->logger = $logger;
58
        $this->toDiscordChannel = $config['plugins']['fleetUp']['channelID'];
59
        $this->userID = $config['plugins']['fleetUp']['userID'];
60
        $this->groupID = $config['plugins']['fleetUp']['groupID'];
61
        $this->apiKey = $config['plugins']['fleetUp']['apiKey'];
62
        $this->guild = $config['bot']['guild'];
63
        $lastCheck = getPermCache('fleetUpPostLastChecked');
64
        if ($lastCheck === NULL) {
65
            // Schedule it for right now if first run
66
            setPermCache('fleetUpPostLastChecked', time() - 5);
67
        }
68
    }
69
70
    /**
71
     *
72
     */
73
    public function tick()
74
    {
75
        $lastChecked = getPermCache('fleetUpPostLastChecked');
76
77
        if ($lastChecked <= time()) {
78
            $this->postFleetUp();
79
            $this->checkFleetUp();
80
        }
81
    }
82
83
    private function postFleetUp()
84
    {
85
        date_default_timezone_set('UTC');
86
        $eveTime = time();
87
        //fleetUp post upcoming operations
88
        $currentID = getPermCache('fleetUpLastPostedOperation');
89
        $fleetUpOperations = json_decode(downloadData("http://api.fleet-up.com/Api.svc/tlYgBRjmuXj2Yl1lEOyMhlDId/{$this->userID}/{$this->apiKey}/Operations/{$this->groupID}"), true);
90 View Code Duplication
        foreach ($fleetUpOperations['Data'] as $operation) {
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...
91
            $name = $operation['Subject'];
92
            $startTime = $operation['StartString'];
93
            preg_match_all('!\d+!', $operation['Start'], $epochStart);
94
            $startTimeUnix = substr($epochStart[0][0], 0, -3);
95
            $destination = $operation['Location'];
96
            $formUp = $operation['LocationInfo'];
97
            $info = $operation['Details'];
98
            $id = $operation['Id'];
99
            $link = "https://fleet-up.com/Operation#{$id}";
100
            $timeDifference = $startTimeUnix - $eveTime;
101
            if ($currentID !== $id) {
102
                if ($timeDifference < 900 && $timeDifference > 1) {
103
                    $msg = "@everyone
104
**Upcoming Operation** 
105
Title - {$name} 
106
Form Up Time - {$startTime} 
107
Form Up System - {$formUp} 
108
Target System - {$destination} 
109
Details - {$info} 
110
111
Link - {$link}";
112
                    $channelID = $this->toDiscordChannel;
113
                    priorityQueueMessage($msg, $channelID, $this->guild);
114
                    setPermCache('fleetUpLastPostedOperation', $id);
115
                    $this->logger->addInfo('FleetUp: Upcoming Operation Queued for Posting');
116
                }
117
            }
118
        }
119
        setPermCache('fleetUpPostLastChecked', time() + 910);
120
    }
121
122
    private function checkFleetUp()
123
    {
124
        date_default_timezone_set('UTC');
125
        $eveTime = time();
126
127
        $lastChecked = getPermCache('fleetUpLastChecked');
128
129
        if ($lastChecked <= time()) {
130
131
            //fleetUp check for new operations
132
            $currentID = getPermCache('fleetUpLastOperation');
133
            $fleetUpOperations = json_decode(downloadData("http://api.fleet-up.com/Api.svc/tlYgBRjmuXj2Yl1lEOyMhlDId/{$this->userID}/{$this->apiKey}/Operations/{$this->groupID}"), true);
134 View Code Duplication
            foreach ($fleetUpOperations['Data'] as $operation) {
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...
135
                $name = $operation['Subject'];
136
                $startTime = $operation['StartString'];
137
                preg_match_all('!\d+!', $operation['Start'], $epochStart);
138
                $startTimeUnix = substr($epochStart[0][0], 0, -3);
139
                $desto = $operation['Location'];
140
                $formUp = $operation['LocationInfo'];
141
                $info = $operation['Details'];
142
                $id = $operation['Id'];
143
                $link = "https://fleet-up.com/Operation#{$id}";
144
                $timeDifference = $startTimeUnix - $eveTime;
145
                if ($currentID < $id && $timeDifference > 1) {
146
                    $msg = "
147
**New Operation Posted** 
148
Title - {$name} 
149
Form Up Time - {$startTime} 
150
Form Up System - {$formUp} 
151
Target System - {$desto} 
152
Details - {$info} 
153
154
Link - {$link}";
155
                    $channelID = $this->toDiscordChannel;
156
                    queueMessage($msg, $channelID, $this->guild);
157
                    $this->logger->addInfo('FleetUp: Newest FleetUp operation queued for posting');
158
                }
159
                if ($id > $currentID) {
160
                    setPermCache('fleetUpLastOperation', $id);
161
                    $this->logger->addInfo('FleetUp: Newest FleetUp operation');
162
                }
163
            }
164
            setPermCache('fleetUpLastChecked', time() + 300);
165
        }
166
    }
167
168
}
169