Issues (34)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

tests/TestCase.php (9 issues)

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
The type TheCodingMachine\ServerM...ationByHost\Test\Server 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
    public $server;
13
14
    /** @var ?string */
0 ignored issues
show
Documentation Bug introduced by
The doc comment ?string at position 0 could not be parsed: Unknown type name '?string' at position 0 in ?string.
Loading history...
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 ignore-unused  annotation

32
    protected function getPackageProviders(/** @scrutinizer ignore-unused */ $app)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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
The type TheCodingMachine\ServerM...otifications\Notifiable was not found. Did you mean TheCodingMachine\ServerM...otifications\Notifiable? If so, make sure to prefix the type with \.
Loading history...
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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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.

Loading history...
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.

Loading history...
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 ignore-unused  annotation

120
    public function addHosts($name, /** @scrutinizer ignore-unused */ array $checks = [])

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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
}