Issues (28)

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/Cursor.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
3
/**
4
 * This software package is licensed under AGPL or Commercial license.
5
 *
6
 * @package maslosoft/mangan
7
 * @licence AGPL or Commercial
8
 * @copyright Copyright (c) Piotr MaseÅ‚kowski <[email protected]>
9
 * @copyright Copyright (c) Maslosoft
10
 * @copyright Copyright (c) Others as mentioned in code
11
 * @link https://maslosoft.com/mangan/
12
 */
13
14
namespace Maslosoft\Mangan;
15
16
use Countable;
17
use Iterator;
18
use Maslosoft\Addendum\Interfaces\AnnotatedInterface;
19
use Maslosoft\Mangan\Interfaces\Adapters\FinderCursorInterface;
20
use Maslosoft\Mangan\Transformers\RawArray;
21
use MongoCursor;
22
use UnexpectedValueException;
23
24
/**
25
 * Cursor
26
 *
27
 * Cursor object, that behaves much like the MongoCursor,
28
 * but this one returns instantiated objects
29
 * @author Ianaré Sévi
30
 * @author Dariusz Górecki <[email protected]>
31
 * @author Invenzzia Group, open-source division of CleverIT company http://www.invenzzia.org
32
 * @copyright 2011 CleverIT http://www.cleverit.com.pl
33
 * @since v1.3.4
34
 */
35
class Cursor implements Iterator, Countable
36
{
37
38
	/**
39
	 * MongoCursor returned by the query
40
	 * @var FinderCursorInterface|MongoCursor
41
	 * @since v1.3.4
42
	 */
43
	private $cursor;
44
45
	/**
46
	 * Model used for instantiating objects
47
	 * @var AnnotatedInterface
48
	 * @since v1.3.4
49
	 */
50
	private $model;
51
52
	/**
53
	 * Construct a new Cursor
54
	 *
55
	 * @param FinderCursorInterface|MongoCursor $cursor the cursor returned by the query
56
	 * @param AnnotatedInterface $model the model for instantiating objects
57
	 * @since v1.3.4
58
	 */
59 1
	public function __construct(Iterator $cursor, AnnotatedInterface $model)
60
	{
61 1
		assert($cursor instanceof FinderCursorInterface || $cursor instanceof MongoCursor, new UnexpectedValueException(sprintf('Expected `%s` or `%s` got `%s`', FinderCursorInterface::class, MongoCursor::class, get_class($cursor))));
62 1
		$this->cursor = $cursor;
63 1
		$this->model = $model;
64 1
	}
65
66
	/**
67
	 * Return MongoCursor for additional tuning
68
	 *
69
	 * @return FinderCursorInterface|MongoCursor the cursor used for this query
70
	 * @since v1.3.4
71
	 */
72
	public function getCursor()
73
	{
74
		return $this->cursor;
75
	}
76
77
	/**
78
	 * Return the current element
79
	 * @return AnnotatedInterface|Document|null
80
	 * @since v1.3.4
81
	 */
82 1
	public function current()
83
	{
84 1
		$document = $this->cursor->current();
85 1
		if (empty($document))
86
		{
87
			return null;
88
		}
89
90 1
		return RawArray::toModel($document, $this->model);
0 ignored issues
show
$this->model is of type object<Maslosoft\Addendu...ces\AnnotatedInterface>, but the function expects a string|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
91
	}
92
93
	/**
94
	 * Return the key of the current element
95
	 * @return scalar
96
	 * @since v1.3.4
97
	 */
98
	public function key()
99
	{
100
		return $this->cursor->key();
101
	}
102
103
	/**
104
	 * Move forward to next element
105
	 * @return void
106
	 * @since v1.3.4
107
	 */
108 1
	public function next()
109
	{
110 1
		$this->cursor->next();
111 1
	}
112
113
	/**
114
	 * Rewind the Iterator to the first element
115
	 * @return void
116
	 * @since v1.3.4
117
	 */
118 1
	public function rewind()
119
	{
120 1
		$this->cursor->rewind();
121 1
	}
122
123
	/**
124
	 * Checks if current position is valid
125
	 * @return boolean
126
	 * @since v1.3.4
127
	 */
128 1
	public function valid()
129
	{
130 1
		return $this->cursor->valid();
131
	}
132
133
	/**
134
	 * Returns the number of documents found
135
	 * {@see http://www.php.net/manual/en/mongocursor.count.php}
136
	 * @param boolean $foundOnly default FALSE
137
	 * @return integer count of documents found
138
	 * @since v1.3.4
139
	 */
140 1
	public function count($foundOnly = false)
141
	{
142 1
		return $this->cursor->count($foundOnly);
143
	}
144
145
	/**
146
	 * Apply a limit to this cursor
147
	 * {@see http://www.php.net/manual/en/mongocursor.limit.php}
148
	 * @param integer $limit new limit
149
	 * @since v1.3.4
150
	 */
151
	public function limit($limit)
152
	{
153
		$this->cursor->limit($limit);
154
	}
155
156
	/**
157
	 * Skip a $offset records
158
	 * {@see http://www.php.net/manual/en/mongocursor.skip.php}
159
	 * @param integer $offset new skip
160
	 * @since v1.3.4
161
	 */
162
	public function offset($offset)
163
	{
164
		$this->cursor->skip($offset);
165
	}
166
167
	/**
168
	 * Apply sorting directives
169
	 * {@see http://www.php.net/manual/en/mongocursor.sort.php}
170
	 * @param array $fields sorting directives
171
	 * @since v1.3.4
172
	 */
173
	public function sort(array $fields)
174
	{
175
		$this->cursor->sort($fields);
176
	}
177
178
}
179