Issues (2873)

Security Analysis    not enabled

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.

classes/PodsArray.php (5 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
/**
4
 * @package Pods
5
 */
6
class PodsArray implements ArrayAccess {
7
8
	/**
9
	 * @var array|mixed
10
	 */
11
	private $__container = array();
12
13
	/**
14
	 * Alternative to get_object_vars to access an object as an array with simple functionality and accepts arrays to
15
	 * add additional functionality. Additional functionality includes validation and setting default data.
16
	 *
17
	 * @param mixed $container Object (or existing Array).
18
	 *
19
	 * @return \PodsArray
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
20
	 *
21
	 * @license http://www.gnu.org/licenses/gpl-2.0.html
22
	 * @since   2.0
23
	 */
24
	public function __construct( $container ) {
25
26
		if ( is_array( $container ) || is_object( $container ) ) {
27
			$this->__container = &$container;
28
		}
29
	}
30
31
	/**
32
	 * Set value from array usage $object['offset'] = 'value';
33
	 *
34
	 * @param mixed $offset Used to set index of Array or Variable name on Object.
35
	 * @param mixed $value  Value to be set.
36
	 *
37
	 * @return mixed
38
	 * @since 2.0
39
	 */
40
	public function offsetSet( $offset, $value ) {
0 ignored issues
show
The function name offsetSet is in camel caps, but expected offset_set instead as per the coding standard.
Loading history...
41
42
		if ( is_array( $this->__container ) ) {
43
			$this->__container[ $offset ] = $value;
44
		} else {
45
			$this->__container->{$offset} = $value;
46
		}
47
48
		return $value;
49
	}
50
51
	/**
52
	 * Get value from array usage $object['offset'];
53
	 *
54
	 * @param mixed $offset Used to get value of Array or Variable on Object.
55
	 *
56
	 * @return mixed|null
57
	 * @since 2.0
58
	 */
59
	public function offsetGet( $offset ) {
0 ignored issues
show
The function name offsetGet is in camel caps, but expected offset_get instead as per the coding standard.
Loading history...
60
61
		if ( is_array( $this->__container ) ) {
62
			if ( isset( $this->__container[ $offset ] ) ) {
63
				return $this->__container[ $offset ];
64
			}
65
		} elseif ( isset( $this->__container->$offset ) ) {
66
			return $this->__container->$offset;
67
		}
68
69
		return null;
70
	}
71
72
	/**
73
	 * Get value from array usage $object['offset'];
74
	 *
75
	 * @param mixed $offset Used to get value of Array or Variable on Object.
76
	 *
77
	 * @return bool
78
	 * @since 2.0
79
	 */
80
	public function offsetExists( $offset ) {
0 ignored issues
show
The function name offsetExists is in camel caps, but expected offset_exists instead as per the coding standard.
Loading history...
81
82
		if ( is_array( $this->__container ) ) {
83
			return isset( $this->__container[ $offset ] );
84
		}
85
86
		return isset( $this->__container->$offset );
87
	}
88
89
	/**
90
	 * Get value from array usage $object['offset'];
91
	 *
92
	 * @param mixed $offset Used to unset index of Array or Variable on Object.
93
	 *
94
	 * @since 2.0
95
	 */
96
	public function offsetUnset( $offset ) {
0 ignored issues
show
The function name offsetUnset is in camel caps, but expected offset_unset instead as per the coding standard.
Loading history...
97
98
		if ( is_array( $this->__container ) ) {
99
			unset( $this->__container[ $offset ] );
100
		} else {
101
			unset( $this->__container->$offset );
102
		}
103
	}
104
105
	/**
106
	 * Validate value on a specific type and set default (if empty)
107
	 *
108
	 * @param mixed       $offset  Used to get value of Array or Variable on Object.
109
	 * @param mixed|null  $default Used to set default value if it doesn't exist.
110
	 * @param string|null $type    Used to force a specific type of variable (allowed: array, object, integer, absint,
111
	 *                             boolean).
112
	 * @param mixed|null  $extra   Used in advanced types of variables.
113
	 *
114
	 * @return array|bool|int|mixed|null|number|object
115
	 * @since 2.0
116
	 */
117
	public function validate( $offset, $default = null, $type = null, $extra = null ) {
118
119
		if ( ! $this->offsetExists( $offset ) ) {
120
			$this->offsetSet( $offset, $default );
121
		}
122
123
		$value = $this->offsetGet( $offset );
124
125
		if ( empty( $value ) && null !== $default && false !== $value ) {
126
			$value = $default;
127
		}
128
129
		if ( 'array' === $type || 'array_merge' === $type ) {
130
			if ( ! is_array( $value ) ) {
131
				$value = explode( ',', $value );
132
			}
133
134
			if ( 'array_merge' === $type && $value !== $default ) {
135
				$value = array_merge( $default, $value );
136
			}
137
		} elseif ( 'object' === $type || 'object_merge' === $type ) {
138
			if ( ! is_object( $value ) ) {
139
				if ( ! is_array( $value ) ) {
140
					$value = explode( ',', $value );
141
				}
142
				$value = (object) $value;
143
			}
144
145
			if ( 'object_merge' === $type && $value !== $default ) {
146
				$value = (object) array_merge( (array) $default, (array) $value );
147
			}
148
		} elseif ( 'integer' === $type || 'int' === $type || 'absint' === $type ) {
149
			if ( ! is_numeric( trim( $value ) ) ) {
150
				$value = 0;
151
			} else {
152
				$value = intval( $value );
153
			}
154
155
			if ( 'absint' === $type ) {
156
				$value = abs( $value );
157
			}
158
		} elseif ( 'boolean' === $type || 'bool' === $type ) {
159
			$value = (boolean) $value;
160
		} elseif ( 'in_array' === $type && is_array( $default ) ) {
161
			if ( is_array( $value ) ) {
162
				foreach ( $value as $k => $v ) {
163
					if ( ! in_array( $v, $extra, true ) ) {
164
						unset( $value[ $k ] );
165
					}
166
				}
167
			} elseif ( ! in_array( $value, $extra, true ) ) {
168
				$value = $default;
169
			}
170
		} elseif ( 'isset' === $type && is_array( $default ) ) {
171
			if ( is_array( $value ) ) {
172
				foreach ( $value as $k => $v ) {
173
					if ( ! isset( $extra[ $v ] ) ) {
174
						unset( $value[ $k ] );
175
					}
176
				}
177
			} elseif ( ! isset( $extra[ $value ] ) ) {
178
				$value = $default;
179
			}
180
		}//end if
181
182
		$this->offsetSet( $offset, $value );
183
184
		return $value;
185
	}
186
187
	/**
188
	 * Dump the PodsArray object to array
189
	 *
190
	 * @return array Array version of the object
191
	 *
192
	 * @since 2.0
193
	 */
194
	public function dump() {
195
196
		if ( is_array( $this->__container ) ) {
197
			return $this->__container;
198
		}
199
200
		return get_object_vars( $this->__container );
201
	}
202
203
	/**
204
	 * Mapping >> offsetSet
205
	 *
206
	 * @param mixed $offset Property name.
207
	 * @param mixed $value  Property value.
208
	 *
209
	 * @return mixed
210
	 * @since 2.0
211
	 */
212
	public function __set( $offset, $value ) {
213
214
		return $this->offsetSet( $offset, $value );
215
	}
216
217
	/**
218
	 * Mapping >> offsetGet
219
	 *
220
	 * @param mixed $offset Property name.
221
	 *
222
	 * @return mixed|null
223
	 * @since 2.0
224
	 */
225
	public function __get( $offset ) {
226
227
		return $this->offsetGet( $offset );
228
	}
229
230
	/**
231
	 * Mapping >> offsetExists
232
	 *
233
	 * @param mixed $offset Property name.
234
	 *
235
	 * @return bool
236
	 * @since 2.0
237
	 */
238
	public function __isset( $offset ) {
239
240
		return $this->offsetExists( $offset );
241
	}
242
243
	/**
244
	 * Mapping >> offsetUnset
245
	 *
246
	 * @param mixed $offset Property name.
247
	 *
248
	 * @since 2.0
249
	 */
250
	public function __unset( $offset ) {
251
252
		$this->offsetUnset( $offset );
253
	}
254
}
255