Issues (1401)

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.

client/includes/Hooks/MovePageNotice.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
2
3
namespace Wikibase\Client\Hooks;
4
5
use Html;
6
use MediaWiki\Hook\SpecialMovepageAfterMoveHook;
7
use MovePageForm;
8
use Title;
9
use Wikibase\Client\RepoLinker;
10
use Wikibase\Client\WikibaseClient;
11
use Wikibase\Lib\Store\SiteLinkLookup;
12
13
/**
14
 * Gets a notice about the Wikibase Item belonging to the current page
15
 * after a move (in case there's one).
16
 *
17
 * @license GPL-2.0-or-later
18
 * @author Marius Hoch < [email protected] >
19
 */
20
class MovePageNotice implements SpecialMovepageAfterMoveHook {
21
22
	/**
23
	 * @var SiteLinkLookup
24
	 */
25
	private $siteLinkLookup;
26
27
	/**
28
	 * @var string
29
	 */
30
	private $siteId;
31
32
	/**
33
	 * @var RepoLinker
34
	 */
35
	private $repoLinker;
36
37
	/**
38
	 * @param SiteLinkLookup $siteLinkLookup
39
	 * @param string $siteId Global id of the client wiki
40
	 * @param RepoLinker $repoLinker
41
	 */
42
	public function __construct( SiteLinkLookup $siteLinkLookup, $siteId, RepoLinker $repoLinker ) {
43
		$this->siteLinkLookup = $siteLinkLookup;
44
		$this->siteId = $siteId;
45
		$this->repoLinker = $repoLinker;
46
	}
47
48
	public static function factory() {
49
		$wikibaseClient = WikibaseClient::getDefaultInstance();
50
		$siteLinkLookup = $wikibaseClient->getStore()->getSiteLinkLookup();
51
		$repoLinker = $wikibaseClient->newRepoLinker();
52
53
		return new self(
54
			$siteLinkLookup,
55
			$wikibaseClient->getSettings()->getSetting( 'siteGlobalID' ),
56
			$repoLinker
57
		);
58
	}
59
60
	/**
61
	 * Hook for injecting a message on [[Special:MovePage]]
62
	 * @see https://www.mediawiki.org/wiki/Manual:Hooks/SpecialMovepageAfterMove
63
	 *
64
	 * @param MovePageForm $movePage
65
	 * @param Title $oldTitle
66
	 * @param Title $newTitle
67
	 */
68
	public function onSpecialMovepageAfterMove( $movePage, $oldTitle, $newTitle ) {
69
		$out = $movePage->getOutput();
70
		$out->addModules( 'wikibase.client.miscStyles' );
71
		$out->addHTML( $this->getPageMoveNoticeHtml( $oldTitle, $newTitle ) );
72
	}
73
74
	/**
75
	 * Create a repo link directly to the item.
76
	 * We can't use Special:ItemByTitle here as the item might have already been updated.
77
	 *
78
	 * @param Title $title
79
	 *
80
	 * @return string|null
81
	 */
82
	private function getItemUrl( Title $title ) {
83
		$entityId = $this->siteLinkLookup->getItemIdForLink(
84
			$this->siteId,
85
			$title->getPrefixedText()
86
		);
87
88
		if ( !$entityId ) {
89
			return null;
90
		}
91
92
		return $this->repoLinker->getEntityUrl( $entityId );
93
	}
94
95
	/**
96
	 * @param Title $oldTitle Title of the page before the move
97
	 * @param Title $newTitle Title of the page after the move
98
	 *
99
	 * @return string|null
100
	 */
101
	private function getPageMoveNoticeHtml( Title $oldTitle, Title $newTitle ) {
102
		$itemLink = $this->getItemUrl( $oldTitle );
103
104
		if ( !$itemLink ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $itemLink of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
105
			return null;
106
		}
107
108
		$msg = $this->getPageMoveMessage( $newTitle );
109
110
		$html = Html::rawElement(
111
			'div',
112
			[
113
				'id' => 'wbc-after-page-move',
114
				'class' => 'plainlinks'
115
			],
116
			wfMessage( $msg, $itemLink )->parse()
117
		);
118
119
		return $html;
120
	}
121
122
	private function getPageMoveMessage( Title $newTitle ) {
123
		// @phan-suppress-next-line PhanUndeclaredProperty Dynamic property
124
		if ( isset( $newTitle->wikibasePushedMoveToRepo ) ) {
125
			// We're going to update the item using the repo job queue \o/
126
			return 'wikibase-after-page-move-queued';
127
		}
128
129
		// The user has to update the item per hand for some reason
130
		return 'wikibase-after-page-move';
131
	}
132
133
}
134