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/RevisionDeleteUser.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
 * Backend functions for suppressing and unsuppressing all references to a given user.
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License along
16
 * with this program; if not, write to the Free Software Foundation, Inc.,
17
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
 * http://www.gnu.org/copyleft/gpl.html
19
 *
20
 * @file
21
 * @ingroup RevisionDelete
22
 */
23
24
/**
25
 * Backend functions for suppressing and unsuppressing all references to a given user,
26
 * used when blocking with HideUser enabled.  This was spun out of SpecialBlockip.php
27
 * in 1.18; at some point it needs to be rewritten to either use RevisionDelete abstraction,
28
 * or at least schema abstraction.
29
 *
30
 * @ingroup RevisionDelete
31
 */
32
class RevisionDeleteUser {
33
34
	/**
35
	 * Update *_deleted bitfields in various tables to hide or unhide usernames
36
	 * @param string $name Username
37
	 * @param int $userId User id
38
	 * @param string $op Operator '|' or '&'
39
	 * @param null|IDatabase $dbw If you happen to have one lying around
40
	 * @return bool
41
	 */
42
	private static function setUsernameBitfields( $name, $userId, $op, $dbw ) {
43
		if ( !$userId || ( $op !== '|' && $op !== '&' ) ) {
44
			return false; // sanity check
45
		}
46
		if ( !$dbw instanceof IDatabase ) {
47
			$dbw = wfGetDB( DB_MASTER );
48
		}
49
50
		# To suppress, we OR the current bitfields with Revision::DELETED_USER
51
		# to put a 1 in the username *_deleted bit. To unsuppress we AND the
52
		# current bitfields with the inverse of Revision::DELETED_USER. The
53
		# username bit is made to 0 (x & 0 = 0), while others are unchanged (x & 1 = x).
54
		# The same goes for the sysop-restricted *_deleted bit.
55
		$delUser = Revision::DELETED_USER | Revision::DELETED_RESTRICTED;
56
		$delAction = LogPage::DELETED_ACTION | Revision::DELETED_RESTRICTED;
57
		if ( $op == '&' ) {
58
			$delUser = $dbw->bitNot( $delUser );
0 ignored issues
show
It seems like $dbw is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
59
			$delAction = $dbw->bitNot( $delAction );
60
		}
61
62
		# Normalize user name
63
		$userTitle = Title::makeTitleSafe( NS_USER, $name );
64
		$userDbKey = $userTitle->getDBkey();
65
66
		# Hide name from live edits
67
		$dbw->update(
68
			'revision',
69
			[ self::buildSetBitDeletedField( 'rev_deleted', $op, $delUser, $dbw ) ],
70
			[ 'rev_user' => $userId ],
71
			__METHOD__ );
72
73
		# Hide name from deleted edits
74
		$dbw->update(
75
			'archive',
76
			[ self::buildSetBitDeletedField( 'ar_deleted', $op, $delUser, $dbw ) ],
77
			[ 'ar_user_text' => $name ],
78
			__METHOD__
79
		);
80
81
		# Hide name from logs
82
		$dbw->update(
83
			'logging',
84
			[ self::buildSetBitDeletedField( 'log_deleted', $op, $delUser, $dbw ) ],
85
			[ 'log_user' => $userId, 'log_type != ' . $dbw->addQuotes( 'suppress' ) ],
86
			__METHOD__
87
		);
88
		$dbw->update(
89
			'logging',
90
			[ self::buildSetBitDeletedField( 'log_deleted', $op, $delAction, $dbw ) ],
91
			[ 'log_namespace' => NS_USER, 'log_title' => $userDbKey,
92
				'log_type != ' . $dbw->addQuotes( 'suppress' ) ],
93
			__METHOD__
94
		);
95
96
		# Hide name from RC
97
		$dbw->update(
98
			'recentchanges',
99
			[ self::buildSetBitDeletedField( 'rc_deleted', $op, $delUser, $dbw ) ],
100
			[ 'rc_user_text' => $name ],
101
			__METHOD__
102
		);
103
		$dbw->update(
104
			'recentchanges',
105
			[ self::buildSetBitDeletedField( 'rc_deleted', $op, $delAction, $dbw ) ],
106
			[ 'rc_namespace' => NS_USER, 'rc_title' => $userDbKey, 'rc_logid > 0' ],
107
			__METHOD__
108
		);
109
110
		# Hide name from live images
111
		$dbw->update(
112
			'oldimage',
113
			[ self::buildSetBitDeletedField( 'oi_deleted', $op, $delUser, $dbw ) ],
114
			[ 'oi_user_text' => $name ],
115
			__METHOD__
116
		);
117
118
		# Hide name from deleted images
119
		$dbw->update(
120
			'filearchive',
121
			[ self::buildSetBitDeletedField( 'fa_deleted', $op, $delUser, $dbw ) ],
122
			[ 'fa_user_text' => $name ],
123
			__METHOD__
124
		);
125
		# Done!
126
		return true;
127
	}
128
129
	private static function buildSetBitDeletedField( $field, $op, $value, $dbw ) {
130
		return $field . ' = ' . ( $op === '&'
131
			? $dbw->bitAnd( $field, $value )
132
			: $dbw->bitOr( $field, $value ) );
133
	}
134
135
	public static function suppressUserName( $name, $userId, $dbw = null ) {
136
		return self::setUsernameBitfields( $name, $userId, '|', $dbw );
137
	}
138
139
	public static function unsuppressUserName( $name, $userId, $dbw = null ) {
140
		return self::setUsernameBitfields( $name, $userId, '&', $dbw );
141
	}
142
}
143