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/onMessage/motd.php (7 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
 * @property  message
27
 */
28
	class motd {
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...
29
		public $config;
30
		public $discord;
31
		public $logger;
32
		public $message;
33
		private $excludeChannel;
34
		private $triggers;
35
		public function init($config, $discord, $logger) {
36
			$this->config = $config;
37
			$this->discord = $discord;
38
			$this->logger = $logger;
39
			$this->excludeChannel = $this->config['bot']['restrictedChannels'];
40
			$this->triggers[] = $this->config['bot']['trigger'] . 'motd';
41
			$this->triggers[] = $this->config['bot']['trigger'] . 'Motd';
42
			$this->triggers[] = $this->config['bot']['trigger'] . 'MOTD';
43
			$this->keyID = $config['plugins']['motd']['keyID'];
0 ignored issues
show
The property keyID does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
44
			$this->vCode = $config['plugins']['motd']['vCode'];
0 ignored issues
show
The property vCode does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
45
			$this->characterID = $config['plugins']['motd']['characterID'];
0 ignored issues
show
The property characterID does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
46
			$this->channelname = $config['plugins']['motd']['channelname'];
0 ignored issues
show
The property channelname does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
47
		}
48
		public function onMessage($msgData, $message) {
49
			$channelID = (int) $msgData['message']['channelID'];
50
			if (in_array($channelID, $this->excludeChannel, true)) {
51
				return null;
52
			}
53
			$this->message = $message;
54
			$user = $msgData['message']['from'];
0 ignored issues
show
$user is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
55
			$message = $msgData['message']['message'];
56
			$data = command($message, $this->information() ['trigger'], $this->config['bot']['trigger']);
57
			if (isset($data['trigger'])) {
58
				$keyID = $this->keyID;
59
				$vCode = $this->vCode;
60
				$characterID = $this->characterID;
61
				$channelname = $this->channelname;
62
63
        $urlChar = "https://api.eveonline.com/char/ChatChannels.xml.aspx?keyID=$keyID&vCode=$vCode&characterID=$characterID";
64
				$data = file_get_contents($urlChar);
65
				$list = new SimpleXMLElement($data);
66
				
67
				
68
				foreach ($list->result->rowset->row as $row) {
69
					$channeln = $row["displayName"];
70
					
71
					if ($channeln == $channelname) {
72
					//scrub the motd, then break it into 1900 chars or less. Limit is 2000 and want to leave room for the name of the person being replied too
73
					$comment = $row["motd"];
74
          $comment = str_replace("<BR>", "\n", $comment);
75
          $comment = str_replace("<br>", "\n", $comment);
76
          $comment = str_replace("<u>", "__", $comment);
77
          $comment = str_replace("</u>", "__", $comment);	
78
          $comment = str_replace("<b>", "**", $comment);	
79
          $comment = str_replace("</b>", "**", $comment);	
80
          $comment = str_replace("<i>", "*", $comment);	
81
          $comment = str_replace("</i>", "*", $comment);
82
					$comment = str_replace("&amp;", "&", $comment);
83
          $comment = strip_tags($comment);
84
					$comment2 = str_split($comment, 1900);
85
					
86
					$this->message->reply("\n $comment2[0]");
87
						if (!empty($comment2[1])) {
88
							$this->message->reply("\n $comment2[1]");
89
						}
90
						if (!empty($comment2[2])) {
91
							$this->message->reply("\n $comment2[2]");
92
						}
93
						if (!empty($comment2[3])) {
94
							$this->message->reply("\n $comment2[3]");
95
						}
96
					}
97
				}
98
			}
99
		}
100
		public function information() {
101
            return array('name' => 'motd', 'trigger' => $this->triggers, 'information' => 'Displays the MOTD, useful for seeing information displayed there when not in-game.');
102
		}
103
	}
104
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
105