Issues (279)

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.

classes/Kohana/Jam/Range.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 defined('SYSPATH') OR die('No direct script access.');
2
3
/**
4
 * This class is what the upload field accually returns
5
 * and has all the nesessary info and manipulation abilities to save / delete / validate itself
6
 *
7
 * @package    Jam
8
 * @author     Ivan Kerin
9
 * @copyright  (c) 2011-2012 Despark Ltd.
10
 * @license    http://creativecommons.org/licenses/by-sa/3.0/legalcode
11
*/
12
class Kohana_Jam_Range implements ArrayAccess, Serializable {
13
14
	protected $_min;
15
16
	protected $_max;
17
18
	protected $_format = ":min - :max";
19
20 58
	public function format($format = NULL)
21
	{
22 58
		if ($format !== NULL)
23
		{
24 13
			$this->_format = $format;
25 13
			return $this;
26
		}
27 58
		return $this->_format;
28
	}
29
30 1
	public static function sum(array $ranges, $format = NULL)
31
	{
32 1
		$min = 0;
33 1
		$max = 0;
34
35 1
		foreach ($ranges as $range)
36
		{
37 1
			$min += (int) $range->min();
38 1
			$max += (int) $range->max();
39
		}
40
41 1
		return new Jam_Range(array($min, $max), $format);
42
	}
43
44 1
	public static function merge(array $ranges, $format = NULL)
45
	{
46 1
		$min = 0;
47 1
		$max = 0;
48
49 1
		foreach ($ranges as $range)
50
		{
51 1
			$min = max($min, $range->min());
52 1
			$max = max($max, $range->max());
53
		}
54
55 1
		return new Jam_Range(array($min, $max), $format);
56
	}
57
58 57
	public function __construct($source = NULL, $format = NULL)
59
	{
60 57
		if (is_string($source) AND $source !== '')
61
		{
62 6
			$source = explode('|', $source);
63
		}
64
65 57
		if (is_array($source))
66
		{
67 46
			$this->min($source[0]);
68 46
			$this->max($source[1]);
69
		}
70 13
		elseif ($source instanceof Jam_Range)
71
		{
72 3
			$this->min($source->min());
73 3
			$this->max($source->max());
74
		}
75
76 57
		$this->format($format);
77 57
	}
78
79 59
	public function min($min = NULL)
80
	{
81 59
		if ($min !== NULL)
82
		{
83 48
			$this->_min = (float) $min;
84 48
			return $this;
85
		}
86 59
		return $this->_min;
87
	}
88
89 56
	public function max($max = NULL)
90
	{
91 56
		if ($max !== NULL)
92
		{
93 48
			$this->_max =(float) $max;
94 48
			return $this;
95
		}
96 56
		return $this->_max;
97
	}
98
99 1
	public function add(Jam_Range $addition)
100
	{
101 1
		return Jam_Range::sum(array($this, $addition), $this->format());
102
	}
103
104 2
	public function offsetSet($offset, $value)
105
	{
106 2
		if (is_null($offset))
107
			throw new Kohana_Exception('Cannot add new values to range');
108
109 2
		if ($offset == 0)
110
		{
111 1
			$this->min($value);
112
		}
113 2
		elseif ($offset == 1)
114
		{
115 1
			$this->max($value);
116
		}
117
		else
118
		{
119 1
			throw new Kohana_Exception('Use offset 0 for min and offset 1 for max, offset :offset not supported', array(':offset' => $offset));
120
		}
121 1
	}
122
123 4
	public function offsetExists($offset)
124
	{
125 4
		return ($offset == 0 OR $offset == 1);
126
	}
127
128 1
	public function offsetUnset($offset)
129
	{
130 1
		throw new Kohana_Exception('Cannot unset range object');
131
	}
132
133 1
	public function offsetGet($offset)
134
	{
135 1
		if ( ! $this->offsetExists($offset))
136
			throw new Kohana_Exception('Use offset 0 for min and offset 1 for max, offset :offset not supported', array(':offset' => $offset));
137
138 1
		return $offset ? $this->max() : $this->min();
139
	}
140
141 4
	public function __toString()
142
	{
143 4
		return $this->min().'|'.$this->max();
144
	}
145
146 7
	public function humanize()
147
	{
148 7
		if (is_callable($this->format()))
149
		{
150
			return call_user_func($this->format(), $this->min(), $this->max());
151
		}
152
		else
153
		{
154 7
			return strtr($this->format(), array(':min' => $this->min(), ':max' => $this->max()));
0 ignored issues
show
It seems like $this->format() targeting Kohana_Jam_Range::format() can also be of type this<Kohana_Jam_Range>; however, strtr() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
155
		}
156
	}
157
158 1
	public function as_array()
159
	{
160 1
		return array($this->min(), $this->max());
161
	}
162
163 1
	public function serialize()
164
	{
165 1
		return $this->__toString();
166
	}
167
168 1
	public function unserialize($data)
169
	{
170 1
		list($min, $max) = explode('|', $data);
171
172 1
		$this->min($min);
173 1
		$this->max($max);
174 1
	}
175
}
176