Issues (13)

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/Database/Clusterpoint/Finder.php (1 issue)

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 Fathomminds\Rest\Database\Clusterpoint;
3
4
use Fathomminds\Rest\Exceptions\RestException;
5
use Fathomminds\Rest\Database\Finder as BaseFinder;
6
use Clusterpoint\Client;
7
8
class Finder extends BaseFinder
9
{
10
    /**
11
     * @param \Clusterpoint\Instance\Service $collection
12
     */
13
    protected function setLimit($collection)
14
    {
15
        if ($this->queryConfiguration->limit !== null) {
16
            $collection->limit($this->queryConfiguration->limit);
17
        }
18
    }
19
20
    /**
21
     * @param \Clusterpoint\Instance\Service $collection
22
     */
23
    protected function setOffset($collection)
24
    {
25
        if ($this->queryConfiguration->offset !== null) {
26
            $collection->offset($this->queryConfiguration->offset);
27
        }
28
    }
29
30
    /**
31
     * @param \Clusterpoint\Instance\Service $collection
32
     */
33
    protected function setOrderBy($collection)
34
    {
35
        foreach ($this->queryConfiguration->orderBy as $orderBy) {
36
            $collection->orderBy(key($orderBy), current($orderBy));
37
        }
38
    }
39
40
    /**
41
     * @param \Clusterpoint\Instance\Service $collection
42
     */
43
    protected function setSelect($collection)
44
    {
45
        if ($this->queryConfiguration->select !== '*') {
46
            $collection->select($this->queryConfiguration->select);
47
        }
48
    }
49
50
    /**
51
     * @param \Clusterpoint\Instance\Service $collection
52
     */
53
    protected function setWhere($collection)
54
    {
55
        if (!empty($this->queryConfiguration->where)) {
56
            $this->parseWhere($collection, $this->queryConfiguration->where, $this->mainLogical);
57
        }
58
    }
59
60
    /**
61
     * @param \Clusterpoint\Instance\Service $collection
62
     */
63
    protected function configQuery($collection)
64
    {
65
        $this->setLimit($collection);
66
        $this->setOffset($collection);
67
        $this->setOrderBy($collection);
68
        $this->setSelect($collection);
69
        $this->setWhere($collection);
70
    }
71
72
    public function get()
73
    {
74
        if (!($this->client instanceof Client)) {
75
            throw new RestException(
76
                'Clusterpoint Finder can be used with Clusterpoint Client only',
77
                ['type' => get_class($this->client)]
78
            );
79
        }
80
        $collection = $this->client->database(
81
            $this->queryConfiguration->databaseName .
82
            '.' .
83
            $this->queryConfiguration->from
84
        );
85
        $this->configQuery($collection);
86
        $items = json_decode(json_encode($collection->get()->toArray()));
87
        $count = count($items);
88
        for ($idx = 0; $idx < $count; $idx++) {
89
            $this->resultSet[] = $items[$idx];
90
        }
91
        return $this;
92
    }
93
94
    protected function createClient()
95
    {
96
        $this->client = new Client;
97
        return $this;
98
    }
99
100
    /**
101
     * @param \Clusterpoint\Instance\Service $collection
102
     * @param array $conditions @param string $logical
103
     * @return \Closure
104
     */
105
    protected function addWhereGroup($collection, $conditions, $logical)
0 ignored issues
show
The parameter $collection is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
106
    {
107
        /**
108
         * @codeCoverageIgnore
109
         * Passing anonymous function to Clusterpoint API
110
         */
111
        return function($collection) use ($conditions, $logical) {
112
            $this->parseWhere($collection, $conditions, $logical);
113
        };
114
    }
115
116
    /**
117
     * @param string $logical
118
     * @param \Clusterpoint\Instance\Service $collection
119
     * @param array $condition
120
     * @param string $nextLogical
121
     */
122
    protected function parseWhereGroup($logical, $collection, $condition, $nextLogical)
123
    {
124
        if ($logical === '||') {
125
            $collection->orWhere($this->addWhereGroup($collection, $condition, $nextLogical));
126
        }
127
        if ($logical === '&&') {
128
            $collection->where($this->addWhereGroup($collection, $condition, $nextLogical));
129
        }
130
    }
131
132
    /**
133
     * @param \Clusterpoint\Instance\Service $collection
134
     * @param array $conditions
135
     * @param string $logical
136
     */
137
    private function parseWhere($collection, $conditions, $logical)
138
    {
139
        foreach ($conditions as $key => $condition) {
140
            switch (strtoupper($key)) {
141
                case 'AND':
142
                    $this->parseWhereGroup($logical, $collection, $condition, '&&');
143
                    break;
144
                case 'OR':
145
                    $this->parseWhereGroup($logical, $collection, $condition, '||');
146
                    break;
147
                default:
148
                    list($fieldName, $operator, $value) = $condition;
149
                    $collection->where($fieldName, $operator, $value, $logical, false);
150
            }
151
        }
152
    }
153
}
154