Issues (194)

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/Bpost/Order/Customer.php (3 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
namespace Bpost\BpostApiClient\Bpost\Order;
3
4
use Bpost\BpostApiClient\Exception\BpostLogicException\BpostInvalidLengthException;
5
6
/**
7
 * bPost Customer class
8
 *
9
 * @author Tijs Verkoyen <[email protected]>
10
 */
11
class Customer
12
{
13
    const TAG_NAME = 'customer';
14
15
    /**
16
     * @var string
17
     */
18
    private $name;
19
20
    /**
21
     * @var string
22
     */
23
    private $company;
24
25
    /**
26
     * @var Address
27
     */
28
    private $address;
29
30
    /**
31
     * @var string
32
     */
33
    private $emailAddress;
34
35
    /**
36
     * @var string
37
     */
38
    private $phoneNumber;
39
40
    /**
41
     * @param \Bpost\BpostApiClient\Bpost\Order\Address $address
42
     */
43 12
    public function setAddress($address)
44
    {
45 12
        $this->address = $address;
46 12
    }
47
48
    /**
49
     * @return \Bpost\BpostApiClient\Bpost\Order\Address
50
     */
51 10
    public function getAddress()
52
    {
53 10
        return $this->address;
54
    }
55
56
    /**
57
     * @param string $company
58
     */
59 12
    public function setCompany($company)
60
    {
61 12
        $this->company = $company;
62 12
    }
63
64
    /**
65
     * @return string
66
     */
67 12
    public function getCompany()
68
    {
69 12
        return $this->company;
70
    }
71
72
    /**
73
     * @param string $emailAddress
74
     * @throws BpostInvalidLengthException
75
     */
76 15 View Code Duplication
    public function setEmailAddress($emailAddress)
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...
77
    {
78 15
        $length = 50;
79 15
        if (mb_strlen($emailAddress) > $length) {
80 3
            throw new BpostInvalidLengthException('emailAddress', mb_strlen($emailAddress), $length);
81
        }
82 12
        $this->emailAddress = $emailAddress;
83 12
    }
84
85
    /**
86
     * @return string
87
     */
88 10
    public function getEmailAddress()
89
    {
90 10
        return $this->emailAddress;
91
    }
92
93
    /**
94
     * @param string $name
95
     */
96 12
    public function setName($name)
97
    {
98 12
        $this->name = $name;
99 12
    }
100
101
    /**
102
     * @return string
103
     */
104 10
    public function getName()
105
    {
106 10
        return $this->name;
107
    }
108
109
    /**
110
     * @param string $phoneNumber
111
     * @throws BpostInvalidLengthException
112
     */
113 15 View Code Duplication
    public function setPhoneNumber($phoneNumber)
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...
114
    {
115 15
        $length = 20;
116 15
        if (mb_strlen($phoneNumber) > $length) {
117 3
            throw new BpostInvalidLengthException('phoneNumber', mb_strlen($phoneNumber), $length);
118
        }
119 12
        $this->phoneNumber = $phoneNumber;
120 12
    }
121
122
    /**
123
     * @return string
124
     */
125 10
    public function getPhoneNumber()
126
    {
127 10
        return $this->phoneNumber;
128
    }
129
130
    /**
131
     * Return the object as an array for usage in the XML
132
     *
133
     * @param \DomDocument $document
134
     * @param  string      $prefix
0 ignored issues
show
Should the type for parameter $prefix not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
135
     * @return \DomElement
136
     */
137 9
    public function toXML(\DomDocument $document, $prefix = null)
138
    {
139 9
        $tagName = static::TAG_NAME;
140 9
        if ($prefix !== null) {
141 3
            $tagName = $prefix . ':' . $tagName;
142 3
        }
143
144 9
        $customer = $document->createElement($tagName);
145
146 9
        if ($this->getName() !== null) {
147 9
            $customer->appendChild(
148 9
                $document->createElement(
149 9
                    'common:name',
150 9
                    $this->getName()
151 9
                )
152 9
            );
153 9
        }
154 9
        if ($this->getCompany() !== null) {
155 9
            $customer->appendChild(
156 9
                $document->createElement(
157 9
                    'common:company',
158 9
                    $this->getCompany()
159 9
                )
160 9
            );
161 9
        }
162 9
        if ($this->getAddress() !== null) {
163 9
            $customer->appendChild(
164 9
                $this->getAddress()->toXML($document)
165 9
            );
166 9
        }
167 9
        if ($this->getEmailAddress() !== null) {
168 9
            $customer->appendChild(
169 9
                $document->createElement(
170 9
                    'common:emailAddress',
171 9
                    $this->getEmailAddress()
172 9
                )
173 9
            );
174 9
        }
175 9
        if ($this->getPhoneNumber() !== null) {
176 9
            $customer->appendChild(
177 9
                $document->createElement(
178 9
                    'common:phoneNumber',
179 9
                    $this->getPhoneNumber()
180 9
                )
181 9
            );
182 9
        }
183
184 9
        return $customer;
185
    }
186
187
    /**
188
     * @param  \SimpleXMLElement $xml
189
     * @param  Customer          $instance
190
     *
191
     * @return Customer
192
     * @throws BpostInvalidLengthException
193
     */
194 3
    public static function createFromXMLHelper(\SimpleXMLElement $xml, Customer $instance)
195
    {
196 3
        if (isset($xml->name) && $xml->name != '') {
197 3
            $instance->setName((string) $xml->name);
198 3
        }
199 3
        if (isset($xml->company) && $xml->company != '') {
200 3
            $instance->setCompany((string) $xml->company);
201 3
        }
202 3
        if (isset($xml->address)) {
203 3
            $instance->setAddress(
204 3
                Address::createFromXML($xml->address)
205 3
            );
206 3
        }
207 3
        if (isset($xml->emailAddress) && $xml->emailAddress != '') {
208 3
            $instance->setEmailAddress(
209 3
                (string) $xml->emailAddress
210 3
            );
211 3
        }
212 3
        if (isset($xml->phoneNumber) && $xml->phoneNumber != '') {
213 3
            $instance->setPhoneNumber((string) $xml->phoneNumber);
214 3
        }
215
216 3
        return $instance;
217
    }
218
}
219