rattfieldnz /
shodan
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
Loading history...
|
|||
| 2 | |||
|
0 ignored issues
–
show
|
|||
| 3 | namespace RattfieldNz\Shodan; |
||
| 4 | |||
| 5 | use ErrorException; |
||
| 6 | use RattfieldNz\Shodan\Libraries\Curl\Curl; |
||
| 7 | use RattfieldNz\Shodan\Libraries\Data\Data; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Class Shodan. |
||
| 11 | * |
||
| 12 | * @category PHP |
||
|
0 ignored issues
–
show
|
|||
| 13 | * |
||
| 14 | * @author Rob Attfield <[email protected]> |
||
|
0 ignored issues
–
show
|
|||
| 15 | * @license https://github.com/rattfieldnz/shodan/blob/master/LICENSE MIT |
||
|
0 ignored issues
–
show
|
|||
| 16 | */ |
||
|
0 ignored issues
–
show
|
|||
| 17 | class Shodan |
||
| 18 | { |
||
|
0 ignored issues
–
show
|
|||
| 19 | private $_url; |
||
|
0 ignored issues
–
show
|
|||
| 20 | |||
| 21 | private $_results; |
||
|
0 ignored issues
–
show
|
|||
| 22 | |||
| 23 | private $_data; |
||
|
0 ignored issues
–
show
|
|||
| 24 | |||
| 25 | 6 | public function __construct() |
|
|
0 ignored issues
–
show
|
|||
| 26 | { |
||
|
0 ignored issues
–
show
|
|||
| 27 | 6 | $this->_results = null; |
|
|
0 ignored issues
–
show
|
|||
| 28 | 6 | } |
|
|
0 ignored issues
–
show
|
|||
| 29 | |||
| 30 | /** |
||
| 31 | * Add URL to be checked with Shodan API. |
||
| 32 | * |
||
| 33 | * @param string $url The URL to be checked. |
||
| 34 | * |
||
| 35 | * @return Shodan. |
||
|
0 ignored issues
–
show
|
|||
| 36 | */ |
||
| 37 | 4 | public function setUrl(string $url) |
|
| 38 | { |
||
|
0 ignored issues
–
show
|
|||
| 39 | 4 | $this->_url = $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. Loading history...
|
|||
| 40 | 4 | $this->_data = new Data($this->_url); |
|
| 41 | |||
| 42 | 4 | return $this; |
|
| 43 | } |
||
|
0 ignored issues
–
show
|
|||
| 44 | |||
| 45 | /** |
||
| 46 | * Checks a given URL with Shodan API. |
||
| 47 | * |
||
| 48 | * @throws ErrorException |
||
|
0 ignored issues
–
show
|
|||
| 49 | * |
||
| 50 | * @return Shodan |
||
| 51 | */ |
||
| 52 | 2 | public function check() |
|
| 53 | { |
||
|
0 ignored issues
–
show
|
|||
| 54 | $error = [ |
||
|
0 ignored issues
–
show
|
|||
| 55 | 2 | 'status' => 500, |
|
|
0 ignored issues
–
show
|
|||
| 56 | 'response' => 'URL cannot be null.', |
||
|
0 ignored issues
–
show
|
|||
| 57 | ]; |
||
|
0 ignored issues
–
show
|
|||
| 58 | |||
| 59 | 2 | $this->_results = empty($this->getUrl()) || empty($this->_data) ? |
|
|
0 ignored issues
–
show
|
|||
| 60 | 2 | $error : (new Curl($this->_data))->getData(); |
|
| 61 | |||
| 62 | 2 | return $this; |
|
| 63 | } |
||
|
0 ignored issues
–
show
|
|||
| 64 | |||
| 65 | /** |
||
| 66 | * Get current URL. |
||
| 67 | * |
||
| 68 | * @return string|null |
||
| 69 | */ |
||
| 70 | 4 | public function getUrl() |
|
| 71 | { |
||
|
0 ignored issues
–
show
|
|||
| 72 | 4 | return $this->_url; |
|
| 73 | } |
||
|
0 ignored issues
–
show
|
|||
| 74 | |||
| 75 | /** |
||
| 76 | * Get results of Shodan API call. |
||
| 77 | * |
||
| 78 | * @param bool $jsonEncode Encode results as JSON, or |
||
|
0 ignored issues
–
show
|
|||
| 79 | * return as associative array. |
||
| 80 | * |
||
| 81 | * @return mixed|null |
||
| 82 | */ |
||
| 83 | 3 | public function getResults(bool $jsonEncode = false) |
|
|
0 ignored issues
–
show
|
|||
| 84 | { |
||
|
0 ignored issues
–
show
|
|||
| 85 | 3 | if (empty($this->_results)) { |
|
| 86 | 1 | return; |
|
|
0 ignored issues
–
show
|
|||
| 87 | } |
||
| 88 | |||
| 89 | 2 | return $jsonEncode === false ? |
|
|
0 ignored issues
–
show
|
|||
| 90 | 2 | $this->_results : json_encode($this->_results); |
|
| 91 | } |
||
|
0 ignored issues
–
show
|
|||
| 92 | } |
||
|
0 ignored issues
–
show
|
|||
| 93 |