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.

Aggregation/Bucketing/GeoDistanceAggregation.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 geo distance aggregation.
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html
21
 */
22
class GeoDistanceAggregation extends AbstractAggregation
23
{
24
    use BucketingTrait;
25
26
    /**
27
     * @var mixed
28
     */
29
    private $origin;
30
31
    /**
32
     * @var string
33
     */
34
    private $distanceType;
35
36
    /**
37
     * @var string
38
     */
39
    private $unit;
40
41
    /**
42
     * @var array
43
     */
44
    private $ranges = [];
45
46
    /**
47
     * Inner aggregations container init.
48
     *
49
     * @param string $name
50
     * @param string $field
51
     * @param mixed  $origin
52
     * @param array  $ranges
53
     * @param string $unit
54
     * @param string $distanceType
55
     */
56
    public function __construct($name, $field = null, $origin = null, $ranges = [], $unit = null, $distanceType = null)
57
    {
58
        parent::__construct($name);
59
60
        $this->setField($field);
61
        $this->setOrigin($origin);
62
        foreach ($ranges as $range) {
63
            $from = isset($range['from']) ? $range['from'] : null;
64
            $to = isset($range['to']) ? $range['to'] : null;
65
            $this->addRange($from, $to);
66
        }
67
        $this->setUnit($unit);
68
        $this->setDistanceType($distanceType);
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function getOrigin()
75
    {
76
        return $this->origin;
77
    }
78
79
    /**
80
     * @param mixed $origin
81
     *
82
     * @return $this
83
     */
84
    public function setOrigin($origin)
85
    {
86
        $this->origin = $origin;
87
88
        return $this;
89
    }
90
91
    /**
92
     * @return string
93
     */
94
    public function getDistanceType()
95
    {
96
        return $this->distanceType;
97
    }
98
99
    /**
100
     * @param string $distanceType
101
     *
102
     * @return $this
103
     */
104
    public function setDistanceType($distanceType)
105
    {
106
        $this->distanceType = $distanceType;
107
108
        return $this;
109
    }
110
111
    /**
112
     * @return string
113
     */
114
    public function getUnit()
115
    {
116
        return $this->unit;
117
    }
118
119
    /**
120
     * @param string $unit
121
     *
122
     * @return $this
123
     */
124
    public function setUnit($unit)
125
    {
126
        $this->unit = $unit;
127
128
        return $this;
129
    }
130
131
    /**
132
     * Add range to aggregation.
133
     *
134
     * @param int|float|null $from
135
     * @param int|float|null $to
136
     *
137
     * @throws \LogicException
138
     *
139
     * @return GeoDistanceAggregation
140
     */
141 View Code Duplication
    public function addRange($from = null, $to = null)
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...
142
    {
143
        $range = array_filter(
144
            [
145
                'from' => $from,
146
                'to' => $to,
147
            ],
148
            function ($v) {
149
                return !is_null($v);
150
            }
151
        );
152
153
        if (empty($range)) {
154
            throw new \LogicException('Either from or to must be set. Both cannot be null.');
155
        }
156
157
        $this->ranges[] = $range;
158
159
        return $this;
160
    }
161
162
    /**
163
     * {@inheritdoc}
164
     */
165
    public function getArray()
166
    {
167
        $data = [];
168
169
        if ($this->getField()) {
170
            $data['field'] = $this->getField();
171
        } else {
172
            throw new \LogicException('Geo distance aggregation must have a field set.');
173
        }
174
175
        if ($this->getOrigin()) {
176
            $data['origin'] = $this->getOrigin();
177
        } else {
178
            throw new \LogicException('Geo distance aggregation must have an origin set.');
179
        }
180
181
        if ($this->getUnit()) {
182
            $data['unit'] = $this->getUnit();
183
        }
184
185
        if ($this->getDistanceType()) {
186
            $data['distance_type'] = $this->getDistanceType();
187
        }
188
189
        $data['ranges'] = $this->ranges;
190
191
        return $data;
192
    }
193
194
    /**
195
     * {@inheritdoc}
196
     */
197
    public function getType()
198
    {
199
        return 'geo_distance';
200
    }
201
}
202