Issues (10)

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/Schema.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
namespace gossi\swagger;
3
4
use gossi\swagger\collections\Definitions;
5
use gossi\swagger\parts\DescriptionPart;
6
use gossi\swagger\parts\ExtensionPart;
7
use gossi\swagger\parts\ExternalDocsPart;
8
use gossi\swagger\parts\ItemsPart;
9
use gossi\swagger\parts\RefPart;
10
use gossi\swagger\parts\TypePart;
11
use phootwork\collection\ArrayList;
12
use phootwork\collection\CollectionUtils;
13
use phootwork\collection\Map;
14
use phootwork\lang\Arrayable;
15
16
class Schema extends AbstractModel implements Arrayable {
17
18
	use RefPart;
19
	use TypePart;
20
	use DescriptionPart;
21
	use ItemsPart;
22
	use ExternalDocsPart;
23
	use ExtensionPart;
24
25
	/** @var string */
26
	private $discriminator;
27
28
	/** @var bool */
29
	private $readOnly = false;
30
31
	/** @var string */
32
	private $title;
33
34
	private $xml;
35
36
	/** @var string */
37
	private $example;
38
39
	/** @var ArrayList|bool */
40
	private $required;
41
42
	/** @var Definitions */
43
	private $properties;
44
45
	/** @var ArrayList */
46
	private $allOf;
47
48
	/** @var Schema */
49
	private $additionalProperties;
50
51 10
	public function __construct($contents = null) {
52 10
		$this->parse($contents === null ? new Map() : $contents);
53 10
	}
54
55 10
	private function parse($contents = []) {
56 10
		$data = CollectionUtils::toMap($contents);
57
58 10
		$this->title = $data->get('title');
59 10
		$this->discriminator = $data->get('discriminator');
60 10
		$this->readOnly = $data->has('readOnly') && $data->get('readOnly');
61 10
		$this->example = $data->get('example');
62 10
		$this->required = $data->get('required');
63 10
		$this->properties = new Definitions($data->get('properties'));
64 10
		if ($data->has('additionalProperties')) {
65
			$this->additionalProperties = new self($data->get('additionalProperties'));
66
		}
67
68 10
		$this->allOf = new ArrayList();
69 10
		if ($data->has('allOf')) {
70 3
			foreach ($data->get('allOf') as $schema) {
71 3
				$this->allOf->add(new self($schema));
72 3
			}
73 3
		}
74
75
		// parts
76 10
		$this->parseRef($data);
77 10
		$this->parseType($data);
78 10
		$this->parseDescription($data);
79 10
		$this->parseItems($data);
80 10
		$this->parseExternalDocs($data);
81 10
		$this->parseExtensions($data);
82 10
	}
83
84 10
	public function toArray() {
85 10
		return $this->export('title', 'discriminator', 'description', 'readOnly', 'example',
86 10
				'externalDocs', $this->getTypeExportFields(), 'items', 'required',
87 10
				'properties', 'additionalProperties', 'allOf');
88
	}
89
90
	/**
91
	 *
92
	 * @return bool|array
93
	 */
94
	public function getRequired() {
95
		return $this->required;
96
	}
97
98
	/**
99
	 *
100
	 * @param bool|array $required
101
	 * @return $this
102
	 */
103
	public function setRequired($required) {
104
		$this->required = $required;
0 ignored issues
show
Documentation Bug introduced by
It seems like $required can also be of type array. However, the property $required is declared as type object<phootwork\collection\ArrayList>|boolean. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
105
		return $this;
106
	}
107
108
	/**
109
	 *
110
	 * @return string
111
	 */
112
	public function getDiscriminator() {
113
		return $this->discriminator;
114
	}
115
116
	/**
117
	 *
118
	 * @param string $discriminator
119
	 */
120
	public function setDiscriminator($discriminator) {
121
		$this->discriminator = $discriminator;
122
		return $this;
123
	}
124
125
	/**
126
	 *
127
	 * @return bool
128
	 */
129
	public function isReadOnly() {
130
		return $this->readOnly;
131
	}
132
133
	/**
134
	 *
135
	 * @param bool $readOnly
136
	 */
137
	public function setReadOnly($readOnly) {
138
		$this->readOnly = $readOnly;
139
		return $this;
140
	}
141
142
	/**
143
	 *
144
	 * @return string
145
	 */
146
	public function getExample() {
147
		return $this->example;
148
	}
149
150
	/**
151
	 *
152
	 * @param string $example
153
	 */
154
	public function setExample($example) {
155
		$this->example = $example;
156
		return $this;
157
	}
158
159
	/**
160
	 *
161
	 * @return string
162
	 */
163
	public function getTitle() {
164
		return $this->title;
165
	}
166
167
	/**
168
	 *
169
	 * @param string $title
170
	 * @return $this
171
	 */
172
	public function setTitle($title) {
173
		$this->title = $title;
174
		return $this;
175
	}
176
177
	/**
178
	 *
179
	 * @return Definitions
180
	 */
181
	public function getProperties() {
182
		return $this->properties;
183
	}
184
185
	/**
186
	 *
187
	 * @return ArrayList
188
	 */
189
	public function getAllOf() {
190
		return $this->allOf;
191
	}
192
193
	/**
194
	 *
195
	 * @return Schema
196
	 */
197
	public function getAdditionalProperties() {
198
		if ($this->additionalProperties === null) {
199
			$this->additionalProperties = new self();
200
		}
201
		return $this->additionalProperties;
202
	}
203
204
}
205