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.

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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 36 and the first side effect is on line 38.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * This file is the entry point for all API queries.
4
 *
5
 * It begins by checking whether the API is enabled on this wiki; if not,
6
 * it informs the user that s/he should set $wgEnableAPI to true and exits.
7
 * Otherwise, it constructs a new ApiMain using the parameter passed to it
8
 * as an argument in the URL ('?action=') and with write-enabled set to the
9
 * value of $wgEnableWriteAPI as specified in LocalSettings.php.
10
 * It then invokes "execute()" on the ApiMain object instance, which
11
 * produces output in the format specified in the URL.
12
 *
13
 * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
14
 *
15
 * This program is free software; you can redistribute it and/or modify
16
 * it under the terms of the GNU General Public License as published by
17
 * the Free Software Foundation; either version 2 of the License, or
18
 * (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License along
26
 * with this program; if not, write to the Free Software Foundation, Inc.,
27
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
 * http://www.gnu.org/copyleft/gpl.html
29
 *
30
 * @file
31
 */
32
33
use MediaWiki\Logger\LegacyLogger;
34
35
// So extensions (and other code) can check whether they're running in API mode
36
define( 'MW_API', true );
37
38
require __DIR__ . '/includes/WebStart.php';
39
40
$starttime = microtime( true );
41
42
// URL safety checks
43
if ( !$wgRequest->checkUrlExtension() ) {
44
	return;
45
}
46
47
// Verify that the API has not been disabled
48
if ( !$wgEnableAPI ) {
49
	header( $_SERVER['SERVER_PROTOCOL'] . ' 500 MediaWiki configuration Error', true, 500 );
50
	echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php'
51
		. '<pre><b>$wgEnableAPI=true;</b></pre>';
52
	die( 1 );
53
}
54
55
// Set a dummy $wgTitle, because $wgTitle == null breaks various things
56
// In a perfect world this wouldn't be necessary
57
$wgTitle = Title::makeTitle( NS_SPECIAL, 'Badtitle/dummy title for API calls set in api.php' );
58
59
// RequestContext will read from $wgTitle, but it will also whine about it.
60
// In a perfect world this wouldn't be necessary either.
61
RequestContext::getMain()->setTitle( $wgTitle );
62
63
try {
64
	/* Construct an ApiMain with the arguments passed via the URL. What we get back
65
	 * is some form of an ApiMain, possibly even one that produces an error message,
66
	 * but we don't care here, as that is handled by the ctor.
67
	 */
68
	$processor = new ApiMain( RequestContext::getMain(), $wgEnableWriteAPI );
69
70
	// Last chance hook before executing the API
71
	Hooks::run( 'ApiBeforeMain', [ &$processor ] );
72
	if ( !$processor instanceof ApiMain ) {
73
		throw new MWException( 'ApiBeforeMain hook set $processor to a non-ApiMain class' );
74
	}
75
} catch ( Exception $e ) {
76
	// Crap. Try to report the exception in API format to be friendly to clients.
77
	ApiMain::handleApiBeforeMainException( $e );
78
	$processor = false;
79
}
80
81
// Process data & print results
82
if ( $processor ) {
83
	$processor->execute();
84
}
85
86
// Log what the user did, for book-keeping purposes.
87
$endtime = microtime( true );
88
89
// Log the request
90
if ( $wgAPIRequestLog ) {
91
	$items = [
92
		wfTimestamp( TS_MW ),
93
		$endtime - $starttime,
94
		$wgRequest->getIP(),
95
		$wgRequest->getHeader( 'User-agent' )
96
	];
97
	$items[] = $wgRequest->wasPosted() ? 'POST' : 'GET';
98
	if ( $processor ) {
99
		try {
100
			$manager = $processor->getModuleManager();
101
			$module = $manager->getModule( $wgRequest->getVal( 'action' ), 'action' );
102
		} catch ( Exception $ex ) {
103
			$module = null;
104
		}
105
		if ( !$module || $module->mustBePosted() ) {
106
			$items[] = "action=" . $wgRequest->getVal( 'action' );
107
		} else {
108
			$items[] = wfArrayToCgi( $wgRequest->getValues() );
109
		}
110
	} else {
111
		$items[] = "failed in ApiBeforeMain";
112
	}
113
	LegacyLogger::emit( implode( ',', $items ) . "\n", $wgAPIRequestLog );
114
	wfDebug( "Logged API request to $wgAPIRequestLog\n" );
115
}
116
117
$mediawiki = new MediaWiki();
118
$mediawiki->doPostOutputShutdown( 'fast' );
119