Issues (49)

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/HookRegistry.php (2 issues)

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 SMW\Notifications;
4
5
use SMW\Notifications\EchoPresentationModel;
6
use SMW\Notifications\EchoFormatter;
7
use SMW\Notifications\ChangeNotification\ChangeNotificationFilter;
8
use SMW\Notifications\DataValues\NotificationGroupValue;
9
use SMWDataItem as DataItem;
10
use Hooks;
11
use EchoEvent;
12
13
/**
14
 * @license GNU GPL v2+
15
 * @since 1.0
16
 *
17
 * @author mwjames
18
 */
19
class HookRegistry {
20
21
	/**
22
	 * @var array
23
	 */
24
	private $handlers = array();
25
26
	/**
27
	 * @since 1.0
28
	 *
29
	 * @param array $options
0 ignored issues
show
There is no parameter named $options. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
30
	 */
31 1
	public function __construct() {
32 1
		$this->addCallbackHandlers();
33 1
	}
34
35
	/**
36
	 * @since  1.0
37
	 */
38 1
	public function register() {
39 1
		foreach ( $this->handlers as $name => $callback ) {
40 1
			Hooks::register( $name, $callback );
41
		}
42 1
	}
43
44
	/**
45
	 * @since  1.0
46
	 *
47
	 * @param string $name
48
	 *
49
	 * @return boolean
50
	 */
51 1
	public function isRegistered( $name ) {
52 1
		return Hooks::isRegistered( $name );
53
	}
54
55
	/**
56
	 * @since  1.0
57
	 *
58
	 * @param string $name
59
	 *
60
	 * @return Callable|false
61
	 */
62 1
	public function getHandlerFor( $name ) {
63 1
		return isset( $this->handlers[$name] ) ? $this->handlers[$name] : false;
64
	}
65
66 1
	private function addCallbackHandlers() {
0 ignored issues
show
addCallbackHandlers uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
67
68 1
		$echoNotificationsManager = new EchoNotificationsManager();
69
70
		/**
71
		 * @see https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks.md
72
		 */
73 1
		$this->handlers['SMW::Property::initProperties'] = function ( $baseRegistry ) {
74
75 1
			$propertyRegistry = new PropertyRegistry();
76
77 1
			$propertyRegistry->registerTo(
78 1
				$baseRegistry
79
			);
80
81 1
			return true;
82
		};
83
84
		/**
85
		 * @see https://www.semantic-mediawiki.org/wiki/Hooks/SMW::DataType::initTypes
86
		 */
87 1
		$this->handlers['SMW::DataType::initTypes'] = function ( $dataTypeRegistry ) {
88
89 1
			$dataTypeRegistry->registerDatatype(
90 1
				NotificationGroupValue::TYPE_ID,
91 1
				'\SMW\Notifications\DataValues\NotificationGroupValue',
92 1
				DataItem::TYPE_BLOB
93
			);
94
95 1
			return true;
96
		};
97
98
		/**
99
		 * @see https://www.mediawiki.org/wiki/Notifications/Developer_guide
100
		 * @see https://www.mediawiki.org/wiki/Extension:Echo/BeforeCreateEchoEvent
101
		 *
102
		 * @param array &$notifications
103
		 * @param array &$notificationCategories
104
		 * @param array &$icons
105
		 */
106 1
		$this->handlers['BeforeCreateEchoEvent'] = function( array &$notifications, array &$notificationCategories, array &$icons ) use ( $echoNotificationsManager ) {
107
108 1
			$echoNotificationsManager->initNotificationsDefinitions(
109 1
				$notifications,
110 1
				$notificationCategories,
111 1
				$icons
112
			);
113
114 1
			return true;
115
		};
116
117
		/**
118
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/UserGetDefaultOptions
119
		 *
120
		 * @param array[] &$defaultOptions
121
		 */
122 1
		$this->handlers['UserGetDefaultOptions'] = function( array &$defaultOptions ) use ( $echoNotificationsManager ) {
123 1
			$echoNotificationsManager->addDefaultOptions( $defaultOptions );
124 1
			return true;
125
		};
126
127
		/**
128
		 * @see https://www.mediawiki.org/wiki/Notifications/Developer_guide#Bundled_notifications
129
		 *
130
		 * @param EchoEvent $event
131
		 * @param string &$bundleString
132
		 */
133 1
		$this->handlers['EchoGetBundleRules'] = function( EchoEvent $event, &$bundleString ) use ( $echoNotificationsManager ) {
134 1
			$echoNotificationsManager->getNotificationsBundle( $event, $bundleString );
135 1
			return true;
136
		};
137
138
		/**
139
		 * @see https://www.mediawiki.org/wiki/Notifications/Developer_guide#Bundled_notifications
140
		 *
141
		 * @param EchoEvent $event
142
		 * @param array &$users
143
		 */
144 1
		$this->handlers['EchoGetDefaultNotifiedUsers'] = function( EchoEvent $event, &$users ) use ( $echoNotificationsManager ) {
145 1
			$echoNotificationsManager->getDefaultRecipientsByType( $event, $users );
146 1
			return true;
147
		};
148
149
		/**
150
		 * @see https://www.semantic-mediawiki.org/wiki/Hooks/SMW::SQLStore::AfterDataUpdateComplete
151
		 */
152 1
		$this->handlers['SMW::SQLStore::AfterDataUpdateComplete'] = function ( $store, $semanticData, $compositePropertyTableDiffIterator ) use ( $echoNotificationsManager ) {
153
154 1
			$changeNotificationFilter = new ChangeNotificationFilter(
155 1
				$semanticData->getSubject(),
156 1
				$store
157
			);
158
159 1
			$changeNotificationFilter->setAgent(
160 1
				$GLOBALS['wgUser']
161
			);
162
163 1
			$changeNotificationFilter->setPropertyExemptionList(
164 1
				$GLOBALS['snogChangeNotificationDetectionPropertyExemptionList']
165
			);
166
167 1
			$changeNotificationFilter->isCommandLineMode(
168 1
				$GLOBALS['wgCommandLineMode']
169
			);
170
171 1
			$echoNotificationsManager->createEvent(
172 1
				$changeNotificationFilter->findChangeEvent( $compositePropertyTableDiffIterator )
173
			);
174
175 1
			return true;
176
		};
177
178 1
	}
179
180
}
181