Issues (46)

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/PSolr/Request/Select.php (4 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 PSolr\Request;
4
5
/**
6
 * @see http://wiki.apache.org/solr/CommonQueryParameters
7
 * @see http://wiki.apache.org/solr/ExtendedDisMax
8
 *
9
 * @method \PSolr\Response\SearchResults sendRequest(\PSolr\Request\SolrClient $solr, $headers = null, array $options = array())
10
 */
11
class Select extends SolrRequest
12
{
13
    const OPERATOR_AND = 'AND';
14
    const OPERATOR_OR  = 'OR';
15
16
    const DEFTYPE_EDISMAX = 'edismax';
17
18
    /**
19
     * @var string
20
     */
21
    protected $handlerName = 'select';
22
23
    /**
24
     * $var string
25
     */
26
    protected $responseClass = '\PSolr\Response\SearchResults';
27
28
    /**
29
     * Helper function that turns associative arrays into boosted fields.
30
     *
31
     * - array('field' => 10.0) = "field^10.0".
32
     * - array('field' => array(2, 10.0) = "field~2^10.0"
33
     *
34
     * @param string|array $fields
35
     *
36
     * @see https://wiki.apache.org/solr/DisMaxQParserPlugin#qf_.28Query_Fields.29
37
     *
38
     * @todo Rethink this.
39
     */
40
    public function buildBoostedFields($fields)
41
    {
42
        // Assume strings are pre-formatted.
43
        if (is_string($fields)) {
44
            return $fields;
45
        }
46
47
        $processed = array();
48
        foreach ($fields as $fieldName => $boost) {
49
            if (!is_array($boost)) {
50
                $processed[] = $fieldName . '^' . $boost;
51
            } else {
52
                $field = $fieldName . '~' . $boost[0];
53
                if (isset($boost[1])) {
54
                    $field .= '^' . $boost[1];
55
                }
56
                $processed[] = $field;
57
            }
58
        }
59
        return join(',', $processed);
60
    }
61
62
    /**
63
     * @param string $query
64
     *
65
     * @return \PSolr\Request\Select
66
     *
67
     * @see http://wiki.apache.org/solr/CommonQueryParameters#q
68
     */
69
    public function setQuery($query)
70
    {
71
        return $this->set('q', $query);
72
    }
73
74
    /**
75
     * @param string $sort
76
     *
77
     * @return \PSolr\Request\Select
78
     *
79
     * @todo Component\Sort.php
80
     *
81
     * @see http://wiki.apache.org/solr/CommonQueryParameters#sort
82
     */
83
    public function setSort($sort)
84
    {
85
        return $this->set('sort', $sort);
86
    }
87
88
    /**
89
     * @param int $rows
0 ignored issues
show
There is no parameter named $rows. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
90
     *
91
     * @return \PSolr\Request\Select
92
     *
93
     * @see http://wiki.apache.org/solr/CommonQueryParameters#start
94
     */
95
    public function setStart($start)
96
    {
97
        return $this->set('start', $start);
98
    }
99
100
    /**
101
     * @param int $rows
102
     *
103
     * @return \PSolr\Request\Select
104
     *
105
     * @see http://wiki.apache.org/solr/CommonQueryParameters#rows
106
     */
107
    public function setRows($rows)
108
    {
109
        return $this->set('rows', $rows);
110
    }
111
112
    /**
113
     * @param int $pageDoc
114
     *
115
     * @return \PSolr\Request\Select
116
     *
117
     * @see http://wiki.apache.org/solr/CommonQueryParameters#pageDoc_and_pageScore
118
     */
119
    public function setPageDoc($pageDoc)
120
    {
121
        return $this->set('pageDoc', $pageDoc);
122
    }
123
124
    /**
125
     * @param float $pageScore
126
     *
127
     * @return \PSolr\Request\Select
128
     *
129
     * @see http://wiki.apache.org/solr/CommonQueryParameters#pageDoc_and_pageScore
130
     */
131
    public function setPageScore($pageScore)
132
    {
133
        return $this->set('pageScore', $pageScore);
134
    }
135
136
    /**
137
     * @param string $fq
0 ignored issues
show
There is no parameter named $fq. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
138
     *
139
     * @return \PSolr\Request\Select
140
     *
141
     * @see http://wiki.apache.org/solr/CommonQueryParameters#fq
142
     */
143
    public function addFilterQuery($filterQuery)
144
    {
145
        return $this->add('fq', $filterQuery);
146
    }
147
148
    /**
149
     * @param string|array $fieldList
150
     *
151
     * @return \PSolr\Request\Select
152
     *
153
     * @see http://wiki.apache.org/solr/CommonQueryParameters#fl
154
     */
155
    public function setFieldList($fieldList)
156
    {
157
        return $this->set('fl', join(',', (array) $fieldList));
158
    }
159
160
    /**
161
     * @param string $defType
162
     *
163
     * @return \PSolr\Request\Select
164
     *
165
     * @see http://wiki.apache.org/solr/CommonQueryParameters#defType
166
     */
167
    public function setDefType($defType)
168
    {
169
        return $this->set('defType', $defType);
170
    }
171
172
    /**
173
     * @param int $timeAllowed
174
     *
175
     * @return \PSolr\Request\Select
176
     *
177
     * @see http://wiki.apache.org/solr/CommonQueryParameters#timeAllowed
178
     */
179
    public function setTimeAllowed($timeAllowed)
180
    {
181
        return $this->set('timeAllowed', $timeAllowed);
182
    }
183
184
    /**
185
     * @param boolean $omitHeader
186
     *
187
     * @return \PSolr\Request\Select
188
     *
189
     * @see http://wiki.apache.org/solr/CommonQueryParameters#omitHeader
190
     */
191
    public function omitHeader($omitHeader)
192
    {
193
        return $this->set('omitHeader', $omitHeader);
194
    }
195
196
    /**
197
     * @param string $operator
198
     *
199
     * @return \PSolr\Request\Select
200
     *
201
     * @see http://wiki.apache.org/solr/SearchHandler#q.op
202
     */
203
    public function setDefaultOperator($operator)
204
    {
205
        return $this->set('q.op', $operator);
206
    }
207
208
    /**
209
     * @param string $field
210
     *
211
     * @return \PSolr\Request\Select
212
     *
213
     * @see http://wiki.apache.org/solr/SearchHandler#df
214
     */
215
    public function setDefaultField($field)
216
    {
217
        return $this->set('df', $field);
218
    }
219
220
    /**
221
     * @param string $query
222
     *
223
     * @return \PSolr\Request\Select
224
     *
225
     * @see http://wiki.apache.org/solr/ExtendedDisMax#q.alt
226
     */
227
    public function setAlternateQuery($query)
228
    {
229
        return $this->set('q.alt', $query);
230
    }
231
232
    /**
233
     * @param string|array $fields
234
     *   An associative array of fields to boosts, e.g. array('field' => 2.0);
235
     *
236
     * @return \PSolr\Request\Select
237
     *
238
     * @see http://wiki.apache.org/solr/ExtendedDisMax#qf_.28Query_Fields.29
239
     */
240
    public function setQueryFields($fields)
241
    {
242
        return $this->set('qf', $this->buildBoostedFields($fields));
243
    }
244
245
    /**
246
     * @param string $mm
247
     *
248
     * @return \PSolr\Request\Select
249
     *
250
     * @see http://wiki.apache.org/solr/ExtendedDisMax#mm_.28Minimum_.27Should.27_Match.29
251
     */
252
    public function setMinimumShouldMatch($mm)
253
    {
254
        return $this->set('mm', $mm);
255
    }
256
257
    /**
258
     * @param string $slop
259
     *
260
     * @return \PSolr\Request\Select
261
     *
262
     * @see http://wiki.apache.org/solr/ExtendedDisMax#qs_.28Query_Phrase_Slop.29
263
     */
264
    public function setQueryPhraseSlop($slop)
265
    {
266
        return $this->set('qs', $slop);
267
    }
268
269
    /**
270
     * @param string|array $fields
271
     *   An associative array of fields to boosts, e.g. array('field' => 2.0).
272
     *   Pass an array of values to add slop, e.g. array('field', array(2, 10.0)
273
     *   will render "field~2^10".
274
     *
275
     * @return \PSolr\Request\Select
276
     *
277
     * @see http://wiki.apache.org/solr/ExtendedDisMax#pf_.28Phrase_Fields.29
278
     */
279
    public function setPhraseFields($fields)
280
    {
281
        return $this->set('pf', $this->buildBoostedFields($fields));
282
    }
283
284
    /**
285
     * @param float $slop
286
     *
287
     * @return \PSolr\Request\Select
288
     *
289
     * @see http://wiki.apache.org/solr/ExtendedDisMax#ps_.28Phrase_Slop.29
290
     */
291
    public function setPhraseSlop($slop)
292
    {
293
        return $this->set('ps', $slop);
294
    }
295
296
    /**
297
     * @param string|array $fields
298
     *   An associative array of fields to boosts, e.g. array('field' => 2.0).
299
     *   Pass an array of values to add slop, e.g. array('field', array(2, 10.0)
300
     *   will render "field~2^10".
301
     *
302
     * @return \PSolr\Request\Select
303
     *
304
     * @see http://wiki.apache.org/solr/ExtendedDisMax#pf2_.28Phrase_bigram_fields.29
305
     */
306
    public function setPhraseBigramFields($fields)
307
    {
308
        return $this->set('pf2', $this->buildBoostedFields($fields));
309
    }
310
311
    /**
312
     * @param float $slop
313
     *
314
     * @return \PSolr\Request\Select
315
     *
316
     * @see http://wiki.apache.org/solr/ExtendedDisMax#ps2_.28Phrase_bigram_slop.29
317
     */
318
    public function setPhraseBigramSlop($slop)
319
    {
320
        return $this->set('ps2', $slop);
321
    }
322
323
    /**
324
     * @param string|array $fields
325
     *   An associative array of fields to boosts, e.g. array('field' => 2.0).
326
     *   Pass an array of values to add slop, e.g. array('field', array(2, 10.0)
327
     *   will render "field~2^10".
328
     *
329
     * @return \PSolr\Request\Select
330
     *
331
     * @see http://wiki.apache.org/solr/ExtendedDisMax#pf3_.28Phrase_trigram_fields.29
332
     */
333
    public function setPhraseTrigramFields($fields)
334
    {
335
        return $this->set('pf3', $this->buildBoostedFields($fields));
336
    }
337
338
    /**
339
     * @param float $slop
340
     *
341
     * @return \PSolr\Request\Select
342
     *
343
     * @see http://wiki.apache.org/solr/ExtendedDisMax#ps3_.28Phrase_trigram_slop.29
344
     */
345
    public function setPhraseTrigramSlop($slop)
346
    {
347
        return $this->set('ps3', $slop);
348
    }
349
350
    /**
351
     * @param float $tieBreaker
352
     *
353
     * @return \PSolr\Request\Select
354
     *
355
     * @see http://wiki.apache.org/solr/ExtendedDisMax#tie_.28Tie_breaker.29
356
     */
357
    public function setTieBreaker($tieBreaker)
358
    {
359
        return $this->set('tie', $tieBreaker);
360
    }
361
362
    /**
363
     * @param string $query
364
     *
365
     * @return \PSolr\Request\Select
366
     *
367
     * @see http://wiki.apache.org/solr/ExtendedDisMax#bq_.28Boost_Query.29
368
     */
369
    public function setBoostQuery($query)
0 ignored issues
show
The parameter $query is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
370
    {
371
        return $this->set('bq', $tieBreaker);
0 ignored issues
show
The variable $tieBreaker does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
372
    }
373
374
    /**
375
     * @param string $function
376
     * @param bool $multiplicative
377
     *   Defaults to false (additive), pass true for multiplicitive.
378
     *
379
     * @return \PSolr\Request\Select
380
     *
381
     * @see http://wiki.apache.org/solr/ExtendedDisMax#bf_.28Boost_Function.2C_additive.29
382
     * @see http://wiki.apache.org/solr/ExtendedDisMax#boost_.28Boost_Function.2C_multiplicative.29
383
     * @see http://wiki.apache.org/solr/FunctionQuery
384
     */
385
    public function addBoostFunction($function, $multiplicative = false)
386
    {
387
        $param = $multiplicative ? 'boost' : 'bf';
388
        return $this->add($param, $function);
389
    }
390
391
    /**
392
     * @param string|array $fields
393
     *
394
     * @return \PSolr\Request\Select
395
     *
396
     * @see http://wiki.apache.org/solr/ExtendedDisMax#uf_.28User_Fields.29
397
     */
398
    public function setUserFields($fields)
399
    {
400
        return $this->set('uf', join(' ', (array) $fields));
401
    }
402
403
    /**
404
     * @param bool $interpret
405
     *
406
     * @return \Psolr\Component\Facet
407
     *
408
     * @see http://wiki.apache.org/solr/ExtendedDisMax#lowercaseOperators
409
     */
410
    public function interpretLowercaseOperators($interpret = true)
411
    {
412
        return $this->set('lowercaseOperators', (bool) $interpret);
413
    }
414
}
415