Issues (50)

Security Analysis    no request data  

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

  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  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.
  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.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
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.

TransportManager.php (4 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php namespace nyx\notify;
2
3
// External dependencies
4
use Illuminate\Contracts\Queue\ShouldQueue;
5
use Illuminate\Contracts\Bus\Dispatcher;
6
7
/**
8
 * Notification Transport Manager
9
 *
10
 * @package     Nyx\Notify
11
 * @version     0.1.0
12
 * @author      Michal Chojnacki <[email protected]>
13
 * @copyright   2012-2017 Nyx Dev Team
14
 * @link        https://github.com/unyx/nyx
15
 * @todo        Proper eventing (beforeSend, afterSend, failedSend etc.) hooked into Nyx's Events component.
16
 * @todo        Add support for core Collections and PHP 7.1 iterables (Notifiable entities).
17
 */
18
class TransportManager extends \Illuminate\Support\Manager implements interfaces\Dispatcher
19
{
20
    /**
21
     * {@inheritDoc}
22
     */
23
    public function send($notifiables, interfaces\Notification $notification)
24
    {
25
        // In here, as opposed to self::sendNow(), we respect the ShouldQueue interface
26
        // and push the Notification onto the queue if it asks us to.
27
        if ($notification instanceof ShouldQueue) {
28
            $this->enqueue($notifiables, $notification);
29
            return;
30
        }
31
32
        $this->sendNow($notifiables, $notification);
33
    }
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    public function sendNow($notifiables, interfaces\Notification $notification)
39
    {
40
        if (!is_array($notifiables)) {
41
            $notifiables = [$notifiables];
42
        }
43
44
        foreach ($notifiables as $notifiable) {
45
46
            // Iterate over all transports the Notification specifies for the current Notifiable,
47
            // then determine whether it shall be sent and send it.
48
            foreach ($notification->via($notifiable) as $transport) {
49
50
                $transport = $this->driver($transport);
51
52
                if (!$this->shouldSend($notifiable, $notification, $transport)) {
53
                    continue;
54
                }
55
56
                // All clear at this point - let's dispatch the Notification.
57
                $transport->send($notifiable, $notification);
58
            }
59
        }
60
    }
61
62
    /**
63
     * {@inheritDoc}
64
     */
65
    public function getDefaultDriver() : string
66
    {
67
        return 'mail';
68
    }
69
70
    /**
71
     * Determines whether the Notification should be sent at all, given the context.
72
     *
73
     * @param   interfaces\Notifiable   $notifiable     The entity being notified.
74
     * @param   interfaces\Notification $notification   The Notification being sent.
75
     * @param   interfaces\Transport    $transport      The Transport the Notification should be sent over.
76
     * @return  bool                                    True when the Notification should be sent, false otherwise.
77
     * @todo    onBeforeSend event allowing listeners to prevent dispatching.
78
     */
79
    protected function shouldSend(interfaces\Notifiable $notifiable, interfaces\Notification $notification, interfaces\Transport $transport) : bool
0 ignored issues
show
The parameter $notifiable is not used and could be removed.

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

Loading history...
80
    {
81
        if (!$transport->supports($notification)) {
82
            return false;
83
        }
84
85
        return true;
86
    }
87
88
    /**
89
     * Enqueues the given Notification.
90
     *
91
     * @param   mixed                   $notifiables    The entities which shall receive the Notification.
92
     * @param   interfaces\Notification $notification   The Notification to enqueue.
93
     */
94
    protected function enqueue($notifiables, interfaces\Notification $notification)
95
    {
96
        // @todo Laravel's ShouldQueue interface doesn't actually cover access to those properties
97
        // so we'll need a more robust solution later.
98
        $this->app->make(Dispatcher::class)->dispatch(
99
            (new jobs\Enqueue($notifiables, $notification))
100
                ->onConnection($notification->connection)
0 ignored issues
show
Accessing connection on the interface nyx\notify\interfaces\Notification suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
101
                ->onQueue($notification->queue)
0 ignored issues
show
Accessing queue on the interface nyx\notify\interfaces\Notification suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
102
                ->delay($notification->delay)
0 ignored issues
show
Accessing delay on the interface nyx\notify\interfaces\Notification suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
103
        );
104
    }
105
106
    /**
107
     * {@inheritDoc}
108
     */
109
    protected function createDriver($driver)
110
    {
111
        try {
112
            return parent::createDriver($driver);
113
        } catch (\InvalidArgumentException $exception) {
114
115
            // Re-throw if the driver wasn't recognized and isn't a fully-qualified (and existing) class name.
116
            if (!class_exists($driver)) {
117
                throw $exception;
118
            }
119
120
            return $this->app->make($driver);
121
        }
122
    }
123
124
    /**
125
     * Creates a Mail Transport.
126
     *
127
     * @return  transports\Mail
128
     */
129
    protected function createMailDriver() : transports\Mail
130
    {
131
        return $this->app->make(transports\Mail::class);
132
    }
133
134
    /**
135
     * Creates a Slack Transport.
136
     *
137
     * @return  transports\Slack
138
     */
139
    protected function createSlackDriver() : transports\Slack
140
    {
141
        return new transports\Slack($this->app->make('config')->get('services.slack'), new \GuzzleHttp\Client);
142
    }
143
}
144