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/revisiondelete/RevDelRevisionItem.php (1 issue)

Labels
Severity

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
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License along
14
 * with this program; if not, write to the Free Software Foundation, Inc.,
15
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
 * http://www.gnu.org/copyleft/gpl.html
17
 *
18
 * @file
19
 * @ingroup RevisionDelete
20
 */
21
22
/**
23
 * Item class for a live revision table row
24
 */
25
class RevDelRevisionItem extends RevDelItem {
26
	/** @var Revision */
27
	public $revision;
28
29
	public function __construct( $list, $row ) {
30
		parent::__construct( $list, $row );
31
		$this->revision = new Revision( $row );
32
	}
33
34
	public function getIdField() {
35
		return 'rev_id';
36
	}
37
38
	public function getTimestampField() {
39
		return 'rev_timestamp';
40
	}
41
42
	public function getAuthorIdField() {
43
		return 'rev_user';
44
	}
45
46
	public function getAuthorNameField() {
47
		return 'rev_user_text';
48
	}
49
50
	public function canView() {
51
		return $this->revision->userCan( Revision::DELETED_RESTRICTED, $this->list->getUser() );
52
	}
53
54
	public function canViewContent() {
55
		return $this->revision->userCan( Revision::DELETED_TEXT, $this->list->getUser() );
56
	}
57
58
	public function getBits() {
59
		return $this->revision->getVisibility();
60
	}
61
62
	public function setBits( $bits ) {
63
		$dbw = wfGetDB( DB_MASTER );
64
		// Update revision table
65
		$dbw->update( 'revision',
66
			[ 'rev_deleted' => $bits ],
67
			[
68
				'rev_id' => $this->revision->getId(),
69
				'rev_page' => $this->revision->getPage(),
70
				'rev_deleted' => $this->getBits() // cas
71
			],
72
			__METHOD__
73
		);
74
		if ( !$dbw->affectedRows() ) {
75
			// Concurrent fail!
76
			return false;
77
		}
78
		// Update recentchanges table
79
		$dbw->update( 'recentchanges',
80
			[
81
				'rc_deleted' => $bits,
82
				'rc_patrolled' => 1
83
			],
84
			[
85
				'rc_this_oldid' => $this->revision->getId(), // condition
86
				// non-unique timestamp index
87
				'rc_timestamp' => $dbw->timestamp( $this->revision->getTimestamp() ),
88
			],
89
			__METHOD__
90
		);
91
92
		return true;
93
	}
94
95
	public function isDeleted() {
96
		return $this->revision->isDeleted( Revision::DELETED_TEXT );
97
	}
98
99
	public function isHideCurrentOp( $newBits ) {
100
		return ( $newBits & Revision::DELETED_TEXT )
101
			&& $this->list->getCurrent() == $this->getId();
0 ignored issues
show
The method getCurrent() does not exist on RevisionListBase. Did you maybe mean current()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
102
	}
103
104
	/**
105
	 * Get the HTML link to the revision text.
106
	 * Overridden by RevDelArchiveItem.
107
	 * @return string
108
	 */
109 View Code Duplication
	protected function getRevisionLink() {
110
		$date = htmlspecialchars( $this->list->getLanguage()->userTimeAndDate(
111
			$this->revision->getTimestamp(), $this->list->getUser() ) );
112
113
		if ( $this->isDeleted() && !$this->canViewContent() ) {
114
			return $date;
115
		}
116
117
		return Linker::linkKnown(
118
			$this->list->title,
119
			$date,
120
			[],
121
			[
122
				'oldid' => $this->revision->getId(),
123
				'unhide' => 1
124
			]
125
		);
126
	}
127
128
	/**
129
	 * Get the HTML link to the diff.
130
	 * Overridden by RevDelArchiveItem
131
	 * @return string
132
	 */
133 View Code Duplication
	protected function getDiffLink() {
134
		if ( $this->isDeleted() && !$this->canViewContent() ) {
135
			return $this->list->msg( 'diff' )->escaped();
136
		} else {
137
			return Linker::linkKnown(
138
					$this->list->title,
139
					$this->list->msg( 'diff' )->escaped(),
140
					[],
141
					[
142
						'diff' => $this->revision->getId(),
143
						'oldid' => 'prev',
144
						'unhide' => 1
145
					]
146
				);
147
		}
148
	}
149
150
	/**
151
	 * @return string A HTML <li> element representing this revision, showing
152
	 * change tags and everything
153
	 */
154 View Code Duplication
	public function getHTML() {
155
		$difflink = $this->list->msg( 'parentheses' )
156
			->rawParams( $this->getDiffLink() )->escaped();
157
		$revlink = $this->getRevisionLink();
158
		$userlink = Linker::revUserLink( $this->revision );
159
		$comment = Linker::revComment( $this->revision );
160
		if ( $this->isDeleted() ) {
161
			$revlink = "<span class=\"history-deleted\">$revlink</span>";
162
		}
163
		$content = "$difflink $revlink $userlink $comment";
164
		$attribs = [];
165
		$tags = $this->getTags();
166
		if ( $tags ) {
167
			list( $tagSummary, $classes ) = ChangeTags::formatSummaryRow(
168
				$tags,
169
				'revisiondelete',
170
				$this->list->getContext()
171
			);
172
			$content .= " $tagSummary";
173
			$attribs['class'] = implode( ' ', $classes );
174
		}
175
		return Xml::tags( 'li', $attribs, $content );
176
	}
177
178
	/**
179
	 * @return string Comma-separated list of tags
180
	 */
181
	public function getTags() {
182
		return $this->row->ts_tags;
183
	}
184
185
	public function getApiData( ApiResult $result ) {
186
		$rev = $this->revision;
187
		$user = $this->list->getUser();
188
		$ret = [
189
			'id' => $rev->getId(),
190
			'timestamp' => wfTimestamp( TS_ISO_8601, $rev->getTimestamp() ),
191
		];
192
		$ret += $rev->isDeleted( Revision::DELETED_USER ) ? [ 'userhidden' => '' ] : [];
193
		$ret += $rev->isDeleted( Revision::DELETED_COMMENT ) ? [ 'commenthidden' => '' ] : [];
194
		$ret += $rev->isDeleted( Revision::DELETED_TEXT ) ? [ 'texthidden' => '' ] : [];
195
		if ( $rev->userCan( Revision::DELETED_USER, $user ) ) {
196
			$ret += [
197
				'userid' => $rev->getUser( Revision::FOR_THIS_USER ),
198
				'user' => $rev->getUserText( Revision::FOR_THIS_USER ),
199
			];
200
		}
201
		if ( $rev->userCan( Revision::DELETED_COMMENT, $user ) ) {
202
			$ret += [
203
				'comment' => $rev->getComment( Revision::FOR_THIS_USER ),
204
			];
205
		}
206
207
		return $ret;
208
	}
209
}
210