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.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace EricMakesStuff\ServerMonitor\Notifications; |
||
4 | |||
5 | use EricMakesStuff\ServerMonitor\Events\HttpPingDown; |
||
6 | use EricMakesStuff\ServerMonitor\Events\HttpPingUp; |
||
7 | use EricMakesStuff\ServerMonitor\Events\DiskUsageAlarm; |
||
8 | use EricMakesStuff\ServerMonitor\Events\DiskUsageHealthy; |
||
9 | use EricMakesStuff\ServerMonitor\Events\SSLCertificateExpiring; |
||
10 | use EricMakesStuff\ServerMonitor\Events\SSLCertificateInvalid; |
||
11 | use EricMakesStuff\ServerMonitor\Events\SSLCertificateValid; |
||
12 | use Illuminate\Events\Dispatcher; |
||
13 | |||
14 | class EventHandler |
||
15 | { |
||
16 | /** |
||
17 | * @var \EricMakesStuff\ServerMonitor\Notifications\Notifier |
||
18 | */ |
||
19 | protected $notifier; |
||
20 | |||
21 | public function __construct() |
||
22 | { |
||
23 | $notifierClass = config('server-monitor.notifications.handler'); |
||
24 | |||
25 | $this->notifier = app($notifierClass); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param \EricMakesStuff\ServerMonitor\Events\DiskUsageAlarm $event |
||
30 | */ |
||
31 | public function whenDiskUsageAlarm(DiskUsageAlarm $event) |
||
32 | { |
||
33 | $this->notifier->diskUsageAlarm($event->diskUsageMonitor); |
||
0 ignored issues
–
show
|
|||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @param \EricMakesStuff\ServerMonitor\Events\DiskUsageHealthy $event |
||
38 | */ |
||
39 | public function whenDiskUsageHealthy(DiskUsageHealthy $event) |
||
40 | { |
||
41 | $this->notifier->diskUsageHealthy($event->diskUsageMonitor); |
||
0 ignored issues
–
show
It seems like
$event->diskUsageMonitor can be null ; however, diskUsageHealthy() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
![]() |
|||
42 | } |
||
43 | |||
44 | /** |
||
45 | * @param \EricMakesStuff\ServerMonitor\Events\HttpPingDown $event |
||
46 | */ |
||
47 | public function whenHttpPingDown(HttpPingDown $event) |
||
48 | { |
||
49 | $this->notifier->httpPingDown($event->httpPingMonitor); |
||
0 ignored issues
–
show
It seems like
$event->httpPingMonitor can be null ; however, httpPingDown() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
![]() |
|||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param \EricMakesStuff\ServerMonitor\Events\HttpPingUp $event |
||
54 | */ |
||
55 | public function whenHttpPingUp(HttpPingUp $event) |
||
56 | { |
||
57 | $this->notifier->httpPingUp($event->httpPingMonitor); |
||
0 ignored issues
–
show
It seems like
$event->httpPingMonitor can be null ; however, httpPingUp() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
![]() |
|||
58 | } |
||
59 | |||
60 | /** |
||
61 | * @param \EricMakesStuff\ServerMonitor\Events\SSLCertificateValid $event |
||
62 | */ |
||
63 | public function whenSSLCertificateValid(SSLCertificateValid $event) |
||
64 | { |
||
65 | $this->notifier->sslCertificateValid($event->sslCertificateMonitor); |
||
0 ignored issues
–
show
It seems like
$event->sslCertificateMonitor can be null ; however, sslCertificateValid() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
![]() |
|||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param \EricMakesStuff\ServerMonitor\Events\SSLCertificateInvalid $event |
||
70 | */ |
||
71 | public function whenSSLCertificateInvalid(SSLCertificateInvalid $event) |
||
72 | { |
||
73 | $this->notifier->sslCertificateInvalid($event->sslCertificateMonitor); |
||
0 ignored issues
–
show
It seems like
$event->sslCertificateMonitor can be null ; however, sslCertificateInvalid() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
![]() |
|||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @param \EricMakesStuff\ServerMonitor\Events\SSLCertificateExpiring $event |
||
78 | */ |
||
79 | public function whenSSLCertificateExpiring(SSLCertificateExpiring $event) |
||
80 | { |
||
81 | $this->notifier->sslCertificateExpiring($event->sslCertificateMonitor); |
||
0 ignored issues
–
show
It seems like
$event->sslCertificateMonitor can be null ; however, sslCertificateExpiring() does not accept null , maybe add an additional type check?
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: /** @return stdClass|null */
function mayReturnNull() { }
function doesNotAcceptNull(stdClass $x) { }
// With potential error.
function withoutCheck() {
$x = mayReturnNull();
doesNotAcceptNull($x); // Potential error here.
}
// Safe - Alternative 1
function withCheck1() {
$x = mayReturnNull();
if ( ! $x instanceof stdClass) {
throw new \LogicException('$x must be defined.');
}
doesNotAcceptNull($x);
}
// Safe - Alternative 2
function withCheck2() {
$x = mayReturnNull();
if ($x instanceof stdClass) {
doesNotAcceptNull($x);
}
}
![]() |
|||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Register the listeners for the subscriber. |
||
86 | * |
||
87 | * @param \Illuminate\Events\Dispatcher $events |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | public function subscribe(Dispatcher $events) |
||
92 | { |
||
93 | $events->listen( |
||
94 | DiskUsageHealthy::class, |
||
95 | static::class.'@whenDiskUsageHealthy' |
||
96 | ); |
||
97 | |||
98 | $events->listen( |
||
99 | DiskUsageAlarm::class, |
||
100 | static::class.'@whenDiskUsageAlarm' |
||
101 | ); |
||
102 | |||
103 | $events->listen( |
||
104 | HttpPingUp::class, |
||
105 | static::class.'@whenHttpPingUp' |
||
106 | ); |
||
107 | |||
108 | $events->listen( |
||
109 | HttpPingDown::class, |
||
110 | static::class.'@whenHttpPingDown' |
||
111 | ); |
||
112 | |||
113 | $events->listen( |
||
114 | SSLCertificateValid::class, |
||
115 | static::class.'@whenSSLCertificateValid' |
||
116 | ); |
||
117 | |||
118 | $events->listen( |
||
119 | SSLCertificateInvalid::class, |
||
120 | static::class.'@whenSSLCertificateInvalid' |
||
121 | ); |
||
122 | |||
123 | $events->listen( |
||
124 | SSLCertificateExpiring::class, |
||
125 | static::class.'@whenSSLCertificateExpiring' |
||
126 | ); |
||
127 | } |
||
128 | } |
||
129 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: