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

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
 * This file is part of the Jusibe PHP library.
4
 *
5
 * (c) Prosper Otemuyiwa <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Unicodeveloper\Jusibe;
12
13
use StdClass;
14
use Dotenv\Dotenv;
15
use GuzzleHttp\Client;
16
use Unicodeveloper\Jusibe\Exceptions\IsEmpty;
17
18
trait Helper {
19
20
    /**
21
    * Load Dotenv to grant getenv() access to environment variables in .env file.
22
    */
23
     public function loadEnv()
24
     {
25
         if (! getenv('APP_ENV')) {
26
             $dotenv = new Dotenv(__DIR__.'/../');
0 ignored issues
show
__DIR__ . '/../' is of type string, but the function expects a object<Dotenv\Loader\LoaderInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
27
             $dotenv->load();
28
         }
29
     }
30
31
     /**
32
      * Get Valid Message ID
33
      * @return string
34
      */
35
     public function getValidMessageID()
36
     {
37
        return getenv('VALID_MESSAGE_ID');
38
     }
39
40
     /**
41
      * Get Valid Bulk Message ID
42
      * @return string
43
      */
44
      public function getValidBulkMessageID()
45
      {
46
         return getenv('BULK_MESSAGE_ID');
47
      }
48
49
     /**
50
      * Get Invalid Message ID
51
      * @return string
52
      */
53
     public function getInvalidMessageID()
54
     {
55
        return getenv('INVALID_MESSAGE_ID');
56
     }
57
58
     /**
59
      * Get Valid Access Token
60
      * @return string
61
      */
62
     public function getValidAccessToken()
63
     {
64
        return getenv('VALID_ACCESS_TOKEN');
65
     }
66
67
     /**
68
      * Stubbed checkDeliveryStatusResponse
69
      * @return object
70
      */
71
     public function checkDeliveryStatusResponse()
72
     {
73
        $response = new StdClass;
74
        $response->message_id = $this->getValidMessageID();
75
        $response->status = 'Delivered';
76
        $response->date_sent = time();
77
        $response->date_delivered = time();
78
79
        return $response;
80
     }
81
82
     /**
83
      * Stubbed checkBulkDeliveryStatusResponse
84
      * @return object
85
      */
86
      public function checkBulkDeliveryStatusResponse()
87
      {
88
         $response = new StdClass;
89
         $response->bulk_message_id = $this->getValidBulkMessageID();
90
         $response->status = 'Completed';
91
         $response->created = time();
92
         $response->processed = time();
93
         $response->total_numbers = 2;
94
         $response->total_unique_numbers = 2;
95
         $response->total_valid_numbers = 2;
96
         $response->total_invalid_numbers = 0;
97
 
98
         return $response;
99
      }
100
101
     /**
102
      * Stubbed Invalid Keys Response
103
      * @return object
104
      */
105
     public function invalidKeysResponse()
106
     {
107
        $response = new StdClass;
108
        $response->error = "Invalid API Key!";
109
110
        return $response;
111
     }
112
113
     /**
114
      * Stubbed Invalid Message ID Response
115
      * @return object
116
      */
117
     public function invalidMessageIDResponse()
118
     {
119
        $response = new StdClass;
120
        $response->invalid_message_id = "Invalid message ID";
121
122
        return $response;
123
     }
124
125
     /**
126
      * Stubbed sendSMSResponse
127
      * @return object
128
      */
129
     public function sendSMSResponse()
130
     {
131
        $response = new StdClass;
132
        $response->status = 'Sent';
133
        $response->message_id = $this->getValidMessageID();
134
        $response->sms_credits_used = 1;
135
136
        return $response;
137
     }
138
139
     /**
140
      * Stubbed sendBulkSMSResponse
141
      * @return object
142
      */
143
      public function sendBulkSMSResponse()
144
      {
145
         $response = new StdClass;
146
         $response->status = 'Submitted';
147
         $response->bulk_message_id = $this->getValidBulkMessageID();
148
         $response->request_speed = 0.05;
149
 
150
         return $response;
151
      }
152
153
     /**
154
      * Stubbed checkAvailableCreditsResponse
155
      * @return object
156
      */
157
     public function checkAvailableCreditsResponse()
158
     {
159
        $response = new StdClass;
160
        $response->sms_credits = 200;
161
162
        return $response;
163
     }
164
165
     /**
166
      * Stubbed correct Payload
167
      * @return array
168
      */
169
     public function correctPayload()
170
     {
171
        $message  = "I LOVE YOU, BABY";
172
173
        return [
174
            'to' => '8038142771',
175
            'from' => 'TEST JUSIBE',
176
            'message' => $message
177
        ];
178
     }
179
180
     /**
181
      * Get Invalid Access Token
182
      * @return string
183
      */
184
     public function getInvalidAccessToken()
185
     {
186
        return getenv('INVALID_ACCESS_TOKEN');
187
     }
188
189
     /**
190
      * Get Valid Public Key
191
      * @return string
192
      */
193
     public function getValidPublicKey()
194
     {
195
        return getenv('VALID_PUBLIC_KEY');
196
     }
197
198
     /**
199
      * Get Valid Public Key
200
      * @return string
201
      */
202
     public function getInvalidPublicKey()
203
     {
204
        return getenv('INVALID_PUBLIC_KEY');
205
     }
206
}
207
208
209