Issues (20)

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 (1 issue)

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 SIL;
4
5
use Onoi\Cache\Cache;
6
use SMW\Store;
7
use SMW\ApplicationFactory;
8
use SMW\InMemoryPoolCache;
9
use SIL\Search\SearchResultModifier;
10
use SIL\Search\LanguageResultMatchFinder;
11
use SIL\Category\LanguageFilterCategoryPage;
12
use Hooks;
13
use Language;
14
15
/**
16
 * @license GNU GPL v2+
17
 * @since 1.0
18
 *
19
 * @author mwjames
20
 */
21
class HookRegistry {
22
23
	/**
24
	 * @var array
25
	 */
26
	private $handlers = [];
27
28
	/**
29
	 * @since 1.0
30
	 *
31
	 * @param Store $store
32
	 * @param Cache $cache
33
	 * @param CacheKeyProvider $cacheKeyProvider
34
	 */
35 2
	public function __construct( Store $store, Cache $cache, CacheKeyProvider $cacheKeyProvider ) {
36 2
		$this->addCallbackHandlers( $store, $cache, $cacheKeyProvider );
37 2
	}
38
39
	/**
40
	 * @since  1.1
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.1
52
	 *
53
	 * @param string $name
54
	 *
55
	 * @return Callable|false
56
	 */
57 1
	public function getHandlerFor( $name ) {
58 1
		return isset( $this->handlers[$name] ) ? $this->handlers[$name] : false;
59
	}
60
61
	/**
62
	 * @since  1.0
63
	 */
64 1
	public function register() {
65 1
		foreach ( $this->handlers as $name => $callback ) {
66 1
			Hooks::register( $name, $callback );
67
		}
68 1
	}
69
70
	/**
71
	 * @since  1.0
72
	 *
73
	 * @param array &$configuration
74
	 */
75 3
	public static function onBeforeConfigCompletion( &$config ) {
76
77 3
		if ( !isset( $config['smwgFulltextSearchPropertyExemptionList'] ) ) {
78
			return;
79
		}
80
81
		// Exclude those properties from indexing
82 3
		$config['smwgFulltextSearchPropertyExemptionList'] = array_merge(
83 3
			$config['smwgFulltextSearchPropertyExemptionList'],
84 3
			[ PropertyRegistry::SIL_IWL_LANG, PropertyRegistry::SIL_ILL_LANG ]
85
		);
86 3
	}
87
88 3
	private function addCallbackHandlers( $store, $cache, $cacheKeyProvider ) {
89
90 2
		$languageTargetLinksCache = new LanguageTargetLinksCache(
91 2
			$cache,
92
			$cacheKeyProvider
93
		);
94
95 2
		$interlanguageLinksLookup = new InterlanguageLinksLookup(
96 2
			$languageTargetLinksCache
97
		);
98
99 2
		$interlanguageLinksLookup->setStore( $store );
100
101
		/**
102
		 * @see https://github.com/SemanticMediaWiki/SemanticMediaWiki/blob/master/docs/technical/hooks.md
103
		 */
104 3
		$this->handlers['SMW::Property::initProperties'] = function ( $baseRegistry ) {
105
106 3
			$propertyRegistry = new PropertyRegistry();
107
108 3
			$propertyRegistry->register(
109 3
				$baseRegistry
110
			);
111
112 3
			return true;
113
		};
114
115
		/**
116
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticleFromTitle
117
		 */
118 3
		$this->handlers['ArticleFromTitle'] = function ( $title, &$page ) use( $interlanguageLinksLookup ) {
119
120 3
			$languageFilterCategoryPage = new LanguageFilterCategoryPage( $title );
121 3
			$languageFilterCategoryPage->isCategoryFilterByLanguage( $GLOBALS['silgEnabledCategoryFilterByLanguage'] );
122 3
			$languageFilterCategoryPage->modifyCategoryView( $page, $interlanguageLinksLookup );
123
124 3
			return true;
125
		};
126
127 2
		$this->registerInterlanguageParserHooks( $interlanguageLinksLookup );
128 2
	}
129
130 3
	private function registerInterlanguageParserHooks( InterlanguageLinksLookup $interlanguageLinksLookup ) {
131
132 2
		$pageContentLanguageOnTheFlyModifier = new PageContentLanguageOnTheFlyModifier(
133 2
			$interlanguageLinksLookup,
134 2
			InMemoryPoolCache::getInstance()->getPoolCacheFor( PageContentLanguageOnTheFlyModifier::POOLCACHE_ID )
0 ignored issues
show
Deprecated Code introduced by
The method SMW\InMemoryPoolCache::getPoolCacheFor() has been deprecated with message: since 2.5, use InMemoryPoolCache::getPoolCacheById

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
135
		);
136
137
		/**
138
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserFirstCallInit
139
		 */
140 1
		$this->handlers['ParserFirstCallInit'] = function ( &$parser ) use( $interlanguageLinksLookup, $pageContentLanguageOnTheFlyModifier ) {
141
142 1
			$parserFunctionFactory = new ParserFunctionFactory();
143
144 1
			list( $name, $definition, $flag ) = $parserFunctionFactory->newInterlanguageLinkParserFunctionDefinition(
145 1
				$interlanguageLinksLookup,
146
				$pageContentLanguageOnTheFlyModifier
147
			);
148
149 1
			$parser->setFunctionHook( $name, $definition, $flag );
150
151 1
			list( $name, $definition, $flag ) = $parserFunctionFactory->newInterlanguageListParserFunctionDefinition(
152 1
				$interlanguageLinksLookup
153
			);
154
155 1
			$parser->setFunctionHook( $name, $definition, $flag );
156
157 1
			list( $name, $definition, $flag ) = $parserFunctionFactory->newAnnotatedLanguageParserFunctionDefinition(
158 1
				$interlanguageLinksLookup
159
			);
160
161 1
			$parser->setFunctionHook( $name, $definition, $flag );
162
163 1
			return true;
164
		};
165
166
		/**
167
		 * https://www.mediawiki.org/wiki/Manual:Hooks/ArticleDelete
168
		 */
169 3
		$this->handlers['SMW::SQLStore::BeforeDeleteSubjectComplete'] = function ( $store, $title ) use ( $interlanguageLinksLookup ) {
170
171 3
			$interlanguageLinksLookup->setStore( $store );
172 3
			$interlanguageLinksLookup->resetLookupCacheBy( $title );
173
174 3
			return true;
175
		};
176
177
		/**
178
		 * https://www.mediawiki.org/wiki/Manual:Hooks/TitleMoveComplete
179
		 */
180 1
		$this->handlers['SMW::SQLStore::BeforeChangeTitleComplete'] = function ( $store, $oldTitle, $newTitle, $pageid, $redirid ) use ( $interlanguageLinksLookup ) {
181
182 1
			$interlanguageLinksLookup->setStore( $store );
183
184 1
			$interlanguageLinksLookup->resetLookupCacheBy( $oldTitle );
185 1
			$interlanguageLinksLookup->resetLookupCacheBy( $newTitle );
186
187 1
			return true;
188
		};
189
190
		/**
191
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/ArticlePurge
192
		 */
193 1
		$this->handlers['ArticlePurge']= function ( &$wikiPage ) use ( $interlanguageLinksLookup ) {
194
195 1
			$interlanguageLinksLookup->resetLookupCacheBy(
196 1
				$wikiPage->getTitle()
197
			);
198
199 1
			return true;
200
		};
201
202
		/**
203
		 * https://www.mediawiki.org/wiki/Manual:Hooks/NewRevisionFromEditComplete
204
		 */
205 3
		$this->handlers['NewRevisionFromEditComplete'] = function ( $wikiPage ) use ( $interlanguageLinksLookup ) {
206
207 3
			$interlanguageLinksLookup->resetLookupCacheBy(
208 3
				$wikiPage->getTitle()
209
			);
210
211 3
			return true;
212
		};
213
214
		/**
215
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateGetLanguageLink
216
		 */
217 1
		$this->handlers['SkinTemplateGetLanguageLink'] = function ( &$languageLink, $languageLinkTitle, $title ) {
218
219 1
			$siteLanguageLinkModifier = new SiteLanguageLinkModifier(
220 1
				$languageLinkTitle,
221
				$title
222
			);
223
224 1
			$siteLanguageLinkModifier->modifyLanguageLink( $languageLink );
225
226 1
			return true;
227
		};
228
229
		/**
230
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/PageContentLanguage
231
		 */
232 3
		$this->handlers['PageContentLanguage'] = function ( $title, Language &$pageLang ) use ( $pageContentLanguageOnTheFlyModifier ) {
233
234
		    // PageContentLanguage now requires pageLang of type Language
235
            // https://phabricator.wikimedia.org/T214358 
236 3
			$pageLang = Language::factory( $pageContentLanguageOnTheFlyModifier->getPageContentLanguage(
237 3
				$title,
238
				$pageLang
239
			) );
240
241 3
			return true;
242
		};
243
244
		/**
245
		 * @see https://www.mediawiki.org/wiki/Manual:Hooks/ParserAfterTidy
246
		 */
247 3
		$this->handlers['ParserAfterTidy'] = function ( &$parser, &$text ) {
248
249 3
			$parserData = ApplicationFactory::getInstance()->newParserData(
250 3
				$parser->getTitle(),
251 3
				$parser->getOutput()
252
			);
253
254 3
			$languageLinkAnnotator = new LanguageLinkAnnotator(
255 3
				$parserData
256
			);
257
258 3
			$interwikiLanguageLinkFetcher = new InterwikiLanguageLinkFetcher(
259 3
				$languageLinkAnnotator
260
			);
261
262 3
			$interwikiLanguageLinkFetcher->fetchLanguagelinksFromParserOutput(
263 3
				$parser->getOutput()
264
			);
265
266 3
			return true;
267
		};
268 2
	}
269
270
271
}
272