Issues (51)

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.

SemanticMaps.php (1 issue)

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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 34 and the first side effect is on line 11.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/**
4
 * Initialization file for the Semantic Maps extension.
5
 *
6
 * @licence GNU GPL v2+
7
 * @author Jeroen De Dauw < [email protected] >
8
 */
9
10
if ( !defined( 'MEDIAWIKI' ) ) {
11
	die( 'Not an entry point.' );
12
}
13
14
if ( defined( 'SM_VERSION' ) ) {
15
	// Do not initialize more than once.
16
	return 1;
17
}
18
19
if ( version_compare( $GLOBALS['wgVersion'], '1.23c', '<' ) ) {
20
	throw new Exception(
21
		'This version of Semantic Maps requires MediaWiki 1.23 or above; use Semantic Maps 3.3.x for older versions.'
22
		. ' See https://github.com/SemanticMediaWiki/SemanticMaps/blob/master/INSTALL.md for more info.'
23
	);
24
}
25
26
if ( !defined( 'Maps_VERSION' ) && is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
27
	include_once( __DIR__ . '/vendor/autoload.php' );
28
}
29
30
if ( !defined( 'Maps_VERSION' ) ) {
31
	throw new Exception( 'You need to have Maps installed in order to use Semantic Maps' );
32
}
33
34
define( 'SM_VERSION', '3.4.2' );
35
36
require_once __DIR__ . '/SM_Settings.php';
37
38
SemanticMaps::newFromMediaWikiGlobals( $GLOBALS )->initExtension();
39
40
$GLOBALS['wgExtensionFunctions'][] = function() {
41
	// Hook for initializing the Geographical Data types.
42
	$GLOBALS['wgHooks']['SMW::DataType::initTypes'][] = 'SemanticMapsHooks::initGeoDataTypes';
43
44
	// Hook for defining the default query printer for queries that ask for geographical coordinates.
45
	$GLOBALS['wgHooks']['SMWResultFormat'][] = 'SemanticMapsHooks::addGeoCoordsDefaultFormat';
46
47
	// Hook for adding a Semantic Maps links to the Admin Links extension.
48
	$GLOBALS['wgHooks']['AdminLinks'][] = 'SemanticMapsHooks::addToAdminLinks';
49
50
	$GLOBALS['wgHooks']['sfFormPrinterSetup'][] = 'SemanticMaps\FormInputsSetup::run';
51
};
52
53
/**
54
 * @codeCoverageIgnore
55
 */
