Issues (23)

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.

src/Extension.php (2 issues)

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 SubPageList;
4
5
use Parser;
6
use ParserHooks\HookDefinition;
7
use ParserHooks\HookHandler;
8
use ParserHooks\HookRegistrant;
9
use SubPageList\Counter\SubPageCount;
10
use SubPageList\Counter\SubPageCounter;
11
use SubPageList\Lister\PageHierarchyCreator;
12
use SubPageList\Lister\SimpleSubPageFinder;
13
use SubPageList\Lister\SubPageList;
14
use SubPageList\Lister\UI\SubPageListRenderer;
15
use SubPageList\Lister\UI\WikitextSubPageListRenderer;
16
17
/**
18
 * Top level factory for the SubPageList extension.
19
 *
20
 * @since 1.0
21
 *
22
 * @licence GNU GPL v2+
23
 * @author Jeroen De Dauw < [email protected] >
24
 */
25
class Extension {
26
27
	/**
28
	 * @since 1.0
29
	 *
30
	 * @var Settings
31
	 */
32
	private $settings;
33
34 25
	public function __construct( Settings $settings ) {
35 25
		$this->settings = $settings;
36 25
	}
37
38
	/**
39
	 * @since 1.0
40
	 *
41
	 * @return Settings
42
	 */
43 5
	public function getSettings() {
44 5
		return $this->settings;
45
	}
46
47
	/**
48
	 * @since 1.0
49
	 *
50
	 * @return DBConnectionProvider
51
	 */
52 26
	public function getSlaveConnectionProvider() {
53 26
		return new LazyDBConnectionProvider( DB_REPLICA );
54
	}
55
56
	/**
57
	 * @since 1.0
58
	 *
59
	 * @return CacheInvalidator
60
	 */
61 1
	public function getCacheInvalidator() {
62 1
		return new SimpleCacheInvalidator( $this->getSubPageFinder() );
63
	}
64
65
	/**
66
	 * @return SimpleSubPageFinder
67
	 */
68 25
	public function getSubPageFinder() {
69 25
		return new SimpleSubPageFinder( $this->getSlaveConnectionProvider() );
70
	}
71
72
	/**
73
	 * @since 1.0
74
	 *
75
	 * @return SubPageCounter
76
	 */
77 24
	public function getSubPageCounter() {
78 24
		return new SimpleSubPageFinder( $this->getSlaveConnectionProvider() );
79
	}
80
81
	/**
82
	 * @since 1.0
83
	 *
84
	 * @return TitleFactory
85
	 */
86 24
	public function getTitleFactory() {
87 24
		return new TitleFactory();
88
	}
89
90
	/**
91
	 * @since 1.0
92
	 *
93
	 * @return HookHandler
94
	 */
95 24
	public function getCountHookHandler() {
96 24
		return new SubPageCount( $this->getSubPageCounter(), $this->getTitleFactory() );
97
	}
98
99
	/**
100
	 * @since 1.0
101
	 *
102
	 * @return HookHandler
103
	 */
104 24
	public function getListHookHandler() {
105 24
		return new SubPageList(
106 24
			$this->getSubPageFinder(),
107 24
			$this->getPageHierarchyCreator(),
108 24
			$this->newSubPageListRenderer(),
109 24
			$this->getTitleFactory()
110
		);
111
	}
112
113
	/**
114
	 * @since 1.0
115
	 *
116
	 * @return PageHierarchyCreator
117
	 */
118 24
	public function getPageHierarchyCreator() {
119 24
		return new PageHierarchyCreator( $this->getTitleFactory() );
120
	}
121
122
	/**
123
	 * @since 1.0
124
	 *
125
	 * @return SubPageListRenderer
126
	 */
127 24
	public function newSubPageListRenderer() {
128 24
		return new WikitextSubPageListRenderer();
129
	}
130
131
	/**
132
	 * @since 1.0
133
	 *
134
	 * @return HookDefinition
135
	 */
136 24
	public function getCountHookDefinition() {
137 24
		return new HookDefinition(
138 24
			'subpagecount',
139
			[
0 ignored issues
show
array('page' => array('d...pl-subpages-par-page')) is of type array<string,array<strin...ssage\":\"string\"}>"}>, but the function expects a array<integer,object<Par...essor\ParamDefinition>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
140
				'page' => [
141 24
					'default' => '',
142
					'aliases' => 'parent',
143
					'message' => 'spl-subpages-par-page',
144
				],
145
			],
146 24
			'page'
147
		);
148
	}
