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 Illuminate\Support\Arr; |
||
| 6 | use Illuminate\Support\ServiceProvider; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Class ShodanServiceProvider. |
||
| 10 | * |
||
| 11 | * @category PHP |
||
|
0 ignored issues
–
show
|
|||
| 12 | * |
||
| 13 | * @author Rob Attfield <[email protected]> |
||
|
0 ignored issues
–
show
|
|||
| 14 | * @license https://github.com/rattfieldnz/shodan/blob/master/LICENSE MIT |
||
|
0 ignored issues
–
show
|
|||
| 15 | */ |
||
|
0 ignored issues
–
show
|
|||
| 16 | class ShodanServiceProvider extends ServiceProvider |
||
| 17 | { |
||
|
0 ignored issues
–
show
|
|||
| 18 | const CONFIG_PATH = __DIR__.'/../config/shodan.php'; |
||
|
0 ignored issues
–
show
|
|||
| 19 | |||
| 20 | 18 | public function boot() |
|
|
0 ignored issues
–
show
|
|||
| 21 | { |
||
|
0 ignored issues
–
show
|
|||
| 22 | 18 | $this->publishes( |
|
| 23 | [ |
||
|
0 ignored issues
–
show
|
|||
| 24 | 18 | self::CONFIG_PATH => config_path('shodan.php'), |
|
|
0 ignored issues
–
show
|
|||
| 25 | 18 | ], 'config' |
|
| 26 | ); |
||
| 27 | 18 | } |
|
|
0 ignored issues
–
show
|
|||
| 28 | |||
| 29 | 18 | public function register() |
|
|
0 ignored issues
–
show
|
|||
| 30 | { |
||
|
0 ignored issues
–
show
|
|||
| 31 | 18 | $this->mergeConfigFrom( |
|
| 32 | 18 | self::CONFIG_PATH, |
|
| 33 | 18 | 'shodan' |
|
| 34 | ); |
||
| 35 | |||
| 36 | 18 | $this->app->alias(Shodan::class, 'shodan'); |
|
| 37 | |||
| 38 | 18 | $this->app->bind( |
|
| 39 | 'shodan', function () { |
||
| 40 | return new Shodan(); |
||
| 41 | 18 | } |
|
| 42 | ); |
||
| 43 | 18 | } |
|
|
0 ignored issues
–
show
|
|||
| 44 | |||
| 45 | /** |
||
| 46 | * Get the services provided by the provider. |
||
| 47 | * |
||
| 48 | * @return array |
||
| 49 | */ |
||
| 50 | 1 | public function provides() |
|
| 51 | { |
||
|
0 ignored issues
–
show
|
|||
| 52 | 1 | return ['shodan']; |
|
|
0 ignored issues
–
show
|
|||
| 53 | } |
||
|
0 ignored issues
–
show
|
|||
| 54 | |||
| 55 | /** |
||
| 56 | * Console-specific booting. |
||
| 57 | * |
||
| 58 | * @return void |
||
| 59 | */ |
||
| 60 | 1 | public function bootForConsole() |
|
| 61 | { |
||
|
0 ignored issues
–
show
|
|||
| 62 | // Publishing the configuration file. |
||
| 63 | 1 | $this->publishes( |
|
| 64 | [ |
||
|
0 ignored issues
–
show
|
|||
| 65 | 1 | __DIR__.'/../config/shodan.php' => config_path('shodan.php'), |
|
|
0 ignored issues
–
show
|
|||
| 66 | 1 | ], 'shodan' |
|
| 67 | ); |
||
| 68 | |||
| 69 | // Registering package commands. |
||
| 70 | 1 | $this->commands(['shodan']); |
|
|
0 ignored issues
–
show
|
|||
| 71 | 1 | } |
|
|
0 ignored issues
–
show
|
|||
| 72 | |||
| 73 | /** |
||
| 74 | * Merge the given configuration with the existing configuration. |
||
| 75 | * |
||
| 76 | * @param string $path |
||
|
0 ignored issues
–
show
|
|||
| 77 | * @param string $key |
||
|
0 ignored issues
–
show
|
|||
| 78 | * |
||
| 79 | * @return void |
||
| 80 | */ |
||
| 81 | 18 | protected function mergeConfigFrom($path, $key) |
|
|
0 ignored issues
–
show
|
|||
| 82 | { |
||
|
0 ignored issues
–
show
|
|||
| 83 | 18 | $config = $this->app['config']->get($key, []); |
|
|
0 ignored issues
–
show
|
|||
| 84 | 18 | $this->app['config']->set($key, $this->mergeConfig($config, include $path)); |
|
| 85 | 18 | } |
|
|
0 ignored issues
–
show
|
|||
| 86 | |||
| 87 | /** |
||
| 88 | * Merges the configs together and takes multi-dimensional arrays into account. |
||
| 89 | * |
||
| 90 | * @param array $original |
||
|
0 ignored issues
–
show
|
|||
| 91 | * @param array $merging |
||
|
0 ignored issues
–
show
|
|||
| 92 | * |
||
| 93 | * @return array |
||
| 94 | */ |
||
| 95 | 18 | protected function mergeConfig(array $original, array $merging) |
|
| 96 | { |
||
|
0 ignored issues
–
show
|
|||
| 97 | 18 | $array = array_merge($original, $merging); |
|
| 98 | 18 | foreach ($original as $key => $value) { |
|
| 99 | 1 | if (!is_array($value)) { |
|
|
0 ignored issues
–
show
|
|||
| 100 | 1 | continue; |
|
| 101 | } |
||
|
0 ignored issues
–
show
|
|||
| 102 | 1 | if (!Arr::exists($merging, $key)) { |
|
|
0 ignored issues
–
show
|
|||
| 103 | continue; |
||
| 104 | } |
||
|
0 ignored issues
–
show
|
|||
| 105 | 1 | if (is_numeric($key)) { |
|
| 106 | continue; |
||
| 107 | } |
||
|
0 ignored issues
–
show
|
|||
| 108 | 1 | $array[$key] = $this->mergeConfig($value, $merging[$key]); |
|
| 109 | } |
||
| 110 | |||
| 111 | 18 | return $array; |
|
| 112 | } |
||
|
0 ignored issues
–
show
|
|||
| 113 | } |
||
|
0 ignored issues
–
show
|
|||
| 114 |