Issues (67)

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/Deserializers/ItemDeserializer.php (4 issues)

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\DataModel\Deserializers;
4
5
use Deserializers\Deserializer;
6
use Deserializers\Exceptions\DeserializationException;
7
use Deserializers\TypedObjectDeserializer;
8
use Wikibase\DataModel\Entity\Item;
9
use Wikibase\DataModel\Entity\ItemId;
10
use Wikibase\DataModel\SiteLink;
11
use Wikibase\DataModel\SiteLinkList;
12
use Wikibase\DataModel\Statement\StatementList;
13
use Wikibase\DataModel\Term\AliasGroupList;
14
use Wikibase\DataModel\Term\TermList;
15
16
/**
17
 * Package private
18
 *
19
 * @license GPL-2.0-or-later
20
 * @author Thomas Pellissier Tanon
21
 * @author Bene* < [email protected] >
22
 */
23
class ItemDeserializer extends TypedObjectDeserializer {
24
25
	/**
26
	 * @var Deserializer
27
	 */
28
	private $entityIdDeserializer;
29
30
	/**
31
	 * @var Deserializer
32
	 */
33
	private $termListDeserializer;
34
35
	/**
36
	 * @var Deserializer
37
	 */
38
	private $aliasGroupListDeserializer;
39
40
	/**
41
	 * @var Deserializer
42
	 */
43
	private $statementListDeserializer;
44
45
	/**
46
	 * @var Deserializer
47
	 */
48
	private $siteLinkDeserializer;
49
50 30
	public function __construct(
51
		Deserializer $entityIdDeserializer,
52
		Deserializer $termListDeserializer,
53
		Deserializer $aliasGroupListDeserializer,
54
		Deserializer $statementListDeserializer,
55
		Deserializer $siteLinkDeserializer
56
	) {
57 30
		parent::__construct( 'item', 'type' );
58
59 30
		$this->entityIdDeserializer = $entityIdDeserializer;
60 30
		$this->termListDeserializer = $termListDeserializer;
61 30
		$this->aliasGroupListDeserializer = $aliasGroupListDeserializer;
62 30
		$this->statementListDeserializer = $statementListDeserializer;
63 30
		$this->siteLinkDeserializer = $siteLinkDeserializer;
64 30
	}
65
66
	/**
67
	 * @see Deserializer::deserialize
68
	 *
69
	 * @param array $serialization
70
	 *
71
	 * @throws DeserializationException
72
	 * @return Item
73
	 */
74 21
	public function deserialize( $serialization ) {
75 21
		$this->assertCanDeserialize( $serialization );
76
77 18
		return $this->getDeserialized( $serialization );
78
	}
79
80 18
	private function getDeserialized( array $serialization ) {
81 18
		$item = new Item();
82
83 18
		$this->setIdFromSerialization( $serialization, $item );
84 18
		$this->setTermsFromSerialization( $serialization, $item );
85 18
		$this->setStatementListFromSerialization( $serialization, $item );
86 18
		$this->setSiteLinksFromSerialization( $item->getSiteLinkList(), $serialization );
87
88 18
		return $item;
89
	}
90
91 18
	private function setIdFromSerialization( array $serialization, Item $item ) {
92 18
		if ( !array_key_exists( 'id', $serialization ) ) {
93 12
			return;
94
		}
95
96
		/** @var ItemId $id */
97 6
		$id = $this->entityIdDeserializer->deserialize( $serialization['id'] );
98 6
		$item->setId( $id );
99 6
	}
100
101 18
	private function setTermsFromSerialization( array $serialization, Item $item ) {
102 18
		if ( array_key_exists( 'labels', $serialization ) ) {
103 10
			$this->assertAttributeIsArray( $serialization, 'labels' );
0 ignored issues
show
Deprecated Code introduced by
The method Deserializers\TypedObjec...ssertAttributeIsArray() has been deprecated with message: since 4.0, just do your own "if ( is_array( … ) )" instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
104
			/** @var TermList $labels */
105 10
			$labels = $this->termListDeserializer->deserialize( $serialization['labels'] );
106 10
			$item->getFingerprint()->setLabels( $labels );
107
		}
108
109 18
		if ( array_key_exists( 'descriptions', $serialization ) ) {
110 10
			$this->assertAttributeIsArray( $serialization, 'descriptions' );
0 ignored issues
show
Deprecated Code introduced by
The method Deserializers\TypedObjec...ssertAttributeIsArray() has been deprecated with message: since 4.0, just do your own "if ( is_array( … ) )" instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
111
			/** @var TermList $descriptions */
112 10
			$descriptions = $this->termListDeserializer->deserialize( $serialization['descriptions'] );
113 10
			$item->getFingerprint()->setDescriptions( $descriptions );
114
		}
115
116 18
		if ( array_key_exists( 'aliases', $serialization ) ) {
117 10
			$this->assertAttributeIsArray( $serialization, 'aliases' );
0 ignored issues
show
Deprecated Code introduced by
The method Deserializers\TypedObjec...ssertAttributeIsArray() has been deprecated with message: since 4.0, just do your own "if ( is_array( … ) )" instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
118
			/** @var AliasGroupList $aliases */
119 10
			$aliases = $this->aliasGroupListDeserializer->deserialize( $serialization['aliases'] );
120 10
			$item->getFingerprint()->setAliasGroups( $aliases );
121
		}
122 18
	}
123
124 18
	private function setStatementListFromSerialization( array $serialization, Item $item ) {
125 18
		if ( !array_key_exists( 'claims', $serialization ) ) {
126 8
			return;
127
		}
128
129
		/** @var StatementList $statements */
130 10
		$statements = $this->statementListDeserializer->deserialize( $serialization['claims'] );
131 10
		$item->setStatements( $statements );
132 10
	}
133
134 18
	private function setSiteLinksFromSerialization(
135
		SiteLinkList $siteLinkList,
136
		array $serialization
137
	) {
138 18
		if ( !array_key_exists( 'sitelinks', $serialization ) ) {
139 8
			return;
140
		}
141
142 10
		$this->assertAttributeIsArray( $serialization, 'sitelinks' );
0 ignored issues
show
Deprecated Code introduced by
The method Deserializers\TypedObjec...ssertAttributeIsArray() has been deprecated with message: since 4.0, just do your own "if ( is_array( … ) )" instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
143
144 10
		foreach ( $serialization['sitelinks'] as $siteLinksSerialization ) {
145
			/** @var SiteLink $siteLink */
146 5
			$siteLink = $this->siteLinkDeserializer->deserialize( $siteLinksSerialization );
147 5
			$siteLinkList->addSiteLink( $siteLink );
148
		}
149 10
	}
150
151
}
152