Issues (4122)

Security Analysis    not enabled

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.

includes/specials/SpecialComparePages.php (1 issue)

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
 * Implements Special:ComparePages
4
 *
5
 * Copyright © 2010 Derk-Jan Hartman <[email protected]>
6
 *
7
 * This program is free software; you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation; either version 2 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License along
18
 * with this program; if not, write to the Free Software Foundation, Inc.,
19
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
 * http://www.gnu.org/copyleft/gpl.html
21
 *
22
 * @file
23
 * @ingroup SpecialPage
24
 */
25
26
/**
27
 * Implements Special:ComparePages
28
 *
29
 * @ingroup SpecialPage
30
 */
31
class SpecialComparePages extends SpecialPage {
32
33
	// Stored objects
34
	protected $opts, $skin;
0 ignored issues
show
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
35
36
	// Some internal settings
37
	protected $showNavigation = false;
38
39
	public function __construct() {
40
		parent::__construct( 'ComparePages' );
41
	}
42
43
	/**
44
	 * Show a form for filtering namespace and username
45
	 *
46
	 * @param string $par
47
	 * @return string
48
	 */
49
	public function execute( $par ) {
50
		$this->setHeaders();
51
		$this->outputHeader();
52
		$this->getOutput()->addModuleStyles( 'mediawiki.special.comparepages.styles' );
53
54
		$form = HTMLForm::factory( 'ooui', [
55
			'Page1' => [
56
				'type' => 'title',
57
				'name' => 'page1',
58
				'label-message' => 'compare-page1',
59
				'size' => '40',
60
				'section' => 'page1',
61
				'validation-callback' => [ $this, 'checkExistingTitle' ],
62
			],
63
			'Revision1' => [
64
				'type' => 'int',
65
				'name' => 'rev1',
66
				'label-message' => 'compare-rev1',
67
				'size' => '8',
68
				'section' => 'page1',
69
				'validation-callback' => [ $this, 'checkExistingRevision' ],
70
			],
71
			'Page2' => [
72
				'type' => 'title',
73
				'name' => 'page2',
74
				'label-message' => 'compare-page2',
75
				'size' => '40',
76
				'section' => 'page2',
77
				'validation-callback' => [ $this, 'checkExistingTitle' ],
78
			],
79
			'Revision2' => [
80
				'type' => 'int',
81
				'name' => 'rev2',
82
				'label-message' => 'compare-rev2',
83
				'size' => '8',
84
				'section' => 'page2',
85
				'validation-callback' => [ $this, 'checkExistingRevision' ],
86
			],
87
			'Action' => [
88
				'type' => 'hidden',
89
				'name' => 'action',
90
			],
91
			'Diffonly' => [
92
				'type' => 'hidden',
93
				'name' => 'diffonly',
94
			],
95
			'Unhide' => [
96
				'type' => 'hidden',
97
				'name' => 'unhide',
98
			],
99
		], $this->getContext(), 'compare' );
100
		$form->setSubmitTextMsg( 'compare-submit' );
101
		$form->suppressReset();
102
		$form->setMethod( 'get' );
103
		$form->setSubmitCallback( [ __CLASS__, 'showDiff' ] );
104
105
		$form->loadData();
106
		$form->displayForm( '' );
107
		$form->trySubmit();
108
	}
109
110
	public static function showDiff( $data, HTMLForm $form ) {
111
		$rev1 = self::revOrTitle( $data['Revision1'], $data['Page1'] );
112
		$rev2 = self::revOrTitle( $data['Revision2'], $data['Page2'] );
113
114
		if ( $rev1 && $rev2 ) {
115
			$revision = Revision::newFromId( $rev1 );
116
117
			if ( $revision ) { // NOTE: $rev1 was already checked, should exist.
118
				$contentHandler = $revision->getContentHandler();
119
				$de = $contentHandler->createDifferenceEngine( $form->getContext(),
120
					$rev1,
121
					$rev2,
122
					null, // rcid
123
					( $data['Action'] == 'purge' ),
124
					( $data['Unhide'] == '1' )
125
				);
126
				$de->showDiffPage( true );
127
			}
128
		}
129
	}
130
131
	public static function revOrTitle( $revision, $title ) {
132
		if ( $revision ) {
133
			return $revision;
134
		} elseif ( $title ) {
135
			$title = Title::newFromText( $title );
136
			if ( $title instanceof Title ) {
137
				return $title->getLatestRevID();
138
			}
139
		}
140
141
		return null;
142
	}
143
144
	public function checkExistingTitle( $value, $alldata ) {
145
		if ( $value === '' || $value === null ) {
146
			return true;
147
		}
148
		$title = Title::newFromText( $value );
149
		if ( !$title instanceof Title ) {
150
			return $this->msg( 'compare-invalid-title' )->parseAsBlock();
151
		}
152
		if ( !$title->exists() ) {
153
			return $this->msg( 'compare-title-not-exists' )->parseAsBlock();
154
		}
155
156
		return true;
157
	}
158
159
	public function checkExistingRevision( $value, $alldata ) {
160
		if ( $value === '' || $value === null ) {
161
			return true;
162
		}
163
		$revision = Revision::newFromId( $value );
164
		if ( $revision === null ) {
165
			return $this->msg( 'compare-revision-not-exists' )->parseAsBlock();
166
		}
167
168
		return true;
169
	}
170
171
	protected function getGroupName() {
172
		return 'pagetools';
173
	}
174
}
175