Issues (4)

Security Analysis    not enabled

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/IonicPushMessage.php (2 issues)

Labels

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 NotificationChannels\IonicPushNotifications;
4
5
use DateTime;
6
7
class IonicPushMessage
8
{
9
    /** @var string */
10
    public $sendTo = 'tokens';
11
12
    /** @var string */
13
    public $profile;
14
15
    /** @var string */
16
    public $title = '';
17
18
    /** @var string */
19
    public $message = '';
20
21
    /** @var string */
22
    public $sound = '';
23
24
    /** @var DateTime */
25
    public $scheduled = '';
26
27
    /** @var array */
28
    public $payload = [];
29
30
    /** @var array */
31
    public $iosData = [];
32
33
    /** @var array */
34
    public $androidData = [];
35
36
    /**
37
     * @param array $data
0 ignored issues
show
There is no parameter named $data. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
38
     *
39
     * @return static
40
     */
41
    public static function create($profile)
42
    {
43
        return new static($profile);
44
    }
45
46
    /**
47
     * @param string $profile
48
     */
49
    public function __construct($profile)
50
    {
51
        $this->profile = $profile;
52
    }
53
54
    /**
55
     * Set the method of targeting users - tokens (default), user_ids, or emails.
56
     *
57
     * @param  string  $profile
0 ignored issues
show
There is no parameter named $profile. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
58
     *
59
     * @return $this
60
     */
61
    public function sendTo($sendTo)
62
    {
63
        $this->sendTo = $sendTo;
64
65
        return $this;
66
    }
67
68
    /**
69
     * Set the title.
70
     *
71
     * @param  string  $title
72
     *
73
     * @return $this
74
     */
75
    public function title($title)
76
    {
77
        $this->title = $title;
78
79
        return $this;
80
    }
81
82
    /**
83
     * Set the message.
84
     *
85
     * @param  string  $message
86
     *
87
     * @return $this
88
     */
89
    public function message($message)
90
    {
91
        $this->message = $message;
92
93
        return $this;
94
    }
95
96
    /**
97
     * Set the security sound to use.
98
     *
99
     * @param  string  $sound
100
     *
101
     * @return $this
102
     */
103
    public function sound($sound)
104
    {
105
        $this->sound = $sound;
106
107
        return $this;
108
    }
109
110
    /**
111
     * Send custom key/value data with your notifications.
112
     *
113
     * @param  array  $payload
114
     *
115
     * @return $this
116
     */
117
    public function payload($payload)
118
    {
119
        $this->payload = $payload;
120
121
        return $this;
122
    }
123
124
    /**
125
     * Schedule the message for later delivery.
126
     *
127
     * @param  string|DateTime $date
128
     * @return $this
129
     */
130
    public function scheduled($date)
131
    {
132
        if (! $date instanceof DateTime) {
133
            $date = new DateTime($date);
134
        }
135
136
        $this->scheduled = $date->format(DateTime::RFC3339);
137
138
        return $this;
139
    }
140
141
    /**
142
     * Dynamically add device specific data.
143
     *
144
     * @param string $method
145
     * @param array  $args
146
     *
147
     * @return object
148
     */
149
    public function __call($method, $args)
150
    {
151
        if (substr($method, 0, 3) == 'ios') {
152
            $key = snake_case(substr($method, 3));
153
154
            if (in_array($key, $this->allowediOSOptions())) {
155
                $this->iosData[$key] = $args[0];
156
            }
157
        } elseif (substr($method, 0, 7) == 'android') {
158
            $key = snake_case(substr($method, 7));
159
160
            if (in_array($key, $this->allowedAndroidOptions())) {
161
                $this->androidData[$key] = $args[0];
162
            }
163
        }
164
165
        return $this;
166
    }
167
168
    /**
169
     * Get the method we want to use to send messages.
170
     *
171
     * @return string
172
     */
173
    public function getSendToType()
174
    {
175
        return $this->sendTo;
176
    }
177
178
    /**
179
     * List of allowed Android options.
180
     *
181
     * @return array
182
     */
183
    public function allowedAndroidOptions()
184
    {
185
        return [
186
            'collapse_key',
187
            'content_available',
188
            'data',
189
            'delay_while_idle',
190
            'icon',
191
            'icon_color',
192
            'message',
193
            'priority',
194
            'sound',
195
            'tag',
196
            'time_to_live',
197
            'title',
198
        ];
199
    }
200
201
    /**
202
     * List of allowed iOS options.
203
     *
204
     * @return array
205
     */
206
    public function allowediOSOptions()
207
    {
208
        return [
209
            'message',
210
            'title',
211
            'badge',
212
            'payload',
213
            'sound',
214
            'priority',
215
            'expire',
216
            'content_available',
217
        ];
218
    }
219
220
    /**
221
     * @return array
222
     */
223
    public function toArray()
224
    {
225
        $data = [
226
            'profile' => $this->profile,
227
            'notification' => [
228
                'message' => $this->message,
229
            ],
230
        ];
231
232
        if (! empty($this->scheduled)) {
233
            $data['scheduled'] = $this->scheduled;
234
        }
235
236
        if (! empty($this->title)) {
237
            $data['notification']['title'] = $this->title;
238
        }
239
240
        if (! empty($this->sound)) {
241
            $data['notification']['sound'] = $this->sound;
242
        }
243
244
        if (! empty($this->iosData)) {
245
            $data['notification']['ios'] = $this->iosData;
246
        }
247
248
        if (! empty($this->androidData)) {
249
            $data['notification']['android'] = $this->androidData;
250
        }
251
252
        if (! empty($this->payload)) {
253
            $data['notification']['payload'] = $this->payload;
254
        }
255
256
        return $data;
257
    }
258
}
259