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.
1 | <?php |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | |||
0 ignored issues
–
show
|
|||
3 | namespace RattfieldNz\Shodan\Libraries\Data; |
||
4 | |||
5 | use RattfieldNz\Shodan\Libraries\Config\Config; |
||
6 | |||
7 | /** |
||
8 | * Class Data. |
||
9 | * |
||
10 | * @category PHP |
||
0 ignored issues
–
show
|
|||
11 | * |
||
12 | * @author Rob Attfield <[email protected]> |
||
0 ignored issues
–
show
|
|||
13 | * @license https://github.com/rattfieldnz/shodan/blob/master/LICENSE MIT |
||
0 ignored issues
–
show
|
|||
14 | */ |
||
0 ignored issues
–
show
|
|||
15 | class Data |
||
16 | { |
||
0 ignored issues
–
show
|
|||
17 | private $_ip; |
||
0 ignored issues
–
show
|
|||
18 | private $_url; |
||
0 ignored issues
–
show
|
|||
19 | |||
20 | 11 | public function __construct(string $url) |
|
0 ignored issues
–
show
|
|||
21 | { |
||
0 ignored issues
–
show
|
|||
22 | 11 | $this->_url = $url; |
|
23 | 11 | $this->_ip = $this->getIp($this->_url); |
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
24 | 11 | } |
|
0 ignored issues
–
show
|
|||
25 | |||
26 | /** |
||
27 | * Get Shodan API URL with key. |
||
28 | * |
||
29 | * @return string |
||
30 | */ |
||
31 | 4 | public function shodanApiUrl() |
|
32 | { |
||
0 ignored issues
–
show
|
|||
33 | 4 | return 'https://api.shodan.io/shodan/host/'.$this->_ip.'?key='. |
|
0 ignored issues
–
show
|
|||
34 | 4 | Config::shodanApiKey(); |
|
35 | } |
||
0 ignored issues
–
show
|
|||
36 | |||
37 | /** |
||
38 | * Get IPv4 address from a URL. |
||
39 | * |
||
40 | * @param string $url |
||
0 ignored issues
–
show
|
|||
41 | * |
||
42 | * @return string|null |
||
43 | */ |
||
44 | 11 | public function getIp(string $url) |
|
45 | { |
||
0 ignored issues
–
show
|
|||
46 | 11 | $domain = parse_url($url); |
|
47 | 11 | if (empty($domain['host'])) { |
|
48 | 1 | return; |
|
0 ignored issues
–
show
|
|||
49 | } |
||
50 | |||
51 | 11 | $ip = gethostbyname($domain['host']); |
|
52 | |||
53 | 11 | return filter_var($ip, FILTER_VALIDATE_IP) ? $ip : null; |
|
0 ignored issues
–
show
|
|||
54 | } |
||
0 ignored issues
–
show
|
|||
55 | |||
56 | /** |
||
57 | * Returns URL set when initialising Data object. |
||
58 | * |
||
59 | * @return string |
||
60 | */ |
||
61 | 3 | public function getUrl() |
|
62 | { |
||
0 ignored issues
–
show
|
|||
63 | 3 | return $this->_url; |
|
64 | } |
||
0 ignored issues
–
show
|
|||
65 | } |
||
0 ignored issues
–
show
|
|||
66 |