Issues (63)

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/Aggregation/Bucketing/RangeAggregation.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 file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\ElasticsearchDSL\Aggregation\Bucketing;
13
14
use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation;
15
use ONGR\ElasticsearchDSL\Aggregation\Type\BucketingTrait;
16
17
/**
18
 * Class representing RangeAggregation.
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html
21
 */
22
class RangeAggregation extends AbstractAggregation
23
{
24
    use BucketingTrait;
25
26
    /**
27
     * @var array
28
     */
29
    private $ranges = [];
30
31
    /**
32
     * @var bool
33
     */
34
    private $keyed = false;
35
36
    /**
37
     * Inner aggregations container init.
38
     *
39
     * @param string $name
40
     * @param string $field
41
     * @param array  $ranges
42
     * @param bool   $keyed
43
     */
44 View Code Duplication
    public function __construct($name, $field = null, $ranges = [], $keyed = false)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        parent::__construct($name);
47
48
        $this->setField($field);
49
        $this->setKeyed($keyed);
50
        foreach ($ranges as $range) {
51
            $from = isset($range['from']) ? $range['from'] : null;
52
            $to = isset($range['to']) ? $range['to'] : null;
53
            $key = isset($range['key']) ? $range['key'] : null;
54
            $this->addRange($from, $to, $key);
55
        }
56
    }
57
58
    /**
59
     * Sets if result buckets should be keyed.
60
     *
61
     * @param bool $keyed
62
     *
63
     * @return $this
64
     */
65
    public function setKeyed($keyed)
66
    {
67
        $this->keyed = $keyed;
68
69
        return $this;
70
    }
71
72
    /**
73
     * Add range to aggregation.
74
     *
75
     * @param int|float|null $from
76
     * @param int|float|null $to
77
     * @param string         $key
78
     *
79
     * @return RangeAggregation
80
     */
81
    public function addRange($from = null, $to = null, $key = '')
82
    {
83
        $range = array_filter(
84
            [
85
                'from' => $from,
86
                'to' => $to,
87
            ],
88
            function ($v) {
89
                return !is_null($v);
90
            }
91
        );
92
93
        if (!empty($key)) {
94
            $range['key'] = $key;
95
        }
96
97
        $this->ranges[] = $range;
98
99
        return $this;
100
    }
101
102
    /**
103
     * Remove range from aggregation. Returns true on success.
104
     *
105
     * @param int|float|null $from
106
     * @param int|float|null $to
107
     *
108
     * @return bool
109
     */
110
    public function removeRange($from, $to)
111
    {
112
        foreach ($this->ranges as $key => $range) {
113
            if (array_diff_assoc(array_filter(['from' => $from, 'to' => $to]), $range) === []) {
114
                unset($this->ranges[$key]);
115
116
                return true;
117
            }
118
        }
119
120
        return false;
121
    }
122
123
    /**
124
     * Removes range by key.
125
     *
126
     * @param string $key Range key.
127
     *
128
     * @return bool
129
     */
130
    public function removeRangeByKey($key)
131
    {
132
        if ($this->keyed) {
133
            foreach ($this->ranges as $rangeKey => $range) {
134
                if (array_key_exists('key', $range) && $range['key'] === $key) {
135
                    unset($this->ranges[$rangeKey]);
136
137
                    return true;
138
                }
139
            }
140
        }
141
142
        return false;
143
    }
144
145
    /**
146
     * {@inheritdoc}
147
     */
148
    public function getArray()
149
    {
150
        $data = [
151
            'keyed' => $this->keyed,
152
            'ranges' => array_values($this->ranges),
153
        ];
154
155
        if ($this->getField()) {
156
            $data['field'] = $this->getField();
157
        }
158
159
        return $data;
160
    }
161
162
    /**
163
     * {@inheritdoc}
164
     */
165
    public function getType()
166
    {
167
        return 'range';
168
    }
169
}
170