Issues (6)

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/Http/Clients/JetSmsXmlClient.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
namespace Erdemkeren\JetSms\Http\Clients;
4
5
use Erdemkeren\JetSms\ShortMessage;
6
use Erdemkeren\JetSms\ShortMessageCollection;
7
use Erdemkeren\JetSms\Http\Responses\JetSmsXmlResponse;
8
use Erdemkeren\JetSms\Http\Responses\JetSmsResponseInterface;
9
10
/**
11
 * Class JetSmsXmlClient.
12
 */
13
class JetSmsXmlClient implements JetSmsClientInterface
14
{
15
    /**
16
     * The JetSms xml request url.
17
     *
18
     * @var string
19
     */
20
    private $url;
21
22
    /**
23
     * The auth username.
24
     *
25
     * @var string
26
     */
27
    private $username;
28
29
    /**
30
     * The auth password.
31
     *
32
     * @var string
33
     */
34
    private $password;
35
36
    /**
37
     * The outbox name.
38
     *
39
     * @var string
40
     */
41
    private $outboxName;
42
43
    /**
44
     * XmlJetSmsClient constructor.
45
     *
46
     * @param string $url
47
     * @param string $username
48
     * @param string $password
49
     * @param string $outboxName
50
     */
51 2 View Code Duplication
    public function __construct($url, $username, $password, $outboxName)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53 2
        $this->url = $url;
54 2
        $this->username = $username;
55 2
        $this->password = $password;
56 2
        $this->outboxName = $outboxName;
57 2
    }
58
59
    /**
60
     * Send a short message using the JetSms services.
61
     *
62
     * @param  ShortMessage $shortMessage
63
     *
64
     * @return JetSmsResponseInterface
65
     */
66 1
    public function sendShortMessage(ShortMessage $shortMessage)
67
    {
68 1
        $payload = $this->generateSingleMessageBody($shortMessage);
69
70 1
        return new JetSmsXmlResponse($this->performCurlSession($payload));
71
    }
72
73
    /**
74
     * Send multiple short messages using the JetSms services.
75
     *
76
     * @param  ShortMessageCollection $shortMessageCollection
77
     *
78
     * @return JetSmsResponseInterface
79
     */
80 1
    public function sendShortMessages(ShortMessageCollection $shortMessageCollection)
81
    {
82 1
        $payload = $this->generateMultipleMessageBody($shortMessageCollection);
83
84 1
        return new JetSmsXmlResponse($this->performCurlSession($payload));
85
    }
86
87
    /**
88
     * Generate the xml http request body.
89
     *
90
     * @param  ShortMessage $shortMessage
91
     *
92
     * @return string
93
     */
94 1
    private function generateSingleMessageBody(ShortMessage $shortMessage)
95
    {
96 1
        $body = '<?xml version="1.0" encoding="iso-8859-9"?>';
97 1
        $body .= '<message-context type="smmgsd">';
98 1
        $body .= $this->generateAuthTags();
99 1
        $body .= $this->generateValidityRangeTags();
100 1
        $body .= $shortMessage->toSingleMessageXml();
101 1
        $body .= '</message-context>';
102
103 1
        return $body;
104
    }
105
106
    /**
107
     * Generate the xml http request body.
108
     *
109
     * @param  ShortMessageCollection $shortMessageCollection
110
     *
111
     * @return string
112
     */
113 1
    private function generateMultipleMessageBody(ShortMessageCollection $shortMessageCollection)
114
    {
115 1
        $body = '<?xml version="1.0" encoding="iso-8859-9"?>';
116 1
        $body .= '<message-context type="mmmgsd">';
117 1
        $body .= $this->generateAuthTags();
118 1
        $body .= $this->generateValidityRangeTags();
119 1
        $body .= $shortMessageCollection->toXml();
120 1
        $body .= '</message-context>';
121
122 1
        return $body;
123
    }
124
125 2
    private function generateValidityRangeTags()
126
    {
127 2
        return '<start-date></start-date><expire-date></expire-date>';
128
    }
129
130
    /**
131
     * Get the auth credentials as xml tags.
132
     *
133
     * @return string
134
     */
135 2
    private function generateAuthTags()
136
    {
137 2
        return "<username>{$this->username}</username>"
138 2
            . "<password>{$this->password}</password>"
139 2
            . "<outbox-name>{$this->outboxName}</outbox-name>";
140
    }
141
142
    /**
143
     * Perform the curl session.
144
     *
145
     * @param  string $payload
146
     *
147
     * @return string
148
     */
149 2
    private function performCurlSession($payload)
150
    {
151 2
        $perCurlConnection = curl_init();
152 2
        curl_setopt($perCurlConnection, CURLOPT_URL, $this->url);
153 2
        curl_setopt($perCurlConnection, CURLOPT_RETURNTRANSFER, 1);
154 2
        curl_setopt($perCurlConnection, CURLOPT_TIMEOUT, 10);
155 2
        curl_setopt($perCurlConnection, CURLOPT_POSTFIELDS, $payload);
156
157 2
        $result = curl_exec($perCurlConnection);
158
159 2
        return $result;
160
    }
161
}
162