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.

repo/includes/Specials/SpecialWikibaseRepoPage.php (1 issue)

Labels
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 Wikibase\Repo\Specials;
4
5
use MWException;
6
use RuntimeException;
7
use Status;
8
use Title;
9
use Wikibase\DataModel\Entity\EntityDocument;
10
use Wikibase\DataModel\Entity\EntityId;
11
use Wikibase\DataModel\Entity\ItemId;
12
use Wikibase\Lib\FormatableSummary;
13
use Wikibase\Lib\Store\EntityTitleLookup;
14
use Wikibase\Lib\UserInputException;
15
use Wikibase\Repo\EditEntity\EditEntity;
16
use Wikibase\Repo\EditEntity\MediawikiEditEntityFactory;
17
use Wikibase\Repo\SummaryFormatter;
18
use Wikibase\Repo\WikibaseRepo;
19
20
/**
21
 * Abstract base class for special pages of the WikibaseRepo extension.
22
 *
23
 * @license GPL-2.0-or-later
24
 * @author Bene* < [email protected] >
25
 */
26
abstract class SpecialWikibaseRepoPage extends SpecialWikibasePage {
27
28
	/**
29
	 * @var SpecialPageCopyrightView
30
	 */
31
	private $copyrightView;
32
33
	/**
34
	 * @var SummaryFormatter
35
	 */
36
	protected $summaryFormatter;
37
38
	/**
39
	 * @var EntityTitleLookup
40
	 */
41
	private $entityTitleLookup;
42
43
	/**
44
	 * @var MediawikiEditEntityFactory
45
	 */
46
	private $editEntityFactory;
47
48
	/**
49
	 * @var EditEntity
50
	 */
51
	private $editEntity = null;
52
53
	/**
54
	 * @param string $title The title of the special page
55
	 * @param string $restriction The required user right
56
	 * @param SpecialPageCopyrightView $copyrightView
57
	 * @param SummaryFormatter $summaryFormatter
58
	 * @param EntityTitleLookup $entityTitleLookup
59
	 * @param MediawikiEditEntityFactory $editEntityFactory
60
	 */
61
	public function __construct(
62
		$title,
63
		$restriction,
64
		SpecialPageCopyrightView $copyrightView,
65
		SummaryFormatter $summaryFormatter,
66
		EntityTitleLookup $entityTitleLookup,
67
		MediawikiEditEntityFactory $editEntityFactory
68
	) {
69
		parent::__construct( $title, $restriction );
70
		$this->copyrightView = $copyrightView;
71
		$this->summaryFormatter = $summaryFormatter;
72
		$this->entityTitleLookup = $entityTitleLookup;
73
		$this->editEntityFactory = $editEntityFactory;
74
	}
75
76
	/**
77
	 * @param EntityId|null $id
78
	 * @param int $baseRev
79
	 * @return EditEntity
80
	 */
81
	protected function prepareEditEntity( EntityId $id = null, $baseRev = 0 ) {
82
		$this->editEntity = $this->editEntityFactory->newEditEntity(
83
			$this->getUser(),
84
			$id,
85
			$baseRev,
86
			$this->getRequest()->wasPosted()
87
		);
88
89
		return $this->editEntity;
90
	}
91
92
	/**
93
	 * Returns the EditEntity interactor.
94
	 *
95
	 * @note Call only after calling prepareEditEntity() first.
96
	 *
97
	 * @return EditEntity
98
	 */
99
	protected function getEditEntity() {
100
		if ( !$this->editEntity ) {
101
			throw new RuntimeException( 'Call prepareEditEntity() before calling getEditEntity()' );
102
		}
103
104
		return $this->editEntity;
105
	}
106
107
	/**
108
	 * Parses an entity id.
109
	 *
110
	 * @param string $rawId
111
	 *
112
	 * @return EntityId
113
	 * @throws UserInputException
114
	 */
115
	protected function parseEntityId( $rawId ) {
116
		$idParser = WikibaseRepo::getDefaultInstance()->getEntityIdParser();
117
118
		try {
119
			$id = $idParser->parse( $rawId );
120
		} catch ( RuntimeException $ex ) {
121
			throw new UserInputException(
122
				'wikibase-wikibaserepopage-invalid-id',
123
				[ $rawId ],
124
				"Entity ID \"$rawId\" is not valid"
125
			);
126
		}
127
128
		return $id;
129
	}
130
131
	/**
132
	 * Parses an item id.
133
	 *
134
	 * @param string $rawId
135
	 *
136
	 * @return ItemId
137
	 * @throws UserInputException
138
	 */
139
	protected function parseItemId( $rawId ) {
140
		$id = $this->parseEntityId( $rawId );
141
142
		if ( !( $id instanceof ItemId ) ) {
143
			throw new UserInputException(
144
				'wikibase-wikibaserepopage-not-itemid',
145
				[ $rawId ],
146
				"Entity ID \"$rawId\" does not refer to an Item"
147
			);
148
		}
149
150
		return $id;
151
	}
152
153
	/**
154
	 * @param EntityId $id
155
	 *
156
	 * @throws MWException
157
	 * @return null|Title
158
	 */
159
	protected function getEntityTitle( EntityId $id ) {
160
		return $this->entityTitleLookup->getTitleForId( $id );
161
	}
162
163
	/**
164
	 * Saves the entity using the given summary.
165
	 *
166
	 * @note Call prepareEditEntity() first.
167
	 *
168
	 * @param EntityDocument $entity
169
	 * @param FormatableSummary $summary
170
	 * @param string $token
171
	 * @param int $flags The edit flags (see WikiPage::doEditContent)
172
	 *
173
	 * @return Status
174
	 */
175
	protected function saveEntity(
176
		EntityDocument $entity,
177
		FormatableSummary $summary,
178
		$token,
179
		$flags = EDIT_UPDATE
180
	) {
181
		$status = $this->getEditEntity()->attemptSave(
182
			$entity,
183
			$this->summaryFormatter->formatSummary( $summary ),
184
			$flags,
185
			$token
186
		);
187
188
		return $status;
189
	}
190
191
	/**
192
	 * @param string|null $saveMessageKey Defaults to "wikibase-<special page name>-submit".
193
	 *
194
	 * @return string HTML
195
	 */
196
	protected function getCopyrightHTML( $saveMessageKey = null ) {
197
		if ( $saveMessageKey === null ) {
198
			$saveMessageKey = 'wikibase-' . strtolower( $this->getName() ) . '-submit';
0 ignored issues
show
Consider using $this->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
199
		}
200
201
		return $this->copyrightView->getHtml( $this->getLanguage(), $saveMessageKey );
202
	}
203
204
}
205