Issues (165)

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.

Plugins/RPED.php (5 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
/**
4
 * This file is part of Peachy MediaWiki Bot API
5
 *
6
 * Peachy is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
20
class RPED {
21
22
	/**
23
	 * Wiki class
24
	 *
25
	 * @var Wiki
26
	 * @access private
27
	 */
28
	private $wiki;
29
30
	/**
31
	 * maxURLLength
32
	 * Default maximum length of the URL to be posted
33
	 *
34
	 * @var int
35
	 * @access private
36
	 */
37
	private $defaultMaxURLLength;
38
39
	/**
40
	 * Construction method for the RPED class
41
	 *
42
	 * @access public
43
	 * @param Wiki &$wikiClass The Wiki class object
44
	 */
45
	function __construct( Wiki &$wikiClass ) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for __construct.

Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed.

If you are not sure which visibility to choose, it is a good idea to start with the most restrictive visibility, and then raise visibility as needed, i.e. start with private, and only raise it to protected if a sub-class needs to have access, or public if an external class needs access.

Loading history...
46
		$this->wiki = $wikiClass;
47
		$defaultMaxURLLength = 2000;
0 ignored issues
show
$defaultMaxURLLength 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...
48
		return;
0 ignored issues
show
Empty return statement not required here
Loading history...
49
	}
50
51
	/**
52
	 * Insert a page title into the rped_page table
53
	 *
54
	 * @static
55
	 * @access public
56
	 * @param string $page
57
	 * @return void
58
	 */
59
	public function insert( $page ) {
60
		$this->wiki->apiQuery(
61
			array(
62
				'action' => 'rped',
63
				'insert' => $page,
64
			), true
65
		);
66
	}
67
68
	/**
69
	 * Delete a page title from the rped_page table
70
	 *
71
	 * @static
72
	 * @access public
73
	 * @param string $page
74
	 * @return void
75
	 */
76
	public function delete( $page ) {
77
		$this->wiki->apiQuery(
78
			array(
79
				'action' => 'rped',
80
				'delete' => $page,
81
			), true
82
		);
83
	}
84
85
	/**
86
	 * Insert/delete an array of page titles into/from the rped_page table
87
	 *
88
	 * @static
89
	 * @access public
90
	 * @param string $command Either 'insert' or 'delete'
91
	 * @param array $pageArray The array of page title to insert
92
	 * @param int $maxURLLength The maximum length of the url to be POSTed
93
	 * @return void
94
	 */
95
	public function insertOrDeleteArray( $command, $pageArray, $maxURLLength = 0 ) {
96
		if( $command != 'insert' && $command != 'delete' ) {
97
			die( 'Something tried to call insertOrDeleteArray without'
0 ignored issues
show
Coding Style Compatibility introduced by
The method insertOrDeleteArray() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
98
				 . 'specifying an insert or delete command.' );
99
		}
100
		if( $maxURLLength == 0 ) {
101
			$maxURLLength = $this->defaultMaxURLLength;
102
		}
103
		$line = '';
104
		foreach( $pageArray as $page ){
105
			if( $line != '' ) {
106
				$line .= '|';
107
			}
108
			if( strlen( $line ) + strlen( $page ) > $maxURLLength ) {
109
				if( $command == 'delete' ) {
110
					$this->delete( $line );
111
				} else {
112
					$this->insert( $line );
113
				}
114
				$line = '';
115
			}
116
			$line .= $page;
117
		}
118
		if( $command == 'delete' ) {
119
			$this->delete( $line );
120
		} else {
121
			$this->insert( $line );
122
		}
123
	}
124
125
	/**
126
	 * Insert an array of page titles into/from the rped_page table
127
	 *
128
	 * @static
129
	 * @access public
130
	 * @param array $pageArray The array of page title to insert
131
	 * @param int $maxURLLength The maximum length of the url to be POSTed
132
	 * @return void
133
	 */
134
	public function insertArray( $pageArray, $maxURLLength = 0 ) {
135
		$this->insertOrDeleteArray( 'insert', $pageArray, $maxURLLength );
136
	}
137
138
	/**
139
	 * Delete an array of page titles from the rped_page table
140
	 *
141
	 * @static
142
	 * @access public
143
	 * @param array $pageArray The array of page title to insert
144
	 * @param int $maxURLLength The maximum length of the url to be POSTed
145
	 * @return void
146
	 */
147
	public function deleteArray( $pageArray, $maxURLLength = 0 ) {
148
		$this->insertOrDeleteArray( 'delete', $pageArray, $maxURLLength );
149
	}
150
}
151