Issues (2)

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.

src/NotyWidget.php (2 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
2
3
namespace dominus77\noty;
4
5
use Yii;
6
use yii\base\Widget;
7
use yii\helpers\Json;
8
9
/**
10
 * Class NotyWidget
11
 * @package dominus77\noty
12
 */
13
class NotyWidget extends Widget
14
{
15
    /**
16
     * Themes
17
     */
18
    const THEME_BOOTSTRAP_3 = 'bootstrap-v3';
19
    const THEME_BOOTSTRAP_4 = 'bootstrap-v4';
20
    const THEME_LIGHT = 'light';
21
    const THEME_METROUI = 'metroui';
22
    const THEME_MINT = 'mint';
23
    const THEME_NEST = 'nest';
24
    const THEME_RELAX = 'relax';
25
    const THEME_SEMANTICUI = 'semanticui';
26
    const THEME_SUNSET = 'sunset';
27
28
    /**
29
     * Types
30
     */
31
    const TYPE_ALERT = 'alert';
32
    const TYPE_SUCCESS = 'success';
33
    const TYPE_WARNING = 'warning';
34
    const TYPE_DANGER = 'error';
35
    const TYPE_ERROR = 'error';
36
    const TYPE_INFO = 'info';
37
38
    /**
39
     * Layouts
40
     */
41
    const LAYOUT_TOP = 'top';
42
    const LAYOUT_TOP_LEFT = 'topLeft';
43
    const LAYOUT_TOP_CENTER = 'topCenter';
44
    const LAYOUT_TOP_RIGHT = 'topRight';
45
    const LAYOUT_CENTER = 'center';
46
    const LAYOUT_CENTER_LEFT = 'centerLeft';
47
    const LAYOUT_CENTER_RIGHT = 'centerRight';
48
    const LAYOUT_BOTTOM = 'bottom';
49
    const LAYOUT_BOTTOM_LEFT = 'bottomLeft';
50
    const LAYOUT_BOTTOM_CENTER = 'bottomCenter';
51
    const LAYOUT_BOTTOM_RIGHT = 'bottomRight';
52
53
    /**
54
     * @var array
55
     */
56
    private $typeMap = [
57
        'alert' => self::TYPE_ALERT,
58
        'success' => self::TYPE_SUCCESS,
59
        'warning' => self::TYPE_WARNING,
60
        'danger' => self::TYPE_DANGER,
61
        'error' => self::TYPE_ERROR,
62
        'info' => self::TYPE_INFO,
63
    ];
64
65
    /**
66
     * @var array
67
     */
68
    public $typeOptions = [
69
        self::TYPE_SUCCESS => [],
70
        self::TYPE_INFO => [],
71
        self::TYPE_ALERT => [],
72
        self::TYPE_ERROR => [],
73
        self::TYPE_WARNING => []
74
    ];
75
76
    /**
77
     * @var array
78
     */
79
    public $options = [
80
        'progressBar' => true,
81
        'timeout' => false,
82
        'layout' => self::LAYOUT_TOP_RIGHT,
83
        'dismissQueue' => true,
84
        'theme' => self::THEME_RELAX,
85
    ];
86
87
    /** @var yii\web\View */
88
    private $_view;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
89
90
    /**
91
     * @inheritdoc
92
     */
93 2
    public function init()
94
    {
95 2
        parent::init();
96 2
        $this->_view = $this->getView();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getView() of type object<yii\web\View> is incompatible with the declared type object<dominus77\noty\yii\web\View> of property $_view.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
97 2
        NotyAsset::register($this->_view);
98 2
    }
99
100
    /**
101
     * @return string|void
102
     */
103 2
    public function run()
104
    {
105 2
        $session = Yii::$app->session;
106 2
        $flashes = $session->getAllFlashes();
107
108
109 2
        foreach ($flashes as $key => $item) {
110
            if (is_array($item)) {
111
112
                if (!isset($this->typeMap[$item[0]])) {
113
                    continue;
114
                }
115
116
                $typeAlert = $this->typeMap[$item[0]];
117
                $typeOptions = $this->typeOptions[$typeAlert] ?? [];
118
                $oldOptions = $this->options;
119
120
                if (isset($item[2])) {
121
                    $this->typeOptions[$typeAlert] = array_merge($typeOptions, $item[2] ?? []);
122
                }
123
124
                if (isset($item[3])) {
125
                    $this->options = array_merge($oldOptions, $item[3] ?? []);
126
                }
127
128
                $options = array_merge($this->options, $this->typeOptions[$typeAlert] ?? []);
129
130
                $options['type'] = $typeAlert;
131
                $options['text'] = $item[1];
132
133
                $this->register($options);
134
                $this->typeOptions[$typeAlert] = $typeOptions;
135
                $this->options = $oldOptions;
136
            } else {
137
138
                if (!isset($this->typeMap[$key])) {
139
                    continue;
140
                }
141
142
                $typeAlert = $this->typeMap[$key];
143
                $options = array_merge($this->options, $this->typeOptions[$typeAlert] ?? []);
144
145
                foreach ((array)$item as $i => $message) {
146
                    $options['type'] = $typeAlert;
147
                    $options['text'] = $message;
148
149
                    $this->register($options);
150
                }
151
            }
152
            $session->removeFlash($key);
153
        }
154 2
    }
155
156
    /**
157
     * @param array $options
158
     */
159
    public function register($options = [])
160
    {
161
        $optionsEncoded = Json::encode($options);
162
        $this->_view->registerJs("new Noty($optionsEncoded).show();");
163
    }
164
}
165