Issues (7)

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 (4 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 SUC;
4
5
use Hooks;
6
use MWNamespace;
7
8
/**
9
 * @license GNU GPL v2+
10
 * @since 1.0
11
 *
12
 * @author mwjames
13
 */
14
class HookRegistry {
15
16
	/**
17
	 * @var array
18
	 */
19
	private $handlers = array();
20
21
	/**
22
	 * @var Options
23
	 */
24
	private $options;
25
26
	/**
27
	 * @since 1.0
28
	 *
29
	 * @param Options $options
30
	 */
31 2
	public function __construct( Options $options ) {
32 2
		$this->options = $options;
33
34 2
		$this->addCallbackHandlers(
35 2
			$this->options
36 2
		);
37 2
	}
38
39
	/**
40
	 * @since  1.0
41
	 *
42
	 * @param string $name
43
	 *
44
	 * @return boolean
45
	 */
46 1
	public function isRegistered( $name ) {
47 1
		return Hooks::isRegistered( $name );
48
	}
49
50
	/**
51
	 * @since  1.0
52
	 */
53 1
	public function clear() {
54 1
		foreach ( $this->handlers as $name => $callback ) {
55 1
			Hooks::clear( $name );
56 1
		}
57 1
	}
58
59
	/**
60
	 * @since  1.0
61
	 *
62
	 * @param string $name
63
	 *
64
	 * @return Callable|false
65
	 */
66 1
	public function getHandlerFor( $name ) {
67 1
		return isset( $this->handlers[$name] ) ? $this->handlers[$name] : false;
68
	}
69
70
	/**
71
	 * @since  1.0
72
	 */
73 1
	public function register() {
74 1
		foreach ( $this->handlers as $name => $callback ) {
75 1
			Hooks::register( $name, $callback );
76 1
		}
77 1
	}
78
79 2
	private function addCallbackHandlers( $options ) {
80
81
		/**
82
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforePageDisplay
83
		 */
84 2
		$this->handlers['BeforePageDisplay'] = function ( &$outputPage, &$skin ) {
0 ignored issues
show
The parameter $skin is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
85
86 1
			$outputPage->addModuleStyles( 'ext.summary.cards.styles' );
87
88 1
			$outputPage->addModules(
89
				array(
90
					'ext.summary.cards'
91 1
				)
92 1
			);
93
94 1
			return true;
95
		};
96
97
		/**
98
		 * Hook: NewRevisionFromEditComplete called when a revision was inserted
99
		 * due to an edit
100
		 *
101
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/NewRevisionFromEditComplete
102
		 */
103
		$this->handlers['NewRevisionFromEditComplete'] = function ( $wikiPage, $revision, $baseId, $user ) use( $options ) {
0 ignored issues
show
The parameter $revision is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $baseId is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $user is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
104 1
			return CacheHelper::newFromOptions( $options )->invalidateCache( $wikiPage->getTitle() );
105
		};
106
107
		/**
108
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/GetPreferences
109
		 */
110 2
		$this->handlers['GetPreferences'] = function ( $user, &$preferences ) {
111
112
			// Option to enable tooltip info
113 1
			$preferences['suc-tooltip-disabled'] = array(
114 1
				'type'          => 'toggle',
115 1
				'label-message' => 'suc-tooltip-disabled',
116 1
				'section'       => 'rendering/suc-options',
117
			);
118
119 1
			return true;
120
		};
121
122
		/**
123
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
124
		 */
125
		$this->handlers['ResourceLoaderGetConfigVars'] = function ( &$vars ) use ( $options ) {
126
127 1
			$contentLanguage = $GLOBALS['wgContLang'];
128 1
			$enabledNamespaceWithTemplate = array();
129 1
			$namespacesByContentLanguage = array();
130
131 1
			foreach ( $options->get( 'enabledNamespaceWithTemplate' ) as $ns => $template ) {
132
				$enabledNamespaceWithTemplate[$contentLanguage->getNsText( $ns )] = $template;
133 1
			}
134
135
			// Get literals to match and split when comparing href's during the
136
			// JS parse process
137 1
			foreach ( MWNamespace::getCanonicalNamespaces() as $ns => $name ) {
138 1
				$namespacesByContentLanguage[$contentLanguage->getNsText( $ns )] = $name;
139 1
			}
140
141 1
			$vars['ext.summaryCards.config'] = array(
142 1
				'tooltipRequestCacheTTL'          => $options->get( 'tooltipRequestCacheTTL' ),
143 1
				'cachePrefix'                     => $options->get( 'cachePrefix' ),
144 1
				'enabledForAnonUsers'             => $options->get( 'enabledForAnonUsers' ),
145 1
				'enabledNamespaceWithTemplate'    => $enabledNamespaceWithTemplate,
146 1
				'namespacesByContentLanguage'     => $namespacesByContentLanguage,
147 1
				'namespacesByCanonicalIdentifier' => array_flip( $namespacesByContentLanguage )
148 1
			);
149
150 1
			return true;
151
		};
152 2
	}
153
154
}
155