Issues (15)

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/ElasticClient.php (2 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
/**
3
 * Created by PhpStorm.
4
 * User: mina
5
 * Date: 3/17/17
6
 * Time: 2:20 AM
7
 */
8
9
namespace MAbadir\ElasticLaravel;
10
use Elasticsearch\ClientBuilder as Elastic;
11
12
class ElasticClient
13
{
14
    protected $index, $params, $client;
0 ignored issues
show
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
15
16
    /**
17
     * Connection constructor.
18
     */
19
    public function __construct()
20
    {
21
        $this->params = [
22
            'index' => config('elastic.index')
23
        ];
24
25
        $hosts = [
26
            [
27
                'host' => config('elastic.host'),
28
                'port' => config('elastic.port'),
29
//            'scheme' => 'https',
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
30
//            'user' => 'username',
31
//            'pass' => 'password!#$?*abc'
32
            ]
33
        ];
34
35
        $this->client = Elastic::create()           // Instantiate a new ClientBuilder
36
                                ->setHosts($hosts)      // Set the hosts
37
                                ->build();
38
    }
39
40
    /**
41
     * Merges Parameters received by client with index parameter
42
     *
43
     * @param $params
44
     *
45
     * @return array
46
     */
47
    protected function mergeParams($params)
48
    {
49
        return $this->params + $params;
50
    }
51
52
    /**
53
     * Returns the Elastic Search Client instance
54
     * @return \Elasticsearch\Client
55
     */
56
    public function getClient()
57
    {
58
        return $this->client;
59
    }
60
61
    /**
62
     * Creates the index with the given $params settings
63
     *
64
     * @param $params
65
     *
66
     * @return array
67
     */
68
    public function createIndex($params = [])
69
    {
70
        return $this->client->indices()->create($this->mergeParams($params));
71
    }
72
73
    /**
74
     * Drops the index with the given $params settings
75
     *
76
     * @param $params
77
     *
78
     * @return array
79
     */
80
    public function dropIndex($params = [])
81
    {
82
        return $this->client->indices()->delete($this->mergeParams($params));
83
    }
84
85
    /**
86
     * Indexes a document of the given parameters
87
     *
88
     * @param $params
89
     *
90
     * @return array
91
     */
92
    public function index($params)
93
    {
94
        return $this->client->index($this->mergeParams($params));
95
    }
96
97
    /**
98
     * Retrieves a document of the given parameters
99
     *
100
     * @param $params
101
     *
102
     * @return array
103
     */
104
    public function get($params)
105
    {
106
        return $this->client->get($this->mergeParams($params));
107
    }
108
109
    /**
110
     * Updates a document of the given parameters
111
     *
112
     * @param $params
113
     *
114
     * @return array
115
     */
116
    public function update($params)
117
    {
118
        return $this->client->update($this->mergeParams($params));
119
    }
120
121
    /**
122
     * Deletes a document of the given parameters
123
     *
124
     * @param $params
125
     *
126
     * @return array
127
     */
128
    public function delete($params)
129
    {
130
        return $this->client->delete($this->mergeParams($params));
131
    }
132
133
    /**
134
     * Searches the index with the given params
135
     *
136
     * @param $params
137
     *
138
     * @return array
139
     */
140
    public function search($params)
141
    {
142
        return $this->client->search($this->mergeParams($params));
143
    }
144
}