Issues (1)

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/NpmSearch.php (1 issue)

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 Kapersoft\NpmSearch;
4
5
use GuzzleHttp\Client;
6
7
class NpmSearch
8
{
9
10
    /** @var Client */
11
    public $guzzleClient;
12
13
    /** @var string */
14
    public $baseUrl;
15
16
    /**
17
     * @param Client $client
0 ignored issues
show
There is no parameter named $client. Did you maybe mean $guzzleClient?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

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

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

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

Loading history...
18
     * @param string $baseUrl
19
     */
20
    public function __construct($baseUrl = 'https://npmsearch.com/query', Client $guzzleClient = null)
21
    {
22
        if ($guzzleClient === null) {
23
            $guzzleClient = new Client();
24
        }
25
        $this->guzzleClient = $guzzleClient;
26
        $this->baseUrl = $baseUrl;
27
    }
28
    
29
    /**
30
     * Search package using a query
31
     *
32
     * @param string  $query Search query
33
     * @param integer $start Start from
34
     * @param integer $rows  Number of rows
35
     * @return array
36
     */
37
    public function search(string $query, int $start = 0, int $rows = 10):array
38
    {
39
        return $this->makeRequest([
40
            'q'     => $query,
41
            'start' => $start,
42
            'rows'  => $rows
43
        
44
        ]);
45
    }
46
47
    /**
48
     * Search package using author
49
     *
50
     * @param string  $author Author
51
     * @param integer $start  Start form
52
     * @param integer $rows   Number of rows
53
     * @return array
54
     */
55
    public function searchUsingAuthor(string $author, int $start = 0, int $rows = 10):array
56
    {
57
        return $this->makeRequest([
58
            'q'     => 'author:' . $author,
59
            'start' => $start,
60
            'rows'  => $rows
61
        
62
        ]);
63
    }
64
    
65
    /**
66
     * Search package using create data
67
     *
68
     * @param string  $created Created date
69
     * @param integer $start   Start form
70
     * @param integer $rows    Number of rows
71
     * @return array
72
     */
73
    public function searchUsingCreated(string $created, int $start = 0, int $rows = 10):array
74
    {
75
        return $this->makeRequest([
76
            'q'     => 'created:' . $created,
77
            'start' => $start,
78
            'rows'  => $rows
79
        
80
        ]);
81
    }
82
    
83
    /**
84
     * Search package using dependencies
85
     *
86
     * @param string  $dependencies  Dependencies
87
     * @param integer $start         Start form
88
     * @param integer $rows          Number of rows
89
     * @return array
90
     */
91
    public function searchUsingDependencies(string $dependencies, int $start = 0, int $rows = 10):array
92
    {
93
        return $this->makeRequest([
94
            'q'     => 'dependencies:' . $dependencies,
95
            'start' => $start,
96
            'rows'  => $rows
97
        ]);
98
    }
99
100
    /**
101
     * Search package using description
102
     *
103
     * @param string  $description Description
104
     * @param integer $start       Start form
105
     * @param integer $rows        Number of rows
106
     * @return array
107
     */
108
    public function searchUsingDescription(string $description, int $start = 0, int $rows = 10):array
109
    {
110
        return $this->makeRequest([
111
            'q'     => 'description:' . $description,
112
            'start' => $start,
113
            'rows'  => $rows
114
        ]);
115
    }
116
117
    /**
118
     * Search package using devDependencies
119
     *
120
     * @param string  $devDependencies DevDependencies
121
     * @param integer $start           Start form
122
     * @param integer $rows            Number of rows
123
     * @return array
124
     */
125
    public function searchUsingDevDependencies(string $devDependencies, int $start = 0, int $rows = 10):array
126
    {
127
        return $this->makeRequest([
128
            'q'     => 'devDependencies:' . $devDependencies,
129
            'start' => $start,
130
            'rows'  => $rows
131
        ]);
132
    }
133
134
    /**
135
     * Search package using homepage
136
     *
137
     * @param string  $homepage Homepage
138
     * @param integer $start    Start form
139
     * @param integer $rows     Number of rows
140
     * @return array
141
     */
142
    public function searchUsingHomepage(string $homepage, int $start = 0, int $rows = 10):array
143
    {
144
        return $this->makeRequest([
145
            'q'     => 'homepage:' . $homepage,
146
            'start' => $start,
147
            'rows'  => $rows
148
        ]);
149
    }
150
151
    /**
152
     * Search package using keywords
153
     *
154
     * @param string  $keywords Keywords
155
     * @param integer $start    Start form
156
     * @param integer $rows     Number of rows
157
     * @return array
158
     */
159
    public function searchUsingKeywords(string $keywords, int $start = 0, int $rows = 10):array
160
    {
161
        return $this->makeRequest([
162
            'q'     => 'keywords:' . $keywords,
163
            'start' => $start,
164
            'rows'  => $rows
165
        ]);
166
    }
167
168
    /**
169
     * Search package using maintainers
170
     *
171
     * @param string  $maintainers Maintainers
172
     * @param integer $start       Start form
173
     * @param integer $rows        Number of rows
174
     * @return array
175
     */
176
    public function searchUsingMaintainers(string $maintainers, int $start = 0, int $rows = 10):array
177
    {
178
        return $this->makeRequest([
179
            'q'     => 'maintainers:' . $maintainers,
180
            'start' => $start,
181
            'rows'  => $rows
182
        ]);
183
    }
184
185
    /**
186
     * Search package using modified date
187
     *
188
     * @param string  $modified Modified date
189
     * @param integer $start    Start form
190
     * @param integer $rows     Number of rows
191
     * @return array
192
     */
193
    public function searchUsingModified(string $modified, int $start = 0, int $rows = 10):array
194
    {
195
        return $this->makeRequest([
196
            'q'     => 'modified:' . $modified,
197
            'start' => $start,
198
            'rows'  => $rows
199
        ]);
200
    }
201
202
    /**
203
     * Search package using name
204
     *
205
     * @param string  $name  Name
206
     * @param integer $start Start form
207
     * @param integer $rows  Number of rows
208
     * @return array
209
     */
210
    public function searchUsingName(string $name, int $start = 0, int $rows = 10):array
211
    {
212
        return $this->makeRequest([
213
            'q'     => 'name:' . $name,
214
            'start' => $start,
215
            'rows'  => $rows
216
        ]);
217
    }
218
219
    /**
220
     * Search package using readme
221
     *
222
     * @param string  $readme Readme
223
     * @param integer $start  Start form
224
     * @param integer $rows   Number of rows
225
     * @return array
226
     */
227
    public function searchUsingReadme(string $readme, int $start = 0, int $rows = 10):array
228
    {
229
        return $this->makeRequest([
230
            'q'     => 'readme:' . $readme,
231
            'start' => $start,
232
            'rows'  => $rows
233
        ]);
234
    }
235
    
236
    /**
237
     * Search package using repository
238
     *
239
     * @param string  $repository Repository
240
     * @param integer $start      Start form
241
     * @param integer $rows       Number of rows
242
     * @return array
243
     */
244
    public function searchUsingRepository(string $repository, int $start = 0, int $rows = 10):array
245
    {
246
        return $this->makeRequest([
247
            'q'     => 'repository:' . $repository,
248
            'start' => $start,
249
            'rows'  => $rows
250
        ]);
251
    }
252
253
    /**
254
     * Search package using scripts
255
     *
256
     * @param string  $scripts Scripts
257
     * @param integer $start   Start form
258
     * @param integer $rows    Number of rows
259
     * @return array
260
     */
261
    public function searchUsingScripts(string $scripts, int $start = 0, int $rows = 10):array
262
    {
263
        return $this->makeRequest([
264
            'q'     => 'scripts:' . $scripts,
265
            'start' => $start,
266
            'rows'  => $rows
267
        ]);
268
    }
269
270
    /**
271
     * Search package using times
272
     *
273
     * @param string  $times Times
274
     * @param integer $start Start form
275
     * @param integer $rows  Number of rows
276
     * @return array
277
     */
278
    public function searchUsingTimes(string $times, int $start = 0, int $rows = 10):array
279
    {
280
        return $this->makeRequest([
281
            'q'     => 'times:' . $times,
282
            'start' => $start,
283
            'rows'  => $rows
284
        ]);
285
    }
286
287
    /**
288
     * Search package using version
289
     *
290
     * @param string  $version Version
291
     * @param integer $start   Start form
292
     * @param integer $rows    Number of rows
293
     * @return array
294
     */
295
    public function searchUsingVersion(string $version, int $start = 0, int $rows = 10):array
296
    {
297
        return $this->makeRequest([
298
            'q'     => 'version:' . $version,
299
            'start' => $start,
300
            'rows'  => $rows
301
        ]);
302
    }
303
304
    /**
305
     * Search package using rating
306
     *
307
     * @param string  $rating Rating
308
     * @param integer $start  Start form
309
     * @param integer $rows   Number of rows
310
     * @return array
311
     */
312
    public function searchUsingRating(string $rating, int $start = 0, int $rows = 10):array
313
    {
314
        return $this->makeRequest([
315
            'q'     => 'rating:' . $rating,
316
            'start' => $start,
317
            'rows'  => $rows
318
        ]);
319
    }
320
  
321
    /**
322
     * @param array $query
323
     *
324
     * @return array
325
     */
326
    private function makeRequest($query = []):array
327
    {
328
        $packages = $this->guzzleClient
329
            ->get("{$this->baseUrl}", compact('query'))
330
            ->getBody()
331
            ->getContents();
332
        return json_decode($packages, true);
333
    }
334
}
335