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/Content/PropertyHandler.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\Repo\Content;
4
5
use Content;
6
use IContextSource;
7
use MediaWiki\Revision\SlotRenderingProvider;
8
use Page;
9
use Title;
10
use Wikibase\DataModel\Entity\EntityId;
11
use Wikibase\DataModel\Entity\EntityIdParser;
12
use Wikibase\DataModel\Entity\Property;
13
use Wikibase\DataModel\Entity\PropertyId;
14
use Wikibase\Lib\Store\EntityContentDataCodec;
15
use Wikibase\Lib\Store\EntityIdLookup;
16
use Wikibase\Lib\Store\EntityTermStoreWriter;
17
use Wikibase\Lib\Store\LanguageFallbackLabelDescriptionLookupFactory;
18
use Wikibase\Lib\Store\PropertyInfoStore;
19
use Wikibase\Repo\Actions\EditEntityAction;
20
use Wikibase\Repo\Actions\HistoryEntityAction;
21
use Wikibase\Repo\Actions\SubmitEntityAction;
22
use Wikibase\Repo\Actions\ViewEntityAction;
23
use Wikibase\Repo\PropertyInfoBuilder;
24
use Wikibase\Repo\Search\Fields\FieldDefinitions;
25
use Wikibase\Repo\Validators\EntityConstraintProvider;
26
use Wikibase\Repo\Validators\ValidatorErrorLocalizer;
27
28
/**
29
 * Content handler for Wikibase items.
30
 *
31
 * @license GPL-2.0-or-later
32
 * @author Jeroen De Dauw < [email protected] >
33
 * @author Daniel Kinzler
34
 */