149
150
	/**
151
	 * @since 1.0
152
	 *
153
	 * @return HookDefinition
154
	 */
155 24
	public function getListHookDefinition() {
156 24
		$params = [];
157
158 24
		$params['page'] = [
159
			'aliases' => 'parent',
160
			'default' => '',
161
		];
162
163 24
		$params['showpage'] = [
164
			'type' => 'boolean',
165
			'aliases' => 'showparent',
166
			'default' => false,
167
		];
168
169 24
		$params['sort'] = [
170
			'aliases' => 'order',
171
			'values' => [ 'asc', 'desc' ],
172
			'tolower' => true,
173
			'default' => 'asc',
174
		];
175
176 24
		$params['intro'] = [
177
			'default' => '',
178
		];
179
180 24
		$params['outro'] = [
181
			'default' => '',
182
		];
183
184 24
		$params['links'] = [
185
			'type' => 'boolean',
186
			'aliases' => 'link',
187
			'default' => true,
188
		];
189
		
190 24
		$params['redirects'] = [
191
			'type' => 'boolean',
192
			'aliases' => 'redirect',
193
			'default' => false,
194
		];
195
196 24
		$params['default'] = [
197
			'default' => '',
198
		];
199
200 24
		$params['limit'] = [
201
			'type' => 'integer',
202
			'default' => 200,
203
			'range' => [ 1, 500 ],
204
		];
205
206 24
		$params['addlevel'] = [
207
			'type' => 'integer',
208
			'default' => 0,
209
			'range' => [ 0, 10 ],
210
		];
211
		
212 24
		$params['element'] = [
213
			'default' => 'div',
214
			'aliases' => [ 'div', 'p', 'span', 'none' ],
215
		];
216
217 24
		$params['class'] = [
218
			'default' => 'subpagelist',
219
		];
220
221 24
		$params['format'] = [
222
			'aliases' => 'liststyle',
223
			'values' => [
224
				'ul', 'unordered',
225
				'ol', 'ordered',
226
//				'list', 'bar' // TODO: re-implement support for these two
227
			],
228
			'tolower' => true,
229
			'default' => 'ul',
230
		];
231
232 24
		$params['pathstyle'] = [
233
			'aliases' => 'showpath',
234
			'values' => [
235
				'none', 'no',
236
				'subpagename', 'children', 'notparent',
237
				'pagename',
238
				'full',
239
				'fullpagename'
240
			],
241
			'tolower' => true,
242
			'default' => 'subpagename',
243
		];
244
245 24
		$params['kidsonly'] = [
246
			'type' => 'boolean',
247
			'default' => false,
248
		];
249
250 24
		$params['template'] = [
251
			'default' => '',
252
		];
253
254
		// TODO: re-implement support
255
//		$params['separator'] = array(
256
//			'aliases' => 'sep',
257
//			'default' => '&#160;ยท ',
258
//		);
259
260
		// Give grep a chance to find the usages:
261
		// spl-subpages-par-sort, spl-subpages-par-sortby, spl-subpages-par-format, spl-subpages-par-page,
262
		// spl-subpages-par-showpage, spl-subpages-par-pathstyle, spl-subpages-par-kidsonly, spl-subpages-par-limit,
263
		// spl-subpages-par-element, spl-subpages-par-class, spl-subpages-par-intro, spl-subpages-par-outro,
264
		// spl-subpages-par-default, spl-subpages-par-separator, spl-subpages-par-template, spl-subpages-par-links, spl-subpages-par-redirects
265 24
		foreach ( $params as $name => &$param ) {
266 24
			$param['message'] = 'spl-subpages-par-' . $name;
267
		}
268
269 24
		return new HookDefinition(
270 24
			[ 'subpagelist', 'splist', 'subpages' ],
271
			$params,
0 ignored issues
show
$params is of type array<string,array<strin...fault\":\"string\"}>"}>, but the function expects a array<integer,object<Par...essor\ParamDefinition>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
272 24
			[ 'page', 'format', 'pathstyle', 'sort' ]
273
		);
274
	}
275
276
	/**
277
	 * @since 0.1
278
	 *
279
	 * @param Parser $parser
280
	 *
281
	 * @return HookRegistrant
282
	 */
283 24
	public function getHookRegistrant( Parser &$parser ) {
284 24
		return new HookRegistrant( $parser );
285
	}
286
287
}
288