Issues (61)

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/MapsHooks.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
declare( strict_types = 1 );
4
5
namespace Maps;
6
7
use AlItem;
8
use ALTree;
9
use Maps\GeoJsonPages\GeoJsonNewPageUi;
10
use Maps\Presentation\OutputFacade;
11
use MediaWiki\MediaWikiServices;
12
use SkinTemplate;
13
use SMWPrintRequest;
14
15
/**
16
 * Static class for hooks handled by the Maps extension.
17
 *
18
 * @since 0.7
19
 *
20
 * @licence GNU GPL v2+
21
 * @author Jeroen De Dauw < [email protected] >
22
 */
23
final class MapsHooks {
24
25
	/**
26
	 * Adds a link to Admin Links page.
27
	 *
28
	 * @since 0.7
29
	 *
30
	 * @param ALTree $admin_links_tree
31
	 *
32
	 * @return boolean
33
	 */
34
	public static function addToAdminLinks( ALTree &$admin_links_tree ) {
35
		$displaying_data_section = $admin_links_tree->getSection(
36
			wfMessage( 'smw_adminlinks_displayingdata' )->text()
37
		);
38
39
		// Escape if SMW hasn't added links.
40
		if ( is_null( $displaying_data_section ) ) {
41
			return true;
42
		}
43
44
		$smw_docu_row = $displaying_data_section->getRow( 'smw' );
45
46
		$maps_docu_label = wfMessage( 'adminlinks_documentation', 'Maps' )->text();
47
		$smw_docu_row->addItem(
48
			AlItem::newFromExternalLink( 'https://www.semantic-mediawiki.org/wiki/Extension:Maps', $maps_docu_label )
49
		);
50
51
		return true;
52
	}
53
54
	/**
55
	 * Adds global JavaScript variables.
56
	 *
57
	 * @since 1.0
58
	 * @see http://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript
59
	 *
60
	 * @param array &$vars Variables to be added into the output
61
	 *
62
	 * @return boolean true in all cases
63
	 */
64
	public static function onMakeGlobalVariablesScript( array &$vars ) {
65
		$vars['egMapsScriptPath'] = $GLOBALS['wgScriptPath'] . '/extensions/Maps/'; // TODO: wgExtensionDirectory?
66
		$vars['egMapsDebugJS'] = $GLOBALS['egMapsDebugJS'];
67
		$vars['egMapsAvailableServices'] = $GLOBALS['egMapsAvailableServices'];
68
		$vars['egMapsLeafletLayersApiKeys'] = $GLOBALS['egMapsLeafletLayersApiKeys'];
69
70
		$vars += $GLOBALS['egMapsGlobalJSVars'];
71
72
		return true;
73
	}
74
75
	public static function onSkinTemplateNavigation( SkinTemplate $skinTemplate, array &$links ) {
76
		if ( $skinTemplate->getTitle() === null ) {
77
			return true;
78
		}
79
80
		if ( $skinTemplate->getTitle()->getNamespace() === NS_GEO_JSON ) {
81
			if ( array_key_exists( 'edit', $links['views'] ) ) {
82
				$links['views']['edit']['text'] = wfMessage(
83
					$skinTemplate->getTitle()->exists() ? 'maps-geo-json-edit-source': 'maps-geo-json-create-source'
84
				);
85
			}
86
		}
87
88
		return true;
89
	}
90
91
	public static function onBeforeDisplayNoArticleText( \Article $article ) {
92
		return !self::shouldShowGeoJsonCreatePageUi( $article );
93
	}
94
95
	public static function onShowMissingArticle( \Article $article ) {
96
		if ( self::shouldShowGeoJsonCreatePageUi( $article ) ) {
97
			$ui = new GeoJsonNewPageUi( OutputFacade::newFromOutputPage( $article->getContext()->getOutput() ) );
98
			$ui->addToOutput();
99
		}
100
101
		return true;
102
	}
103
104
	private static function shouldShowGeoJsonCreatePageUi( \Article $article ): bool {
105
		return $article->getTitle()->getNamespace() === NS_GEO_JSON
106
			&& MediaWikiServices::getInstance()->getPermissionManager()->userHasRight( $article->getContext()->getUser(), 'createpage' );
107
	}
108
109
	public static function onRegisterTags( array &$tags ) {
110
		$tags[] = 'maps-visual-edit';
111
		return true;
112
	}
113
114
	public static function onChangeTagsAllowedAdd( array &$allowedTags, array $tags, \User $user = null ) {
0 ignored issues
show
The parameter $tags 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...
115
		$allowedTags[] = 'maps-visual-edit';
116
	}
117
118
	public static function onResourceLoaderTestModules( array &$modules, $resourceLoader ) {
0 ignored issues
show
The parameter $resourceLoader 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...
119
		$modules['qunit']['ext.maps.test'] = [
120
			'scripts' => [
121
				'tests/js/leaflet/GeoJsonTest.js',
122
			],
123
			'dependencies' => [
124
				'ext.maps.leaflet.geojson',
125
			],
126
			'localBasePath' => __DIR__ . '/..',
127
			'remoteExtPath' => 'Maps'
128
		];
129
	}
130
131
	/**
132
	 * Set the default format to 'map' when the requested properties are
133
	 * of type geographic coordinates.
134
	 *
135
	 * TODO: have a setting to turn this off and have it off by default for #show
136
	 *
137
	 * @since 1.0
138
	 *
139
	 * @param $format Mixed: The format (string), or false when not set yet
140
	 * @param SMWPrintRequest[] $printRequests The print requests made
141
	 *
142
	 * @return boolean
143
	 */
144
	public static function addGeoCoordsDefaultFormat( &$format, array $printRequests ) {
145
		// Only set the format when not set yet. This allows other extensions to override the Maps behavior.
146
		if ( $format === false ) {
147
			// Only apply when there is more then one print request.
148
			// This way requests comming from #show are ignored.
149
			if ( count( $printRequests ) > 1 ) {
150
				$allValid = true;
151
				$hasCoords = false;
152
153
				// Loop through the print requests to determine their types.
154
				foreach ( $printRequests as $printRequest ) {
155
					// Skip the first request, as it's the object.
156
					if ( $printRequest->getMode() == SMWPrintRequest::PRINT_THIS ) {
157
						continue;
158
					}
159
160
					$typeId = $printRequest->getTypeID();
161
162
					if ( $typeId == '_geo' ) {
163
						$hasCoords = true;
164
					} else {
165
						$allValid = false;
166
						break;
167
					}
168
				}
169
170
				// If they are all coordinates, set the result format to 'map'.
171
				if ( $allValid && $hasCoords ) {
172
					$format = 'map';
173
				}
174
			}
175
176
		}
177
178
		return true;
179
	}
180
181
	public static function addSmwSettings( array &$settings ) {
0 ignored issues
show
The parameter $settings 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...
182
		// TODO: uncomment when it is safe for the semantic integration to be enabled by default
183
		// $settings['smwgNamespacesWithSemanticLinks'][NS_GEO_JSON] = true;
184
		return true;
185
	}
186
187
}
188