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 |
||||
2 | namespace TheCodingMachine\ServerMonitorPluginNotificationByHost\Test; |
||||
3 | |||||
4 | use Carbon\Carbon; |
||||
5 | use Illuminate\Support\Facades\Artisan; |
||||
6 | use Orchestra\Testbench\TestCase as Orchestra; |
||||
7 | use Spatie\ServerMonitor\Models\Host; |
||||
8 | use TheCodingMachine\ServerMonitorPluginNotificationByHost\ServerMonitorPluginNotificationByHostServiceProvider; |
||||
9 | |||||
10 | abstract class TestCase extends Orchestra { |
||||
11 | /** @var Server */ |
||||
0 ignored issues
–
show
|
|||||
12 | public $server; |
||||
13 | |||||
14 | /** @var ?string */ |
||||
0 ignored issues
–
show
|
|||||
15 | protected $consoleOutputCache; |
||||
16 | |||||
17 | public function setUp() |
||||
18 | { |
||||
19 | Carbon::setTestNow(Carbon::create(2016, 1, 1, 00, 00, 00)); |
||||
20 | |||||
21 | $this->consoleOutputCache = null; |
||||
22 | |||||
23 | parent::setUp(); |
||||
24 | |||||
25 | } |
||||
26 | |||||
27 | /** |
||||
28 | * @param \Illuminate\Foundation\Application $app |
||||
29 | * |
||||
30 | * @return array |
||||
31 | */ |
||||
32 | protected function getPackageProviders($app) |
||||
0 ignored issues
–
show
The parameter
$app is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
33 | { |
||||
34 | return [ |
||||
35 | ServerMonitorPluginNotificationByHostServiceProvider::class, |
||||
36 | ]; |
||||
37 | } |
||||
38 | |||||
39 | /** |
||||
40 | * @param \Illuminate\Foundation\Application $app |
||||
41 | */ |
||||
42 | protected function getEnvironmentSetUp($app) |
||||
43 | { |
||||
44 | $app['config']->set('database.default', 'sqlite'); |
||||
45 | |||||
46 | $app['config']->set('mail.driver', 'log'); |
||||
47 | |||||
48 | $app['config']->set('database.default', 'sqlite'); |
||||
49 | $app['config']->set('database.connections.sqlite', [ |
||||
50 | 'driver' => 'sqlite', |
||||
51 | 'prefix' => '', |
||||
52 | 'database' => ':memory:', |
||||
53 | ]); |
||||
54 | |||||
55 | /* @var $app['config'] Repository */ |
||||
56 | $app['config']->set(['server-monitor' => include(__DIR__ . '/../vendor/spatie/laravel-server-monitor/config/server-monitor.php')]); |
||||
57 | |||||
58 | $app['config']->set('server-monitor.notifications.notifications', [ |
||||
59 | \TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckSucceeded::class => [], |
||||
60 | \TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckRestored::class => [], |
||||
61 | \TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckWarning::class => ['mail'], |
||||
62 | \TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifications\CheckFailed::class => ['slack'], |
||||
63 | ]); |
||||
64 | |||||
65 | $app['config']->set('server-monitor.notifications.mail', ['to' => '[email protected]']); |
||||
66 | $app['config']->set('server-monitor.notifications.slack', ['webhook_url' => 'test']); |
||||
67 | $app['config']->set('server-monitor.notifications.notifiable', TheCodingMachine\ServerMonitorPluginNotificationByHost\Notifications\Notifiable::class); |
||||
0 ignored issues
–
show
|
|||||
68 | |||||
69 | $app['config']->set(['server-monitor-plugin-notification-by-host' => include(__DIR__ . '/../config/server-monitor-plugin-notification-by-host.php')]); |
||||
70 | |||||
71 | $this->setUpDatabase(); |
||||
72 | } |
||||
73 | |||||
74 | protected function setUpDatabase() |
||||
75 | { |
||||
76 | include_once __DIR__.'/../vendor/spatie/laravel-server-monitor/database/migrations/create_hosts_table.php.stub'; |
||||
77 | (new \CreateHostsTable())->up(); |
||||
0 ignored issues
–
show
The type
CreateHostsTable was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
78 | |||||
79 | include_once __DIR__.'/../vendor/spatie/laravel-server-monitor/database/migrations/create_checks_table.php.stub'; |
||||
80 | (new \CreateChecksTable())->up(); |
||||
0 ignored issues
–
show
The type
CreateChecksTable was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
81 | } |
||||
82 | |||||
83 | |||||
84 | /** |
||||
85 | * @param string|array $searchStrings |
||||
86 | */ |
||||
87 | View Code Duplication | protected function seeInConsoleOutput($searchStrings) |
|||
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||||
88 | { |
||||
89 | if (! is_array($searchStrings)) { |
||||
90 | $searchStrings = [$searchStrings]; |
||||
91 | } |
||||
92 | $output = $this->getArtisanOutput(); |
||||
93 | foreach ($searchStrings as $searchString) { |
||||
94 | $this->assertContains((string) $searchString, $output); |
||||
95 | } |
||||
96 | } |
||||
97 | |||||
98 | /** |
||||
99 | * @param string|array $searchStrings |
||||
100 | */ |
||||
101 | View Code Duplication | protected function dontSeeInConsoleOutput($searchStrings) |
|||
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||||
102 | { |
||||
103 | if (! is_array($searchStrings)) { |
||||
104 | $searchStrings = [$searchStrings]; |
||||
105 | } |
||||
106 | $output = $this->getArtisanOutput(); |
||||
107 | foreach ($searchStrings as $searchString) { |
||||
108 | $this->assertNotContains((string) $searchString, $output); |
||||
109 | } |
||||
110 | } |
||||
111 | |||||
112 | protected function getArtisanOutput(): string |
||||
113 | { |
||||
114 | $this->consoleOutputCache .= Artisan::output(); |
||||
115 | |||||
116 | return $this->consoleOutputCache; |
||||
117 | } |
||||
118 | |||||
119 | |||||
120 | public function addHosts($name, array $checks = []) |
||||
0 ignored issues
–
show
The parameter
$checks is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
121 | { |
||||
122 | Host::create([ |
||||
123 | 'name' => $name, |
||||
124 | 'ssh_user' => 'user', |
||||
125 | 'port' => 22]); |
||||
126 | /* |
||||
127 | if (! is_array($names)) { |
||||
128 | $names = [$names]; |
||||
129 | } |
||||
130 | /* |
||||
131 | collect($names)->each(function ($name) use ($checks) { |
||||
132 | Host::create([ |
||||
133 | 'name' => $name, |
||||
134 | 'ssh_user' => 'user', |
||||
135 | 'port' => 22, |
||||
136 | ])->checks()->saveMany(collect($checks)->map(function (string $checkName) { |
||||
137 | return new Check([ |
||||
138 | 'type' => $checkName, |
||||
139 | 'status' => CheckStatus::NOT_YET_CHECKED, |
||||
140 | 'custom_properties' => [], |
||||
141 | ]); |
||||
142 | })); |
||||
143 | }); |
||||
144 | */ |
||||
145 | } |
||||
146 | |||||
147 | |||||
148 | |||||
149 | |||||
150 | |||||
151 | |||||
152 | |||||
153 | |||||
154 | |||||
155 | |||||
156 | |||||
157 | |||||
158 | |||||
159 | |||||
160 | |||||
161 | |||||
162 | |||||
163 | |||||
164 | |||||
165 | |||||
166 | |||||
167 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths