Issues (74)

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.

Query/Filter.php (3 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
namespace Netdudes\DataSourceryBundle\Query;
3
4
use Netdudes\DataSourceryBundle\Util\AbstractArrayAccessibleCollection;
5
6
/**
7
 * Group of filters bundled with a condition type
8
 */
9
class Filter extends AbstractArrayAccessibleCollection implements \JsonSerializable
10
{
11
    /**
12
     * The filters are concatenated AND-wise
13
     */
14
    const CONDITION_TYPE_AND = 'AND';
15
16
    /**
17
     * The filters are concatenated OR-wise
18
     */
19
    const CONDITION_TYPE_OR = 'OR';
20
21
    /**
22
     * The filters are concatenated XOR-wise
23
     * Note: This is not currently supported by Doctrine, but left in for completeness
24
     */
25
    const CONDITION_TYPE_XOR = 'XOR';
26
27
    /**
28
     * Condition concatenation type, by default OR
29
     *
30
     * @var int
31
     */
32
    private $conditionType = self::CONDITION_TYPE_AND;
33
34
    /**
35
     * Create a FilterDefinition from a deserialized compact exchange JSON filters.
36
     * This wil recursively call itself to unpack the whole filter tree.
37
     *
38
     * @param $jsonSerializable
39
     *
40
     * @return array|Filter|FilterCondition
41
     * @throws \Exception
42
     * @deprecated Deprecated to be removed in 1.0.0. It seems to be unused.
43
     */
44
    public static function createFromJsonSerializable($jsonSerializable)
45
    {
46
        @trigger_error('createFromJsonSerializable() is deprecated and will be removed in 1.0.0. It seems to be unused.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
47
48
        if (!count((array) $jsonSerializable)) {
49
            // Edge case: empty filter
50
            return new Filter();
51
        }
52
53
        if (count($jsonSerializable) == 2 && is_array($jsonSerializable[1])) {
54
            // Complex Filter
55
            $logic = $jsonSerializable[0];
56
            $elements = $jsonSerializable[1];
57
            $filter = new Filter();
58
            $filter->setConditionType($logic);
59
            foreach ($elements as $element) {
60
                $filter[] = static::createFromJsonSerializable($element);
0 ignored issues
show
Deprecated Code introduced by
The method Netdudes\DataSourceryBun...eFromJsonSerializable() has been deprecated with message: Deprecated to be removed in 1.0.0. It seems to be unused.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
61
            }
62
63
            return $filter;
64
        } elseif (count($jsonSerializable) == 3) {
65
            // Simple element
66
            return new FilterCondition($jsonSerializable[0], $jsonSerializable[1], $jsonSerializable[2], $jsonSerializable[2]);
67
        }
68
69
        throw new \Exception('Unable to parse JSON-serializable filter structure');
70
    }
71
72
    public function toUQL()
73
    {
74
        $parts = [];
75
        foreach ($this as $filter) {
76
            $subFilterUql = $filter->toUQL();
77
            if ($filter instanceof Filter) {
78
                $subFilterUql = '(' . $subFilterUql . ')';
79
            }
80
            $parts[] = $subFilterUql;
81
        }
82
83
        return implode(" " . strtolower($this->conditionType) . " ", $parts);
84
    }
85
86
    /**
87
     * (PHP 5 &gt;= 5.4.0)<br/>
88
     * Specify data which should be serialized to JSON
89
     *
90
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
91
     * @return mixed data which can be serialized by <b>json_encode</b>,
92
     *               which is a value of any type other than a resource.
93
     */
94
    public function jsonSerialize()
95
    {
96
        $serializableArray = [
97
            'logic' => $this->getConditionType(),
98
            'elements' => [],
99
        ];
100
        foreach ($this as $filter) {
101
            $serializableArray['elements'][] = $filter->toJsonSerializable();
102
        }
103
104
        return $serializableArray;
105
    }
106
107
    /**
108
     * Recursively compact into a easily JSON-serializable array
109
     * representation
110
     * @deprecated Deprecated to be removed in 1.0.0. It seems to be unused.
111
     */
112
    public function toJsonSerializable()
113
    {
114
        @trigger_error('toJsonSerializable() is deprecated and will be removed in 1.0.0. It seems to be unused.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
115
116
        return $this->jsonSerialize();
117
    }
118
119
    /**
120
     * @return int
121
     */
122
    public function getConditionType()
123
    {
124
        return $this->conditionType;
125
    }
126
127
    /**
128
     * @param int $conditionType
129
     */
130
    public function setConditionType($conditionType)
131
    {
132
        $this->conditionType = $conditionType;
133
    }
134
135
    public function getAllFirstLevelFilteredDataSourceUniqueNames()
136
    {
137
        $filteredDataSourceIds = [];
138
        foreach ($this as $element) {
139
            if ($element instanceof FilterCondition) {
140
                $filteredDataSourceIds[] = $element->getFieldName();
141
            }
142
        }
143
144
        return $filteredDataSourceIds;
145
    }
146
147
    /**
148
     * Flatten the tree of Filters into a one-dimensional array
149
     * or FilterConditions.
150
     *
151
     * @return FilterCondition[]
152
     */
153
    public function getAllFilterConditionsFlat()
154
    {
155
        $flatConditionsList = [];
156
        $flatten = function (Filter $filterDefinition) use (&$flatConditionsList, &$flatten) {
157
            foreach ($filterDefinition as $filter) {
158
                if ($filter instanceof Filter) {
159
                    $flatten($filter);
160
                } elseif ($filter instanceof FilterCondition) {
161
                    $flatConditionsList[] = $filter;
162
                }
163
            }
164
        };
165
        $flatten($this);
166
167
        return $flatConditionsList;
168
    }
169
}
170