56
class SemanticMaps {
57
58
	private $mwGlobals;
59
60
	public static function newFromMediaWikiGlobals( array &$mwGlobals ) {
61
		return new self( $mwGlobals );
62
	}
63
64
	private function __construct( array &$mwGlobals ) {
65
		$this->mwGlobals =& $mwGlobals;
66
	}
67
68
	/**
69
	 * @since 3.4
70
	 */
71
	public function initExtension() {
72
		$this->mwGlobals['wgExtensionCredits']['semantic'][] = [
73
			'path' => __FILE__,
74
			'name' => 'Semantic Maps',
75
			'version' => SM_VERSION,
76
			'author' => [
77
				'[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]'
78
			],
79
			'url' => 'https://github.com/SemanticMediaWiki/SemanticMaps/blob/master/README.md#semantic-maps',
80
			'descriptionmsg' => 'semanticmaps-desc',
81
			'license-name'   => 'GPL-2.0+'
82
		];
83
84
		$this->registerResourceModules();
85
86
		$this->registerGoogleMaps();
87
		$this->registerLeaflet();
88
		$this->registerOpenLayers();
89
90
		$this->mwGlobals['smwgResultFormats']['kml'] = SMKMLPrinter::class;
91
92
		$this->mwGlobals['wgHooks']['MappingServiceLoad'][] = function() {
93
			$this->mwGlobals['smwgResultAliases'][$this->mwGlobals['egMapsDefaultServices']['qp']][] = 'map';
94
			SMMapPrinter::registerDefaultService( $this->mwGlobals['egMapsDefaultServices']['qp'] );
95
		};
96
97
		// Internationalization
98
		$this->mwGlobals['wgMessagesDirs']['SemanticMaps'] = __DIR__ . '/i18n';
99
	}
100
101
	private function registerResourceModules() {
102
		$moduleTemplate = [
103
			'position' => 'bottom',
104
			'group' => 'ext.semanticmaps',
105
		];
106
107
		$this->mwGlobals['wgResourceModules']['ext.sm.forminputs'] = $moduleTemplate + [
108
			'dependencies' => [ 'ext.maps.coord' ],
109
			'localBasePath' => __DIR__ . '/src/forminputs',
110
			'remoteExtPath' => 'SemanticMaps/src/forminputs',
111
			'scripts' => [
112
				'jquery.mapforminput.js'
113
			],
114
			'messages' => [
115
				'semanticmaps_enteraddresshere',
116
				'semanticmaps-updatemap',
117
				'semanticmaps_lookupcoordinates',
118
				'semanticmaps-forminput-remove',
119
				'semanticmaps-forminput-add',
120
				'semanticmaps-forminput-locations'
121
			]
122
		];
123
124
		$this->mwGlobals['wgResourceModules']['ext.sm.common'] = $moduleTemplate + [
125
			'localBasePath' => __DIR__ . '/src',
126
			'remoteExtPath' => 'SemanticMaps/src',
127
			'scripts' => [
128
				'ext.sm.common.js'
129
			]
130
		];
131
	}
132
133
	private function registerGoogleMaps() {
134
		$moduleTemplate = [
135
			'localBasePath' => __DIR__ . '/src/services/GoogleMaps3',
136
			'remoteExtPath' => 'SemanticMaps/src/services/GoogleMaps3',
137
			'group' => 'ext.semanticmaps',
138
		];
139
140
		$this->mwGlobals['wgResourceModules']['ext.sm.fi.googlemaps3ajax'] = $moduleTemplate + [
141
				'dependencies' => [
142
					'ext.maps.googlemaps3',
143
					'ext.sm.common'
144
				],
145
				'scripts' => [
146
					'ext.sm.googlemaps3ajax.js'
147
				]
148
			];
149
150
		$this->mwGlobals['wgResourceModules']['ext.sm.fi.googlemaps3'] = $moduleTemplate + [
151
				'dependencies' => [
152
					'ext.sm.fi.googlemaps3.single',
153
				],
154
				'scripts' => [
155
					'ext.sm.googlemapsinput.js',
156
				],
157
			];
158
159
		$this->mwGlobals['wgResourceModules']['ext.sm.fi.googlemaps3.single'] = $moduleTemplate + [
160
				'dependencies' => [
161
					'ext.maps.googlemaps3',
162
					'ext.sm.forminputs',
163
				],
164
				'scripts' => [
165
					'jquery.googlemapsinput.js',
166
				],
167
				'messages' => [
168
				]
169
			];
170
171
		$this->mwGlobals['wgHooks']['MappingServiceLoad'][] = function() {
172
			/* @var MapsMappingService $googleMaps */
173
			$googleMaps = MapsMappingServices::getServiceInstance( 'googlemaps3' );
174
			$googleMaps->addResourceModules( array( 'ext.sm.fi.googlemaps3ajax' ) );
175
176
			$googleMaps->addFeature( 'fi', SMGoogleMaps3FormInput::class );
177
178
			SMMapPrinter::registerService( $googleMaps );
179
180
			$this->mwGlobals['smwgResultFormats'][$googleMaps->getName()] = SMMapPrinter::class;
181
			$this->mwGlobals['smwgResultAliases'][$googleMaps->getName()] = $googleMaps->getAliases();
182
		};
183
	}
184
185
	private function registerLeaflet() {
186
		$this->mwGlobals['wgResourceModules']['ext.sm.fi.leafletajax'] = [
187
			'localBasePath' => __DIR__ . '/src/services/Leaflet',
188
			'remoteExtPath' => 'SemanticMaps/src/services/Leaflet',
189
			'group' => 'ext.semanticmaps',
190
			'dependencies' => [
191
				'ext.maps.leaflet',
192
				'ext.sm.common'
193
			],
194
			'scripts' => [
195
				'ext.sm.leafletajax.js'
196
			]
197
		];
198
199
		$this->mwGlobals['wgHooks']['MappingServiceLoad'][] = function() {
200
			/* @var MapsMappingService $leaflet */
201
			$leaflet = MapsMappingServices::getServiceInstance( 'leaflet' );
202
			$leaflet->addResourceModules( array( 'ext.sm.fi.leafletajax' ) );
203
204
			SMMapPrinter::registerService( $leaflet );
205
206
			$this->mwGlobals['smwgResultFormats'][$leaflet->getName()] = SMMapPrinter::class;
207
			$this->mwGlobals['smwgResultAliases'][$leaflet->getName()] = $leaflet->getAliases();
208
		};
209
	}
210
211
	private function registerOpenLayers() {
212
		$this->mwGlobals['wgResourceModules']['ext.sm.fi.openlayersajax'] = [
213
			'localBasePath' => __DIR__ . '/src/services/OpenLayers',
214
			'remoteExtPath' => 'SemanticMaps/src/services/OpenLayers',
215
			'group' => 'ext.semanticmaps',
216
			'dependencies' => [
217
				'ext.maps.openlayers',
218
				'ext.sm.common'
219
			],
220
			'scripts' => [
221
				'ext.sm.openlayersajax.js'
222
			]
223
		];
224
225
		$this->mwGlobals['wgHooks']['MappingServiceLoad'][] = function() {
226
			/* @var MapsMappingService $openLayers */
227
			$openLayers = MapsMappingServices::getServiceInstance( 'openlayers' );
228
			$openLayers->addResourceModules( array( 'ext.sm.fi.openlayersajax' ) );
229
230
			SMMapPrinter::registerService( $openLayers );
231
232
			$this->mwGlobals['smwgResultFormats'][$openLayers->getName()] = SMMapPrinter::class;
233
			$this->mwGlobals['smwgResultAliases'][$openLayers->getName()] = $openLayers->getAliases();
234
		};
235
	}
236
237
	/**
238
	 * @since 3.4
239
	 *
240
	 * @return string|null
241
	 */
242
	public static function getVersion() {
243
		return SM_VERSION;
244
	}
245
246
}
247