This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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
|
|||
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 |
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 methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.