Issues (21)

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.

classes/CodeReview/Config.php (6 issues)

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
namespace CodeReview;
3
4
/**
5
 * Simple configuration container handling basic options parsing nad providing convenient methods.
6
 *
7
 * @property string|null $subPath
8
 * @property string|null $maxVersion
9
 * @property bool $includeDisabledPlugins
10
 * @property bool $findDeprecatedFunctions
11
 * @property bool $findPrivateFunctions
12
 * @property bool $fixProblems
13
 */
14
class Config {
15
16
	const T_PLUGINS_ALL = 0;
17
	const T_PLUGINS_ACTIVE = 1;
18
	const T_PLUGINS_INACTIVE = 2;
19
20
	/**
21
	 * @var array
22
	 */
23
	protected $options = array();
24
25
	/**
26
	 * @var callable
27
	 */
28
	protected $versionGetter = null;
29
30
	/**
31
	 * @param array $options
32
	 */
33 19
	public function __construct(array $options = array(), $versionGetter = null) {
34 19
		$this->options = (array)$options;
35
36 19
		if (is_callable($versionGetter)) {
37 16
			$this->versionGetter = $versionGetter;
38 16
		} else {
39
			//TODO possibly further decouple Elgg core dependency
40 3
			$this->versionGetter = 'elgg_get_version';
41
		}
42 19
	}
43
44
	/**
45
	 * @param $key
46
	 * @return mixed
47
	 */
48 14
	public function __get($key) {
49 14
		return isset($this->options[$key]) ? $this->options[$key] : null;
50
	}
51
52
	/**
53
	 * @param      $key
54
	 * @param null $default
55
	 * @return null
56
	 */
57 16
	public function getOption($key, $default = null) {
58 16
		return isset($this->options[$key]) ? $this->options[$key] : $default;
59
	}
60
61
	/**
62
	 * @param $key
63
	 * @param $value
64
	 */
65 13
	public function __set($key, $value) {
66 13
		$this->options[$key] = $value;
67 13
	}
68
69
	/**
70
	 * @param $type
71
	 * @return array
72
	 */
73 5
	public function getPluginIds($type) {
74 5
		$pluginsDirs = false;
75
76 5
		$config = \code_review::getConfig();
77
78
		switch ($type) {
79 5
			case self::T_PLUGINS_INACTIVE:
80 5
				$pluginsDirs = $this->getPluginIds(self::T_PLUGINS_ALL);
81 5
				$actives = call_user_func($config['plugins_getter'], 'active');
82 5
				foreach ($actives as $plugin) {
83 5
					if ($plugin instanceof \ElggPlugin) {
84
						$pluginsDirs = array_diff($pluginsDirs, array($plugin->getID()));
85
					} else {
86 5
						$pluginsDirs = array_diff($pluginsDirs, array($plugin));
87
					}
88 5
				}
89 5
				break;
90 5
			case self::T_PLUGINS_ACTIVE:
91 2
				$pluginsDirs = call_user_func($config['plugins_getter'], 'active');
92 2
				foreach ($pluginsDirs as $key => $plugin) {
93 2
					if ($plugin instanceof \ElggPlugin) {
94
						$pluginsDirs[$key] = $plugin->getID();
95
					}
96 2
				}
97 2
				break;
98 5
			case self::T_PLUGINS_ALL:
99 5
				$pluginsDirs = \code_review::getPluginDirsInDir($config['pluginspath']);
100 5
				break;
101
102
		}
103 5
		return $pluginsDirs;
104
	}
105
106
	/*
107
	 * Shorthand methods
108
	 */
109
110
	/**
111
	 * @param       $key
112
	 * @param array $array
113
	 * @param null  $default
114
	 * @param bool  $strict
115
	 * @return null
116
	 *
117
	 * Function is a part of Elgg framework with following license:
118
	 *
119
	 * Copyright (c) 2013. See COPYRIGHT.txt
120
	 * http://elgg.org/
121
	 *
122
	 * Permission is hereby granted, free of charge, to any person obtaining
123
	 * a copy of this software and associated documentation files (the
124
	 * "Software"), to deal in the Software without restriction, including
125
	 * without limitation the rights to use, copy, modify, merge, publish,
126
	 * distribute, sublicense, and/or sell copies of the Software, and to
127
	 * permit persons to whom the Software is furnished to do so, subject to
128
	 * the following conditions:
129
	 *
130
	 * The above copyright notice and this permission notice shall be
131
	 * included in all copies or substantial portions of the Software.
132
	 *
133
	 * Except as contained in this notice, the name(s) of the above copyright
134
	 * holders shall not be used in advertising or otherwise to promote the
135
	 * sale, use or other dealings in this Software without prior written
136
	 * authorization.
137
	 *
138
	 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
139
	 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
140
	 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
141
	 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
142
	 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
143
	 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
144
	 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
145
	 */
146 13
	private function elggExtract($key, array $array, $default = null, $strict = true) {
147 13
		if (!is_array($array)) {
148
			return $default;
149
		}
150
151 13
		if ($strict) {
152 13
			return (isset($array[$key])) ? $array[$key] : $default;
153
		} else {
154
			return (isset($array[$key]) && !empty($array[$key])) ? $array[$key] : $default;
155
		}
156
	}
157
158
	/**
159
	 * @param array $vars
160
	 */
161 13
	public function parseInput(array $vars) {
162
163
		//sanitize provided path
164 13
		$subPath = $this->elggExtract('subpath', $vars, '/');
0 ignored issues
show
Are you sure the assignment to $subPath is correct as $this->elggExtract('subpath', $vars, '/') (which targets CodeReview\Config::elggExtract()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
165 13
		$subPath = trim($subPath, '/\\');
166 13
		$subPath = str_replace('\\', '/', $subPath);
167 13
		$subPath = str_replace('..', '', $subPath);
168 13
		$subPath = $subPath . '/';
169
170 13
		$this->subPath = $subPath;
171 13
		$this->maxVersion = $this->elggExtract('version', $vars, '');
0 ignored issues
show
Are you sure the assignment to $this->maxVersion is correct as $this->elggExtract('version', $vars, '') (which targets CodeReview\Config::elggExtract()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
172 13
		$this->includeDisabledPlugins = $this->elggExtract('include_disabled_plugins', $vars, false);
0 ignored issues
show
Are you sure the assignment to $this->includeDisabledPlugins is correct as $this->elggExtract('incl...plugins', $vars, false) (which targets CodeReview\Config::elggExtract()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
173 13
		$this->findDeprecatedFunctions = $this->elggExtract('find_deprecated_functions', $vars, true);
0 ignored issues
show
Are you sure the assignment to $this->findDeprecatedFunctions is correct as $this->elggExtract('find...unctions', $vars, true) (which targets CodeReview\Config::elggExtract()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
174 13
		$this->findPrivateFunctions = $this->elggExtract('find_private_functions', $vars, true);
0 ignored issues
show
Are you sure the assignment to $this->findPrivateFunctions is correct as $this->elggExtract('find...unctions', $vars, true) (which targets CodeReview\Config::elggExtract()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
175 13
		$this->fixProblems = $this->elggExtract('fix_problems', $vars, false);
0 ignored issues
show
Are you sure the assignment to $this->fixProblems is correct as $this->elggExtract('fix_problems', $vars, false) (which targets CodeReview\Config::elggExtract()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
176 13
	}
177
178
	/**
179
	 * @return bool
180
	 */
181 14
	public function isFixProblemsEnabled() {
182 14
		return (bool)$this->getOption('fixProblems', false);
183
	}
184
185
	/**
186
	 * @return string
187
	 */
188 14
	public function getMaxVersion() {
189 14
		if ($this->maxVersion === '' || $this->maxVersion === null) {
190 3
			return call_user_func($this->versionGetter, true);
191
		}
192 12
		return $this->maxVersion;
193
	}
194
195
	/**
196
	 * @return string
197
	 */
198 14
	public function getSubPath() {
199 14
		return (string)$this->subPath;
200
	}
201
202
	/**
203
	 * @return bool
204
	 */
205 15
	public function isIncludeDisabledPluginsEnabled() {
206 15
		return (bool)$this->getOption('includeDisabledPlugins', false);
207
	}
208
209
	/**
210
	 * @return bool
211
	 */
212 15
	public function isSkipInactivePluginsEnabled() {
213 15
		return !$this->isIncludeDisabledPluginsEnabled();
214
	}
215
216
	/**
217
	 * @return bool
218
	 */
219 13
	public function isDeprecatedFunctionsTestEnabled() {
220 13
		return (bool)$this->getOption('findDeprecatedFunctions', true);
221
	}
222
223
	/**
224
	 * @return bool
225
	 */
226 13
	public function isPrivateFunctionsTestEnabled() {
227 13
		return (bool)$this->getOption('findPrivateFunctions', true);
228
	}
229
}