35
class PropertyHandler extends EntityHandler {
36
37
	/**
38
	 * @var PropertyInfoStore
39
	 */
40
	private $infoStore;
41
42
	/**
43
	 * @var PropertyInfoBuilder
44
	 */
45
	private $propertyInfoBuilder;
46
47
	/**
48
	 * @var EntityIdLookup
49
	 */
50
	private $entityIdLookup;
51
52
	/**
53
	 * @var LanguageFallbackLabelDescriptionLookupFactory
54
	 */
55
	private $labelLookupFactory;
56
57
	/**
58
	 * @var EntityTermStoreWriter
59
	 */
60
	private $entityTermStoreWriter;
61
62
	/**
63
	 * @param EntityTermStoreWriter $entityTermStoreWriter
64
	 * @param EntityContentDataCodec $contentCodec
65
	 * @param EntityConstraintProvider $constraintProvider
66
	 * @param ValidatorErrorLocalizer $errorLocalizer
67
	 * @param EntityIdParser $entityIdParser
68
	 * @param EntityIdLookup $entityIdLookup
69
	 * @param LanguageFallbackLabelDescriptionLookupFactory $labelLookupFactory
70
	 * @param PropertyInfoStore $infoStore
71
	 * @param PropertyInfoBuilder $propertyInfoBuilder
72
	 * @param FieldDefinitions $propertyFieldDefinitions
73
	 * @param callable|null $legacyExportFormatDetector
74
	 */
75
	public function __construct(
76
		EntityTermStoreWriter $entityTermStoreWriter,
77
		EntityContentDataCodec $contentCodec,
78
		EntityConstraintProvider $constraintProvider,
79
		ValidatorErrorLocalizer $errorLocalizer,
80
		EntityIdParser $entityIdParser,
81
		EntityIdLookup $entityIdLookup,
82
		LanguageFallbackLabelDescriptionLookupFactory $labelLookupFactory,
83
		PropertyInfoStore $infoStore,
84
		PropertyInfoBuilder $propertyInfoBuilder,
85
		FieldDefinitions $propertyFieldDefinitions,
86
		$legacyExportFormatDetector = null
87
	) {
88
		parent::__construct(
89
			PropertyContent::CONTENT_MODEL_ID,
90
			null,
91
			$contentCodec,
92
			$constraintProvider,
93
			$errorLocalizer,
94
			$entityIdParser,
95
			$propertyFieldDefinitions,
96
			$legacyExportFormatDetector
97
		);
98
99
		$this->entityIdLookup = $entityIdLookup;
100
		$this->labelLookupFactory = $labelLookupFactory;
101
		$this->infoStore = $infoStore;
102
		$this->propertyInfoBuilder = $propertyInfoBuilder;
103
		$this->entityTermStoreWriter = $entityTermStoreWriter;
104
	}
105
106
	/**
107
	 * @return (\Closure|class-string)[]
0 ignored issues
show
The doc-type (\Closure|class-string)[] could not be parsed: Unknown type name "class-string" at position 10. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
108
	 */
109
	public function getActionOverrides() {
110
		return [
111
			'history' => function( Page $page, IContextSource $context ) {
112
				return new HistoryEntityAction(
113
					$page,
114
					$context,
115
					$this->entityIdLookup,
116
					$this->labelLookupFactory->newLabelDescriptionLookup( $context->getLanguage() )
117
				);
118
			},
119
			'view' => ViewEntityAction::class,
120
			'edit' => EditEntityAction::class,
121
			'submit' => SubmitEntityAction::class,
122
		];
123
	}
124
125
	/**
126
	 * @see EntityHandler::getSpecialPageForCreation
127
	 *
128
	 * @return string
129
	 */
130
	public function getSpecialPageForCreation() {
131
		return 'NewProperty';
132
	}
133
134
	/**
135
	 * Returns Property::ENTITY_TYPE
136
	 *
137
	 * @return string
138
	 */
139
	public function getEntityType() {
140
		return Property::ENTITY_TYPE;
141
	}
142
143
	public function getSecondaryDataUpdates(
144
		Title $title,
145
		Content $content,
146
		$role,
147
		SlotRenderingProvider $slotOutput
148
	) {
149
		$updates = parent::getSecondaryDataUpdates( $title, $content, $role, $slotOutput );
150
151
		/** @var PropertyContent $content */
152
		'@phan-var PropertyContent $content';
153
		$id = $content->getEntityId();
154
		$property = $content->getProperty();
155
156
		$updates[] = new DataUpdateAdapter(
157
			[ $this->infoStore, 'setPropertyInfo' ],
158
			$id,
159
			$this->propertyInfoBuilder->buildPropertyInfo( $property )
160
		);
161
162
		if ( $content->isRedirect() ) {
163
			$updates[] = new DataUpdateAdapter(
164
				[ $this->entityTermStoreWriter, 'deleteTermsOfEntity' ],
165
				$id
166
			);
167
		} else {
168
			$updates[] = new DataUpdateAdapter(
169
				[ $this->entityTermStoreWriter, 'saveTermsOfEntity' ],
170
				$property
171
			);
172
		}
173
174
		return $updates;
175
	}
176
177
	public function getDeletionUpdates( Title $title, $role ) {
178
		$updates = parent::getDeletionUpdates( $title, $role );
179
180
		$id = $this->getIdForTitle( $title );
181
182
		$updates[] = new DataUpdateAdapter(
183
			[ $this->infoStore, 'removePropertyInfo' ],
184
			$id
185
		);
186
187
		// Unregister the entity from the term store.
188
		$updates[] = new DataUpdateAdapter(
189
			[ $this->entityTermStoreWriter, 'deleteTermsOfEntity' ],
190
			$id
191
		);
192
193
		return $updates;
194
	}
195
196
	/**
197
	 * @see EntityHandler::makeEmptyEntity()
198
	 *
199
	 * @return Property
200
	 */
201
	public function makeEmptyEntity() {
202
		return Property::newFromType( '' );
203
	}
204
205
	/**
206
	 * @see EntityHandler::newEntityContent
207
	 *
208
	 * @param EntityHolder|null $entityHolder
209
	 *
210
	 * @return PropertyContent
211
	 */
212
	protected function newEntityContent( EntityHolder $entityHolder = null ) {
213
		return new PropertyContent( $entityHolder );
214
	}
215
216
	/**
217
	 * @see EntityContent::makeEntityId
218
	 *
219
	 * @param string $id
220
	 *
221
	 * @return EntityId
222
	 */
223
	public function makeEntityId( $id ) {
224
		return new PropertyId( $id );
225
	}
226
227
}
228