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.

maintenance/language/checkDupeMessages.php (1 issue)

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
 * Print out duplicates in message array
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 MaintenanceLanguage
22
 */
23
24
$optionsWithArgs = [ 'lang', 'clang', 'mode' ];
25
require_once __DIR__ . '/../commandLine.inc';
26
$messagesDir = __DIR__ . '/../../languages/messages/';
27
$runTest = false;
28
$run = false;
29
$runMode = 'text';
30
31
// Check parameters
32
if ( isset( $options['lang'] ) && isset( $options['clang'] ) ) {
33
	if ( !isset( $options['mode'] ) ) {
34
		$runMode = 'text';
35
	} else {
36
		if ( !strcmp( $options['mode'], 'wiki' ) ) {
37
			$runMode = 'wiki';
38
		} elseif ( !strcmp( $options['mode'], 'php' ) ) {
39
			$runMode = 'php';
40
		} elseif ( !strcmp( $options['mode'], 'raw' ) ) {
41
			$runMode = 'raw';
42
		} else {
0 ignored issues
show
This else statement is empty and can be removed.

This check looks for the else branches of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These else branches can be removed.

if (rand(1, 6) > 3) {
print "Check failed";
} else {
    //print "Check succeeded";
}

could be turned into

if (rand(1, 6) > 3) {
    print "Check failed";
}

This is much more concise to read.

Loading history...
43
		}
44
	}
45
	$runTest = true;
46
} else {
47
	echo <<<TEXT
48
Run this script to print out the duplicates against a message array.
49
Parameters:
50
	* lang:  Language code to be checked.
51
	* clang: Language code to be compared.
52
Options:
53
	* mode:  Output format, can be either:
54
		* text:   Text output on the console (default)
55
		* wiki:   Wiki format, with * at beginning of each line
56
		* php:    Output text as PHP syntax in an array named \$dupeMessages
57
		* raw:    Raw output for duplicates
58
TEXT;
59
}
60
61
// Check file exists
62
if ( $runTest ) {
63
	$langCode = $options['lang'];
64
	$langCodeC = $options['clang'];
65
	$langCodeF = ucfirst( strtolower( preg_replace( '/-/', '_', $langCode ) ) );
66
	$langCodeFC = ucfirst( strtolower( preg_replace( '/-/', '_', $langCodeC ) ) );
67
	$messagesFile = $messagesDir . 'Messages' . $langCodeF . '.php';
68
	$messagesFileC = $messagesDir . 'Messages' . $langCodeFC . '.php';
69
	if ( file_exists( $messagesFile ) && file_exists( $messagesFileC ) ) {
70
		$run = true;
71
	} else {
72
		echo "Messages file(s) could not be found.\nMake sure both files are exists.\n";
73
	}
74
}
75
76
// Run to check the dupes
77
if ( $run ) {
78
	if ( !strcmp( $runMode, 'wiki' ) ) {
79
		$runMode = 'wiki';
80
	} elseif ( !strcmp( $runMode, 'raw' ) ) {
81
		$runMode = 'raw';
82
	}
83
	include $messagesFile;
84
	$messageExist = isset( $messages );
85
	if ( $messageExist ) {
86
		$wgMessages[$langCode] = $messages;
87
	}
88
	include $messagesFileC;
89
	$messageCExist = isset( $messages );
90
	if ( $messageCExist ) {
91
		$wgMessages[$langCodeC] = $messages;
92
	}
93
	$count = 0;
94
95
	if ( ( $messageExist ) && ( $messageCExist ) ) {
96
97
		if ( !strcmp( $runMode, 'php' ) ) {
98
			print "<?php\n";
99
			print '$dupeMessages = [' . "\n";
100
		}
101
		foreach ( $wgMessages[$langCodeC] as $key => $value ) {
102
			foreach ( $wgMessages[$langCode] as $ckey => $cvalue ) {
103
				if ( !strcmp( $key, $ckey ) ) {
104
					if ( ( !strcmp( $key, $ckey ) ) && ( !strcmp( $value, $cvalue ) ) ) {
105
						if ( !strcmp( $runMode, 'raw' ) ) {
106
							print "$key\n";
107
						} elseif ( !strcmp( $runMode, 'php' ) ) {
108
							print "'$key' => '',\n";
109
						} elseif ( !strcmp( $runMode, 'wiki' ) ) {
110
							$uKey = ucfirst( $key );
111
							print "* MediaWiki:$uKey/$langCode\n";
112
						} else {
113
							print "* $key\n";
114
						}
115
						$count++;
116
					}
117
				}
118
			}
119
		}
120
		if ( !strcmp( $runMode, 'php' ) ) {
121
			print "];\n";
122
		}
123
		if ( !strcmp( $runMode, 'text' ) ) {
124
			if ( $count == 1 ) {
125
				echo "\nThere are $count duplicated message in $langCode, against to $langCodeC.\n";
126
			} else {
127
				echo "\nThere are $count duplicated messages in $langCode, against to $langCodeC.\n";
128
			}
129
		}
130
	} else {
131
		if ( !$messageExist ) {
132
			echo "There are no messages defined in $langCode.\n";
133
		}
134
		if ( !$messageCExist ) {
135
			echo "There are no messages defined in $langCodeC.\n";
136
		}
137
	}
138
}
139