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/mwdocgen.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
 * Generate class and file reference documentation for MediaWiki using doxygen.
4
 *
5
 * If the dot DOT language processor is available, attempt call graph
6
 * generation.
7
 *
8
 * Usage:
9
 *   php mwdocgen.php
10
 *
11
 * This program is free software; you can redistribute it and/or modify
12
 * it under the terms of the GNU General Public License as published by
13
 * the Free Software Foundation; either version 2 of the License, or
14
 * (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License along
22
 * with this program; if not, write to the Free Software Foundation, Inc.,
23
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
 * http://www.gnu.org/copyleft/gpl.html
25
 *
26
 * @file
27
 * @todo document
28
 * @ingroup Maintenance
29
 *
30
 * @author Antoine Musso <hashar at free dot fr>
31
 * @author Brion Vibber
32
 * @author Alexandre Emsenhuber
33
 * @version first release
34
 */
35
36
require_once __DIR__ . '/Maintenance.php';
37
38
/**
39
 * Maintenance script that builds doxygen documentation.
40
 * @ingroup Maintenance
41
 */
42
class MWDocGen extends Maintenance {
43
44
	/**
45
	 * Prepare Maintenance class
46
	 */
47
	public function __construct() {
48
		parent::__construct();
49
		$this->addDescription( 'Build doxygen documentation' );
50
51
		$this->addOption( 'doxygen',
52
			'Path to doxygen',
53
			false, true );
54
		$this->addOption( 'version',
55
			'Pass a MediaWiki version',
56
			false, true );
57
		$this->addOption( 'generate-man',
58
			'Whether to generate man files' );
59
		$this->addOption( 'file',
60
			"Only process given file or directory. Multiple values " .
61
			"accepted with comma separation. Path relative to \$IP.",
62
			false, true );
63
		$this->addOption( 'output',
64
			'Path to write doc to',
65
			false, true );
66
		$this->addOption( 'no-extensions',
67
			'Ignore extensions' );
68
	}
69
70
	public function getDbType() {
71
		return Maintenance::DB_NONE;
72
	}
73
74
	protected function init() {
75
		global $IP;
76
77
		$this->doxygen = $this->getOption( 'doxygen', 'doxygen' );
78
		$this->mwVersion = $this->getOption( 'version', 'master' );
79
80
		$this->input = '';
81
		$inputs = explode( ',', $this->getOption( 'file', '' ) );
82
		foreach ( $inputs as $input ) {
83
			# Doxygen inputs are space separted and double quoted
84
			$this->input .= " \"$IP/$input\"";
85
		}
86
87
		$this->output = $this->getOption( 'output', "$IP/docs" );
88
89
		$this->inputFilter = wfShellWikiCmd( $IP . '/maintenance/mwdoc-filter.php' );
0 ignored issues
show
The property inputFilter does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
90
		$this->template = $IP . '/maintenance/Doxyfile';
91
		$this->excludes = [
92
			'vendor',
93
			'node_modules',
94
			'images',
95
			'static',
96
		];
97
		$this->excludePatterns = [];
98
		if ( $this->hasOption( 'no-extensions' ) ) {
99
			$this->excludePatterns[] = 'extensions';
100
		}
101
102
		$this->doDot = `which dot`;
103
		$this->doMan = $this->hasOption( 'generate-man' );
104
	}
105
106
	public function execute() {
107
		global $IP;
108
109
		$this->init();
110
111
		# Build out directories we want to exclude
112
		$exclude = '';
113
		foreach ( $this->excludes as $item ) {
114
			$exclude .= " $IP/$item";
115
		}
116
117
		$excludePatterns = implode( ' ', $this->excludePatterns );
118
119
		$conf = strtr( file_get_contents( $this->template ),
120
			[
121
				'{{OUTPUT_DIRECTORY}}' => $this->output,
122
				'{{STRIP_FROM_PATH}}' => $IP,
123
				'{{CURRENT_VERSION}}' => $this->mwVersion,
124
				'{{INPUT}}' => $this->input,
125
				'{{EXCLUDE}}' => $exclude,
126
				'{{EXCLUDE_PATTERNS}}' => $excludePatterns,
127
				'{{HAVE_DOT}}' => $this->doDot ? 'YES' : 'NO',
128
				'{{GENERATE_MAN}}' => $this->doMan ? 'YES' : 'NO',
129
				'{{INPUT_FILTER}}' => $this->inputFilter,
130
			]
131
		);
132
133
		$tmpFile = tempnam( wfTempDir(), 'MWDocGen-' );
134
		if ( file_put_contents( $tmpFile, $conf ) === false ) {
135
			$this->error( "Could not write doxygen configuration to file $tmpFile\n",
136
				/** exit code: */ 1 );
137
		}
138
139
		$command = $this->doxygen . ' ' . $tmpFile;
140
		$this->output( "Executing command:\n$command\n" );
141
142
		$exitcode = 1;
143
		system( $command, $exitcode );
144
145
		$this->output( <<<TEXT
146
---------------------------------------------------
147
Doxygen execution finished.
148
Check above for possible errors.
149
150
You might want to delete the temporary file:
151
 $tmpFile
152
---------------------------------------------------
153
154
TEXT
155
		);
156
157
		if ( $exitcode !== 0 ) {
158
			$this->error( "Something went wrong (exit: $exitcode)\n",
159
				$exitcode );
160
		}
161
	}
162
}
163
164
$maintClass = 'MWDocGen';
165
require_once RUN_MAINTENANCE_IF_MAIN;
166