Issues (3099)

Security Analysis    not enabled

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/Kunstmaan/SearchBundle/Search/Search.php (7 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
namespace Kunstmaan\SearchBundle\Search;
4
5
use Kunstmaan\SearchBundle\Provider\SearchProviderChainInterface;
6
use Kunstmaan\SearchBundle\Provider\SearchProviderInterface;
7
8
/**
9
 * Search class which will delegate to the active SearchProvider
10
 * The active SearchProvider can be overridden by overriding the "kunstmaan_search.search" parameter
11
 */
12
class Search implements SearchProviderInterface
13
{
14
    /**
15
     * @var SearchProviderChainInterface
16
     */
17
    private $searchProviderChain;
18
19
    /**
20
     * @var string
21
     */
22
    private $indexNamePrefix;
23
24
    /**
25
     * @var string
26
     */
27
    private $activeProvider;
28
29
    /**
30
     * @param SearchProviderChainInterface $searchProviderChain
31
     * @param string                       $indexNamePrefix
32
     * @param string                       $activeProvider
33
     */
34
    public function __construct(SearchProviderChainInterface $searchProviderChain, $indexNamePrefix, $activeProvider)
35
    {
36
        $this->searchProviderChain = $searchProviderChain;
37
        $this->indexNamePrefix = $indexNamePrefix;
38
        $this->activeProvider = $activeProvider;
39
    }
40
41
    /**
42
     * Get the current active SearchProvider
43
     *
44
     * @return SearchProviderInterface
45
     */
46
    public function getActiveProvider()
47
    {
48
        return $this->searchProviderChain->getProvider($this->activeProvider);
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function createIndex($indexName)
55
    {
56
        return $this->getActiveProvider()->createIndex($this->indexNamePrefix . $indexName);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62
    public function getIndex($indexName)
63
    {
64
        return $this->getActiveProvider()->getIndex($this->indexNamePrefix . $indexName);
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function getClient()
71
    {
72
        return $this->getActiveProvider()->getClient();
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78 View Code Duplication
    public function createDocument($uid, $document, $indexName = '', $indexType = '')
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...
79
    {
80
        $indexName = strtolower($indexName);
81
82
        return $this->getActiveProvider()->createDocument(
83
            $uid,
84
            $document,
85
            $this->indexNamePrefix . $indexName,
86
            $indexType
87
        );
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93 View Code Duplication
    public function addDocument($uid, $document, $indexType, $indexName)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
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...
94
    {
95
        $indexName = strtolower($indexName);
96
97
        return $this->getActiveProvider()->addDocument(
98
            $this->indexNamePrefix . $indexName,
99
            $indexType,
0 ignored issues
show
$indexType is of type array, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
100
            $document,
0 ignored issues
show
$document is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
101
            $uid
102
        );
103
    }
104
105
    /**
106
     * {@inheritdoc}
107
     */
108
    public function addDocuments($documents, $indexName = '', $indexType = '')
109
    {
110
        $indexName = strtolower($indexName);
111
112
        return $this->getActiveProvider()->addDocuments($documents, $indexName, $indexType);
113
    }
114
115
    /**
116
     * {@inheritdoc}
117
     */
118
    public function deleteDocument($indexName, $indexType, $uid)
119
    {
120
        $indexName = strtolower($indexName);
121
122
        return $this->getActiveProvider()->deleteDocument($this->indexNamePrefix . $indexName, $indexType, $uid);
123
    }
124
125
    /**
126
     * {@inheritdoc}
127
     */
128
    public function deleteDocuments($indexName, $indexType, array $ids)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
129
    {
130
        $indexName = strtolower($indexName);
131
132
        return $this->getActiveProvider()->deleteDocuments($this->indexNamePrefix . $indexName, $indexType, $ids);
133
    }
134
135
    /**
136
     * {@inheritdoc}
137
     */
138
    public function deleteIndex($indexName)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
139
    {
140
        $indexName = strtolower($indexName);
141
142
        return $this->getActiveProvider()->deleteIndex($this->indexNamePrefix . $indexName);
143
    }
144
145
    /**
146
     * {@inheritdoc}
147
     */
148
    public function getName()
149
    {
150
        return 'Search';
151
    }
152
153
    /**
154
     * Get the prefix for the index' name
155
     *
156
     * @return string
157
     */
158
    public function getIndexNamePrefix()
159
    {
160
        return $this->indexNamePrefix;
161
    }
162
}
163