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/collections/Parameters.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
namespace gossi\swagger\collections;
3
4
use gossi\swagger\Parameter;
5
use gossi\swagger\parts\RefPart;
6
use phootwork\collection\ArrayList;
7
use phootwork\collection\CollectionUtils;
8
use phootwork\lang\Arrayable;
9
use gossi\swagger\AbstractModel;
10
11
class Parameters extends AbstractModel implements Arrayable, \Iterator {
12
13
	use RefPart;
14
15
	/** @var ArrayList */
16
	private $parameters;
17
18 13
	public function __construct($contents = []) {
19 13
		$this->parse($contents === null ? [] : $contents);
20 13
	}
21
22 13
	private function parse($contents) {
23 13
		$data = CollectionUtils::toMap($contents);
24
25 13
		$this->parameters = new ArrayList();
26 13
		$this->parseRef($data);
27
28 13
		if (!$this->hasRef()) {
29 13
			foreach ($data as $param) {
30 4
				$this->parameters->add(new Parameter($param));
31 13
			}
32 13
		}
33 13
	}
34
35 9
	public function toArray() {
36 9
		if ($this->hasRef()) {
37 1
			return ['$ref' => $this->getRef()];
38
		}
39
40 9
		return CollectionUtils::toArrayRecursive($this->parameters);
41
	}
42
43 1
	public function size() {
44 1
		return $this->parameters->size();
45
	}
46
47
	/**
48
	 * Searches whether a parameter with the given name exists
49
	 *
50
	 * @param string $name
51
	 * @return bool
52
	 */
53 1
	public function searchByName($name) {
54
		return $this->parameters->search($name, function (Parameter $param, $name) {
55 1
			return $param->getName() == $name;
56 1
		});
57
	}
58
59
	/**
60
	 * Returns parameter with the given name if it exists
61
	 *
62
	 * @param string $name
63
	 * @return Parameter|void
64
	 */
65 1
	public function findByName($name) {
66 1
		foreach ($this->parameters as $param) {
67 1
			if ($param->getName() == $name) {
68 1
				return $param;
69
			}
70 1
		}
71 1
	}
72
73
	/**
74
	 * Searches for the parameter with the given name. Creates a parameter with the given name
75
	 * if none exists
76
	 *
77
	 * @param string $name
78
	 * @return Parameter
79
	 */
80
	public function getByName($name) {
81
		$param = $this->findByName($name);
82
		if (empty($param)) {
83
			$param = new Parameter();
84
			$param->setName($name);
85
			$this->parameters->add($param);
86
		}
87
88
		return $param;
89
	}
90
91
	/**
92
	 * Searches whether a parameter with the given unique combination exists
93
	 *
94
	 * @param string $name
95
	 * @param string $id
0 ignored issues
show
There is no parameter named $id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
96
	 * @return bool
97
	 */
98
	public function search($name, $in) {
99 1
		return $this->parameters->search(function (Parameter $param) use ($name, $in) {
100 1
			return $param->getIn() == $in && $param->getName() == $name;
101 1
		});
102
	}
103
104 1
	public function find($name, $in) {
105 1
		foreach ($this->parameters as $param) {
106 1
			if ($param->getIn() == $in && $param->getName() == $name) {
107 1
				return $param;
108
			}
109 1
		}
110 1
	}
111
112 1
	public function get($name, $in) {
113 1
		$param = $this->find($name, $in);
114 1
		if (empty($param)) {
115 1
			$param = new Parameter();
116 1
			$param->setName($name);
117 1
			$param->setIn($in);
118 1
			$this->parameters->add($param);
119 1
		}
120
121 1
		return $param;
122
	}
123
124
	/**
125
	 * Adds a parameter
126
	 *
127
	 * @param Parameter $param
128
	 */
129 1
	public function add(Parameter $param) {
130 1
		$this->parameters->add($param);
131 1
	}
132
133
	/**
134
	 * Removes a parameter
135
	 *
136
	 * @param Parameter $param
137
	 */
138 1
	public function remove(Parameter $param) {
139 1
		$this->parameters->remove($param);
140 1
	}
141
142
	/**
143
	 * Returns whether a given parameter exists
144
	 *
145
	 * @param Parameter $param
146
	 * @return bool
147
	 */
148 1
	public function contains(Parameter $param) {
149 1
		return $this->parameters->contains($param);
150
	}
151
152
	public function current() {
153
		return $this->parameters->current();
154
	}
155
156
	public function key() {
157
		return $this->parameters->key();
158
	}
159
160
	public function next() {
161
		return $this->parameters->next();
162
	}
163
164
	public function rewind() {
165
		return $this->parameters->rewind();
166
	}
167
168
	public function valid() {
169
		return $this->parameters->valid();
170
	}
171
}
172