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/SMS77.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\SMS77;
4
5
use Exception;
6
use GuzzleHttp\Client as HttpClient;
7
use GuzzleHTtp\Exception\ClientException;
8
use NotificationChannels\SMS77\Exceptions\CouldNotSendNotification;
9
10
class SMS77
11
{
12
    /**
13
     * @var string SMS77 API URL.
14
     */
15
    protected string $apiUrl = 'https://gateway.sms77.io/api/';
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
16
17
    /**
18
     * @var HttpClient HTTP Client.
19
     */
20
    protected $http;
21
22
    /**
23
     * @var null|string SMS77 API Key.
24
     */
25
    protected $apiKey;
26
27
    /**
28
     * @param string $apiKey
29
     * @param HttpClient $http
30
     */
31
    public function __construct(string $apiKey = null, HttpClient $http = null)
32
    {
33
        $this->apiKey = $apiKey;
34
        $this->http = $http;
35
    }
36
37
    /**
38
     * Get API key.
39
     *
40
     * @return string
41
     */
42
    public function getApiKey(): string
43
    {
44
        return $this->apiKey;
45
    }
46
47
    /**
48
     * Set API key.
49
     *
50
     * @param string $apiKey
51
     */
52
    public function setApiKey(string $apiKey)
53
    {
54
        $this->apiKey = $apiKey;
55
    }
56
57
    /**
58
     * Get HttpClient.
59
     *
60
     * @return HttpClient
61
     */
62
    protected function httpClient(): HttpClient
63
    {
64
        return $this->http ?? new HttpClient();
65
    }
66
67
    /**
68
     * Send text message.
69
     *
70
     * <code>
71
     * $params = [
72
     *      'to'                    => '',
73
     *      'text'                  => '',
74
     *      'from'                  => '',
75
     *      'debug'                 => '',
76
     *      'delay'                 => '',
77
     *      'no_reload'             => '',
78
     *      'unicode'               => '',
79
     *      'flash'                 => '',
80
     *      'udh'                   => '',
81
     *      'utf8'                  => '',
82
     *      'ttl'                   => '',
83
     *      'details'               => '',
84
     *      'return_msg_id'         => '',
85
     *      'label'                 => '',
86
     *      'json'                  => '',
87
     *      'performance_tracking'  => ''
88
     * ];
89
     * </code>
90
     *
91
     * @link https://www.sms77.io/en/docs/gateway/http-api/sms-disptach/
92
     *
93
     * @param array $params
94
     */
95
    public function sendMessage(array $params)
96
    {
97
        return $this->sendRequest('sms', $params);
98
    }
99
100
    public function sendRequest(string $endpoint, array $params)
101
    {
102
        if (empty($this->apiKey)) {
103
            throw CouldNotSendNotification::apiKeyNotProvided();
104
        }
105
106
        try {
107
            return $this->httpClient()->post($this->apiUrl.$endpoint, [
108
                'headers' => [
109
                    'Authorization' => 'basic '.$this->apiKey,
110
                ],
111
                'form_params' => $params,
112
            ]);
113
        } catch (ClientException $exception) {
114
            throw CouldNotSendNotification::serviceRespondedWithAnError($exception);
115
        } catch (Exception $exception) {
116
            throw CouldNotSendNotification::serviceNotAvailable($exception);
117
        }
118
    }
119
}
120