Issues (6)

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/Sms.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 LeadThread\Sms;
4
5
use Config;
6
use LeadThread\Sms\Exceptions\InvalidPhoneNumberException;
7
use LeadThread\Sms\Factories\DriverFactory;
8
use LeadThread\Sms\Factories\SearchFactory;
9
use LeadThread\Sms\Interfaces\PhoneSearchParams;
10
use LeadThread\Sms\Interfaces\SendsSms;
11
use LeadThread\Sms\Search\Search;
12
13
class Sms
14
{
15
    protected $driver;
16
    protected $config;
17
18 33
    public function __construct(SendsSms $driver = null)
19
    {
20 33
        $this->config = (class_exists("Config") ? Config::get('sms') : []);
21 33
        $this->driver = $this->getDriver($driver);
22 33
    }
23
24
    /**
25
     * Returns a SMS driver instance
26
     * @param  mixed $driver An existing SMS driver instance to use
27
     * @return \LeadThread\Sms\Interfaces\SendsSms
28
     */
29 33
    protected function getDriver($driver = null)
30
    {
31 33
        if (!$driver instanceof SendsSms) {
32 6
            $factory = new DriverFactory;
33 6
            $driver = $factory->get($this->config['driver']);
0 ignored issues
show
Bug Compatibility introduced by
The expression $factory->get($this->config['driver']); of type LeadThread\Sms\Drivers\SendsSms adds the type LeadThread\Sms\Drivers\SendsSms to the return on line 35 which is incompatible with the return type documented by LeadThread\Sms\Sms::getDriver of type LeadThread\Sms\Interfaces\SendsSms.
Loading history...
34 6
        }
35 33
        return $driver;
36
    }
37
38
    /**
39
     * Sends an SMS message
40
     * @param  string $msg  The message to send
41
     * @param  mixed  $to   The number to send to
42
     * @param  number $from The number to send from
43
     * @return mixed        The response of the message
44
     */
45 27
    public function send($msg, $to, $from = null)
46
    {
47 27
        if (is_array($to)) {
48
            return $this->sendMany($msg, $to, $from);
49
        } else {
50 27
            return $this->driver->send($msg, $to, $from);
0 ignored issues
show
The call to send() misses a required argument $callback.

This check looks for function calls that miss required arguments.

Loading history...
51
        }
52
    }
53
54
    /**
55
     * Sends the same message from the same number to many phone numbers
56
     * @param  string $msg  The message to send
57
     * @param  array  $tos  An array of numbers to send to
58
     * @param  number $from The number to send from
59
     * @return array        An array of responses per number
60
     */
61 9
    public function sendMany($msg, array $tos, $from = null)
62
    {
63 9
        $resp = [];
64 9
        foreach ($tos as $to) {
65 9
            $resp[] = $this->send($msg, $to, $from);
66 9
        }
67 9
        return $resp;
68
    }
69
70
    /**
71
     * An array of SMS items to send
72
     * @param  array $data Must contain msg, to, and from keys per item
73
     * @return array       An array of responses per item
74
     */
75 9
    public function sendArray(array $data)
76
    {
77 9
        $resp = [];
78 9
        foreach ($data as $item) {
79 9
            $resp[] = $this->send($item['msg'], $item['to'], $item['from']);
80 9
        }
81 9
        return $resp;
82
    }
83
84
    protected function getSearchParams($search)
85
    {
86
        if (!$search instanceof PhoneSearchParams) {
87
            $f = new SearchFactory();
88
            return $f->get($this->config["driver"], $search);
89
        }
90
        return $search;
91
    }
92
93
    /**
94
     * Searches for a number and then purchases the first one it finds
95
     * @param  array $search Array of search options
96
     * @return \LeadThread\Sms\Responses\Response
97
     */
98
    public function searchAndBuyNumber($search)
99
    {
100
        return $this->driver->searchAndBuyNumber($this->getSearchParams($search));
101
    }
102
103
    public function searchNumber($search)
104
    {
105
        return $this->driver->searchNumber($this->getSearchParams($search));
106
    }
107
108
    public function buyNumber($number)
109
    {
110
        return $this->driver->buyNumber($number);
111
    }
112
113
    public function sellNumber($number)
114
    {
115
        return $this->driver->sellNumber($number);
116
    }
117
}
118