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/DateRangeAggregation.php (2 issues)

duplicate/similar methods.

Duplication Informational

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 date range aggregation.
19
 *
20
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
21
 */
22
class DateRangeAggregation extends AbstractAggregation
23
{
24
    use BucketingTrait;
25
26
    /**
27
     * @var string
28
     */
29
    private $format;
30
31
    /**
32
     * @var array
33
     */
34
    private $ranges = [];
35
36
    /**
37
     * @var bool
38
     */
39
    private $keyed = false;
40
41
    /**
42
     * @param string $name
43
     * @param string $field
44
     * @param string $format
45
     * @param array  $ranges
46
     * @param bool   $keyed
47
     */
48 View Code Duplication
    public function __construct($name, $field = null, $format = null, array $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...
49
    {
50
        parent::__construct($name);
51
52
        $this->setField($field);
53
        $this->setFormat($format);
54
        $this->setKeyed($keyed);
55
        foreach ($ranges as $range) {
56
            $from = isset($range['from']) ? $range['from'] : null;
57
            $to = isset($range['to']) ? $range['to'] : null;
58
            $key = isset($range['key']) ? $range['key'] : null;
59
            $this->addRange($from, $to, $key);
60
        }
61
    }
62
63
    /**
64
     * Sets if result buckets should be keyed.
65
     *
66
     * @param bool $keyed
67
     *
68
     * @return DateRangeAggregation
69
     */
70
    public function setKeyed($keyed)
71
    {
72
        $this->keyed = $keyed;
73
74
        return $this;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getFormat()
81
    {
82
        return $this->format;
83
    }
84
85
    /**
86
     * @param string $format
87
     */
88
    public function setFormat($format)
89
    {
90
        $this->format = $format;
91
    }
92
93
    /**
94
     * Add range to aggregation.
95
     *
96
     * @param string|null $from
97
     * @param string|null $to
98
     * @param string|null $key
99
     *
100
     * @return $this
101
     *
102
     * @throws \LogicException
103
     */
104 View Code Duplication
    public function addRange($from = null, $to = null, $key = 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...
105
    {
106
        $range = array_filter(
107
            [
108
                'from' => $from,
109
                'to' => $to,
110
                'key' => $key,
111
            ],
112
            function ($v) {
113
                return !is_null($v);
114
            }
115
        );
116
117
        if (empty($range)) {
118
            throw new \LogicException('Either from or to must be set. Both cannot be null.');
119
        }
120
121
        $this->ranges[] = $range;
122
123
        return $this;
124
    }
125
126
    /**
127
     * {@inheritdoc}
128
     */
129
    public function getArray()
130
    {
131
        if ($this->getField() && $this->getFormat() && !empty($this->ranges)) {
132
            $data = [
133
                'format' => $this->getFormat(),
134
                'field' => $this->getField(),
135
                'ranges' => $this->ranges,
136
                'keyed' => $this->keyed,
137
            ];
138
139
            return $data;
140
        }
141
        throw new \LogicException('Date range aggregation must have field, format set and range added.');
142
    }
143
144
    /**
145
     * {@inheritdoc}
146
     */
147
    public function getType()
148
    {
149
        return 'date_range';
150
    }
151
}
152