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.

repo/includes/GenericEventDispatcher.php (1 issue)

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
3
namespace Wikibase\Repo;
4
5
use InvalidArgumentException;
6
7
/**
8
 * Dispatches a notification to a set of watchers.
9
 *
10
 * @todo should go into MediaWiki core.
11
 *
12
 * @license GPL-2.0-or-later
13
 * @author Daniel Kinzler
14
 */
15
class GenericEventDispatcher {
16
17
	/**
18
	 * @var array
19
	 */
20
	private $watchers = [];
21
22
	/**
23
	 * @var int
24
	 */
25
	private $key = 0;
26
27
	/**
28
	 * @var string
29
	 */
30
	private $interface;
31
32
	/**
33
	 * @param string $interface the interface watchers must implement
34
	 */
35
	public function __construct( $interface ) {
36
		$this->interface = $interface;
37
	}
38
39
	/**
40
	 * Registers a watcher. The watcher will be called whenever
41
	 * the dispatch() method is called, until the watcher is unregistered.
42
	 *
43
	 * @param object $listener
44
	 *
45
	 * @throws InvalidArgumentException
46
	 * @return mixed The listener key, for removing the listener later.
47
	 */
48
	public function registerWatcher( $listener ) {
49
		if ( !is_subclass_of( $listener, $this->interface ) ) {
0 ignored issues
show
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if $this->interface can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
50
			throw new InvalidArgumentException( '$listener must implement ' . $this->interface );
51
		}
52
53
		$key = ++$this->key;
54
		$this->watchers[ $key ] = $listener;
55
		return $key;
56
	}
57
58
	/**
59
	 * Unregisters a watcher using its registration key. The watcher will no longer
60
	 * be called by dispatch().
61
	 *
62
	 * @param mixed $key A watcher key as returned by registerWatcher().
63
	 *
64
	 * @throws InvalidArgumentException
65
	 */
66
	public function unregisterWatcher( $key ) {
67
		if ( is_object( $key ) || is_array( $key ) ) {
68
			throw new InvalidArgumentException( '$key must be a primitive value' );
69
		}
70
71
		if ( isset( $this->watchers[$key] ) ) {
72
			unset( $this->watchers[$key] );
73
		}
74
	}
75
76
	/**
77
	 * Dispatches a notification to all registered watchers.
78
	 *
79
	 * @param string $event the name of the event, that is,
80
	 *        the name of the method to call on the watchers.
81
	 * @param mixed ...$args Any extra parameters are passed to the watcher method.
82
	 *
83
	 * @throws InvalidArgumentException
84
	 */
85
	public function dispatch( $event, ...$args ) {
86
		if ( !is_string( $event ) ) {
87
			throw new InvalidArgumentException( '$event must be a string' );
88
		}
89
90
		foreach ( $this->watchers as $watcher ) {
91
			$watcher->$event( ...$args );
92
		}
93
	}
94
95
}
96