Issues (4)

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/Infobip.php (1 issue)

Labels
Severity

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\Infobip;
4
5
use infobip\api\client\SendMultipleTextualSmsAdvanced;
6
use infobip\api\client\SendSingleTextualSms;
7
use infobip\api\configuration\BasicAuthConfiguration;
8
use infobip\api\model\Destination;
9
use infobip\api\model\sms\mt\send\Message;
10
use infobip\api\model\sms\mt\send\textual\SMSAdvancedTextualRequest;
11
use infobip\api\model\sms\mt\send\textual\SMSTextualRequest;
12
use NotificationChannels\Infobip\Exceptions\CouldNotSendNotification;
13
14
class Infobip
15
{
16
    /**
17
     * @var InfobipConfig
18
     */
19
    public $config;
20
21
    /**
22
     * @var InfobipMessage
23
     */
24
    public $message;
25
26
    /**
27
     * Infobip constructor.
28
     *
29
     * @param InfobipMessage $message
30
     * @param InfobipConfig $config
31
     */
32
    public function __construct(InfobipMessage $message, InfobipConfig $config)
33
    {
34
        $this->config = $config;
35
        $this->message = $message;
36
    }
37
38
    /**
39
     * Send sms message to recipient.
40
     *
41
     * @param InfobipMessage $message
42
     * @param $recipient
43
     * @return \infobip\api\model\sms\mt\send\SMSResponse
44
     * @throws CouldNotSendNotification
45
     */
46
    public function sendMessage(InfobipMessage $message, $recipient)
47
    {
48
        if ($message instanceof InfobipMessage) {
49
            $message->from($this->config->getFrom());
50
51
            return $this->sendSms($message, $recipient);
52
        }
53
54
        if ($message instanceof InfobipSmsAdvancedMessage) {
55
            $message->from($this->config->getFrom());
56
            $message->notifyUrl($this->config->getNotifyUrl());
57
58
            return $this->sendSmsAdvanced($message, $recipient);
59
        }
60
61
        throw CouldNotSendNotification::invalidMessageObject($message);
62
    }
63
64
    /**
65
     * Send sms message to recipient using Infobip SMSTextualRequest.
66
     *
67
     * @param InfobipMessage $message
68
     * @param $recipient
69
     * @return \infobip\api\model\sms\mt\send\SMSResponse
70
     */
71
    public function sendSms(InfobipMessage $message, $recipient)
72
    {
73
        $client = new SendSingleTextualSms(new BasicAuthConfiguration($this->config->config['username'], $this->config->config['password']));
74
75
        $request = new SMSTextualRequest();
76
        $request->setFrom($this->getFrom($message));
77
        $request->setTo($recipient);
78
        $request->setText($message->content);
79
80
        return $client->execute($request);
81
    }
82
83
    /**
84
     * Send sms advanced to recipient using SMSAdvancedTextualRequest.
85
     *
86
     * @param InfobipSmsAdvancedMessage $message
87
     * @param $recipient
88
     * @return \infobip\api\model\sms\mt\send\SMSResponse
89
     */
90
    public function sendSmsAdvanced(InfobipSmsAdvancedMessage $message, $recipient)
91
    {
92
        $client = new SendMultipleTextualSmsAdvanced(new BasicAuthConfiguration($this->config->config['username'], $this->config->config['password']));
93
94
        $destination = new Destination();
95
96
        $destination->setTo($recipient);
97
98
        $requestMessage = new Message();
99
        $requestMessage->setFrom($this->getFrom($message));
100
        $requestMessage->setDestinations([$destination]);
101
        $requestMessage->setText($message->content);
102
        $requestMessage->setNotifyUrl($this->getNotifyUrl($message));
103
104
        $request = new SMSAdvancedTextualRequest();
105
        $request->setMessages([$requestMessage]);
106
107
        return $client->execute($request);
108
    }
109
110
    /**
111
     * Get message from phone number from message or config.
112
     *
113
     * @param InfobipMessage $message
114
     * @return mixed
115
     * @throws CouldNotSendNotification
116
     */
117
    public function getFrom(InfobipMessage $message)
118
    {
119
        if (! $from = $message->from ?: $this->config->config['from']) {
120
            throw CouldNotSendNotification::missingFrom();
121
        }
122
123
        return $message->from ?: $this->config->config['from'];
124
    }
125
126
    /**
127
     * Get sms notify url.
128
     *
129
     * @param InfobipSmsAdvancedMessage $message
130
     * @return mixed
131
     * @throws CouldNotSendNotification
132
     */
133
    public function getNotifyUrl(InfobipSmsAdvancedMessage $message)
134
    {
135
        if (! $notifyUrl = $message->notifyUrl ?: $this->config->config['notify_url']) {
136
            throw CouldNotSendNotification::missingNotifyUrl();
137
        }
138
139
        return $message->notify_url ?: $this->config->config['notify_url'];
0 ignored issues
show
The property notify_url does not seem to exist in NotificationChannels\Inf...fobipSmsAdvancedMessage.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
140
    }
141
}
142