Issues (1401)

Security Analysis    no request data  

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.

lib/includes/SettingsArray.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
namespace Wikibase\Lib;
4
5
use ArrayObject;
6
use Closure;
7
use MediaWiki\Logger\LoggerFactory;
8
use OutOfBoundsException;
9
use Psr\Log\LoggerInterface;
10
11
/**
12
 * Class representing a collection of settings.
13
 *
14
 * @note: settings can be dynamic: if a setting is given as a closure, the closure will be
15
 *        called to get the actual setting value the first time this setting is retrieved
16
 *        using getSetting(). The closure is called with the SettingsArray as the only argument.
17
 *
18
 * This program is free software; you can redistribute it and/or modify
19
 * it under the terms of the GNU General Public License as published by
20
 * the Free Software Foundation; either version 2 of the License, or
21
 * (at your option) any later version.
22
 *
23
 * This program is distributed in the hope that it will be useful,
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
 * GNU General Public License for more details.
27
 *
28
 * You should have received a copy of the GNU General Public License
29
 * along with this program; if not, write to the Free Software
30
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
31
 *
32
 * @license GPL-2.0-or-later
33
 * @author Jeroen De Dauw < [email protected] >
34
 * @author Daniel Kinzler
35
 */
36
class SettingsArray extends ArrayObject {
37
38
	/**
39
	 * @var LoggerInterface
40
	 */
41
	private $logger;
42
43
	public function __construct( array $input = [] ) {
44
		parent::__construct( $input );
45
46
		// TODO: Inject?!
47
		$this->logger = LoggerFactory::getInstance( 'Wikibase' );
48
	}
49
50
	/**
51
	 * Gets the value of the specified setting.
52
	 *
53
	 * @param string $settingName
54
	 *
55
	 * @throws OutOfBoundsException
56
	 * @return mixed
57
	 */
58
	public function getSetting( $settingName ) {
59
		if ( !$this->offsetExists( $settingName ) && !property_exists( $this, $settingName ) ) {
60
			throw new OutOfBoundsException( 'Attempt to get non-existing setting "' . $settingName . '"' );
61
		}
62
63
		$value = $this[$settingName];
64
65
		// Allow closures to be used for deferred evaluation
66
		// of "magic" (dynamic) defaults.
67
		if ( $value instanceof Closure ) {
68
			$value = $value( $this );
69
70
			if ( is_object( $value ) ) {
71
				$logValue = 'instance of ' . get_class( $value );
72
			} else {
73
				$logValue = var_export( $value, true );
74
			}
75
76
			$this->logger->debug(
77
				'{method}: setting {settingName} was given as a closure, resolve it to {logValue}',
78
				[
79
					'method' => __METHOD__,
80
					'settingName' => $settingName,
81
					'logValue' => $logValue,
82
				]
83
			);
84
85
			// only eval once, then remember the value
86
			$this->setSetting( $settingName, $value );
0 ignored issues
show
The call to the method Wikibase\Lib\SettingsArray::setSetting() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
87
		}
88
89
		return $value;
90
	}
91
92
	/**
93
	 * Sets the value of the specified setting.
94
	 *
95
	 * @param string $settingName
96
	 * @param mixed $settingValue The desired value. If this is a closure, the closure will be
97
	 *        called to get the actual setting value the first time this setting is retrieved
98
	 *        using getSetting(). The closure is called with this SettingsArray as the only argument.
99
	 */
100
	public function setSetting( $settingName, $settingValue ) {
101
		$this[$settingName] = $settingValue;
102
	}
103
104
	/**
105
	 * Returns if the specified settings is set or not.
106
	 *
107
	 * @param string $settingName
108
	 *
109
	 * @return boolean
110
	 */
111
	public function hasSetting( $settingName ) {
112
		return $this->offsetExists( $settingName );
113
	}
114
115
}
116