GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (11)

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.

tests/Query/Algolia/SearchQueryTest.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
namespace Spatie\SearchIndex\Test\Query\Algolia;
4
5
use DateTime;
6
use PHPUnit\Framework\TestCase;
7
use Spatie\SearchIndex\Query\Algolia\SearchQuery;
8
9
class SearchQueryTest extends TestCase
10
{
11
    /**
12
     * @var SearchQuery
13
     */
14
    protected $query;
15
16
    /**
17
     * @var array
18
     */
19
    protected $defaultResult;
20
21
    public function setUp()
22
    {
23
        $this->query = new SearchQuery();
24
        $this->defaultResult = [
25
            'numericFilters' => '',
26
            'facetFilters'   => '',
27
            'hitsPerPage'    => 10000,
28
            'page'           => 0,
29
        ];
30
    }
31
32
    /**
33
     * @test
34
     */
35
    public function it_can_handle_an_empty_query()
36
    {
37
        $this->assertEquals($this->defaultResult, $this->query->toArray());
38
    }
39
40
    /**
41
     * @test
42
     */
43
    public function it_can_handle_a_query_string()
44
    {
45
        $this->query
46
            ->searchFor('hello');
47
48
        $this->assertEquals($this->expectedResult(['query' => 'hello']), $this->query->toArray());
49
    }
50
51
    /**
52
     * @test
53
     */
54
    public function it_can_handle_a_location_aware_query()
55
    {
56
        $lat = 1.234567890;
57
        $lng = 7.891012345;
58
59
        $this->query->aroundLocation($lat, $lng);
60
61
        $this->assertEquals($this->expectedResult(
62
            [
63
                'aroundLatLng' => $lat.','.$lng,
64
                'aroundRadius' => 30000,
65
            ]
66
        ), $this->query->toArray());
67
    }
68
69
    /**
70
     * @test
71
     */
72
    public function it_can_handle_a_location_aware_query_around_a_radius()
73
    {
74
        $lat = 1.234567890;
75
        $lng = 7.891012345;
76
        $radius = 12345;
77
78
        $this->query->aroundLocation($lat, $lng, $radius);
79
80
        $this->assertEquals($this->expectedResult(
81
            [
82
                'aroundLatLng' => $lat.','.$lng,
83
                'aroundRadius' => $radius,
84
            ]
85
        ), $this->query->toArray());
86
    }
87
88
    /**
89
     * @test
90
     */
91
    public function it_can_handle_date_restrictions()
92
    {
93
        $dateFieldName = 'myDate';
94
        $operation = '>';
95
        $date = new DateTime();
96
97
        $this->query->withDateRestriction($dateFieldName, $operation, $date);
98
99
        $this->assertEquals($this->expectedResult(
100
            [
101
                'numericFilters' => ",{$dateFieldName}{$operation}{$date->getTimestamp()}",
102
            ]
103
        ), $this->query->toArray());
104
    }
105
106
    /**
107
     * @test
108
     */
109
    public function it_can_handle_multiple_date_restrictions()
110
    {
111
        $dateFieldName = 'myDate';
112
        $operation = '>';
113
        $date = new DateTime();
114
115
        $otherDateFieldName = 'otherDate';
116
        $otherOperation = '<';
117
        $otherDate = new DateTime();
118
119
        $this->query->withDateRestriction($dateFieldName, $operation, $date);
120
        $this->query->withDateRestriction($otherDateFieldName, $otherOperation, $otherDate);
121
122
        $this->assertEquals($this->expectedResult(
123
            [
124
                'numericFilters' => ",{$dateFieldName}{$operation}{$date->getTimestamp()},{$otherDateFieldName}{$otherOperation}{$otherDate->getTimestamp()}",
125
            ]
126
        ), $this->query->toArray());
127
    }
128
129
    /**
130
     * @test
131
     */
132 View Code Duplication
    public function it_can_handle_numeric_filters()
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...
133
    {
134
        $name = 'myFilter';
135
        $myValues = [1, 2, 3];
136
        $logicalOperator = SearchQuery::LOGICAL_OPERATOR_OR;
137
138
        $this->query->withNumericFilter($name, $myValues, $logicalOperator);
139
140
        $this->assertEquals($this->expectedResult(
141
            [
142
                'numericFilters' => ",({$name}={$myValues[0]},{$name}={$myValues[1]},{$name}={$myValues[2]})",
143
            ]
144
        ), $this->query->toArray());
145
    }
146
147
    /**
148
     * @test
149
     */
150 View Code Duplication
    public function it_can_handle_numeric_filters_with_an_and_relation()
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...
151
    {
152
        $name = 'myFilter';
153
        $myValues = [1, 2, 3];
154
        $logicalOperator = SearchQuery::LOGICAL_OPERATOR_AND;
155
156
        $this->query->withNumericFilter($name, $myValues, $logicalOperator);
157
158
        $this->assertEquals($this->expectedResult(
159
            [
160
                'numericFilters' => ",{$name}={$myValues[0]},{$name}={$myValues[1]},{$name}={$myValues[2]}",
161
            ]
162
        ), $this->query->toArray());
163
    }
164
165
    /**
166
     * @test
167
     */
168
    public function it_can_handle_a_search_facet()
169
    {
170
        $names = ['facet1', 'facet2'];
171
        $values = ['value1', 'value2'];
172
173
        $this->query->withFacet($names[0], $values[0]);
174
        $this->query->withFacet($names[1], $values[1]);
175
176
        $this->assertEquals($this->expectedResult(
177
            [
178
                'facetFilters' => ",{$names[0]}:{$values[0]},{$names[1]}:{$values[1]}",
179
            ]
180
        ), $this->query->toArray());
181
    }
182
183
    /**
184
     * @test
185
     */
186
    public function it_allows_hits_per_page_to_be_set()
187
    {
188
        $hitsPerPage = 12345;
189
190
        $this->query->setHitsPerPage($hitsPerPage);
191
192
        $this->assertEquals($this->expectedResult(['hitsPerPage' => $hitsPerPage]), $this->query->toArray());
193
    }
194
195
    /**
196
     * @test
197
     */
198
    public function it_allows_hits_page_to_be_set()
199
    {
200
        $hitsPerPage = 8;
201
        $page = 2;
202
203
        $this->query->setHitsPerPage($hitsPerPage);
204
        $this->query->setPage($page);
205
206
        $this->assertEquals($this->expectedResult(['hitsPerPage' => $hitsPerPage, 'page' => $page]), $this->query->toArray());
207
    }
208
209
    /**
210
     * @test
211
     */
212
    public function it_allows_method_chaining_for_multiple_filters()
213
    {
214
        $facetFilter = ['name', 'value'];
215
216
        $numericFilterName = 'myFilter';
217
        $numericFilterValues = [1, 2, 3];
218
        $logicalOperator = SearchQuery::LOGICAL_OPERATOR_OR;
219
220
        $dateFieldName = 'myDate';
221
        $operation = '>';
222
        $date = new DateTime();
223
224
        $this->query->withFacet('name', 'value')
225
                    ->withDateRestriction($dateFieldName, $operation, $date)
226
                    ->withNumericFilter($numericFilterName, $numericFilterValues, $logicalOperator);
227
228
        $this->assertEquals($this->expectedResult(
229
            [
230
                'facetFilters'   => ",{$facetFilter[0]}:{$facetFilter[1]}",
231
                'numericFilters' => ",{$dateFieldName}{$operation}{$date->getTimestamp()},({$numericFilterName}={$numericFilterValues[0]},{$numericFilterName}={$numericFilterValues[1]},{$numericFilterName}={$numericFilterValues[2]})",
232
            ]
233
        ), $this->query->toArray());
234
    }
235
236
    protected function expectedResult(array $expectedResult)
237
    {
238
        return array_merge($this->defaultResult, $expectedResult);
239
    }
240
}
241