Issues (43)

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/SimpleUPS/Rates/Request.php (4 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 namespace SimpleUPS\Rates;
2
3
use \SimpleUPS\Api\MissingParameterException;
4
5
use \SimpleUPS\UPS;
6
7
/**
8
 * @internal
9
 * @since 1.0
10
 */
11
class Request extends \SimpleUPS\Api\Request
12
{
13
    private
14
        /* @var string $pickupType */
15
        $pickupType = PickupType::DAILY_PICKUP,
16
        /* @var string $rateType */
17
        $rateType,
18
19
        /* @var Shipment $shipment */
20
        $shipment;
21
22
    public function __construct()
23
    {
24
        parent::__construct();
25
26
        $this->responseClass = '\SimpleUPS\Rates\Response';
27
    }
28
29
    /**
30
     * Determine which API call will be made
31
     * @internal
32
     * @return string
33
     */
34
    public function getUrl()
35
    {
36
        return $this->getDebug() ? 'https://wwwcie.ups.com/ups.app/xml/Rate' : 'https://onlinetools.ups.com/ups.app/xml/Rate';
37
    }
38
39
    /**
40
     * Build the validate address request
41
     * @internal
42
     * @return string
43
     * @throws \SimpleUPS\Api\MissingParameterException
44
     */
45
    public function buildXml()
46
    {
47
        if ($this->getShipment()->getDestination() == null) {
48
            throw new MissingParameterException('Shipment destination is missing');
49
        }
50
51
        $dom = new \DomDocument('1.0');
52
        $dom->formatOutput = $this->getDebug();
53
        $dom->appendChild($ratingRequest = $dom->createElement('RatingServiceSelectionRequest'));
54
        $addressRequestLang = $dom->createAttribute('xml:lang');
55
        $addressRequestLang->value = parent::getXmlLang();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getXmlLang() instead of buildXml()). Are you sure this is correct? If so, you might want to change this to $this->getXmlLang().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
56
        $ratingRequest->appendChild($request = $dom->createElement('Request'));
57
        $request->appendChild($transactionReference = $dom->createElement('TransactionReference'));
58
        $transactionReference->appendChild($dom->createElement('CustomerContext', $this->getCustomerContext()));
59
60
        $request->appendChild($dom->createElement('RequestAction', 'Rate'));
61
        $request->appendChild(
62
            $dom->createElement('RequestOption', 'Shop')
63
        ); //@todo test with "Rate" as setting to determine difference
64
65
        $ratingRequest->appendChild($pickupType = $dom->createElement('PickupType'));
66
        $pickupType->appendChild($shipmentType = $dom->createElement('Code', $this->getPickupType()));
67
68
        if ($this->getRateType() != null) {
69
            $ratingRequest->appendChild($customerClassification = $dom->createElement('CustomerClassification'));
70
            $customerClassification->appendChild($dom->createElement('Code', $this->getRateType()));
71
        }
72
        // Shipment
73
        $shipment = $this->getShipment();
74
        $shipment->setShipper(UPS::getShipper());
75
76
        $ratingRequest->appendChild($shipment->toXml($dom));
77
        $xml = parent::buildAuthenticationXml() . $dom->saveXML();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (buildAuthenticationXml() instead of buildXml()). Are you sure this is correct? If so, you might want to change this to $this->buildAuthenticationXml().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
78
79
        return $xml;
80
    }
81
82
    /**
83
     * How the shipment will be picked up
84
     * Default value is PickupType::DAILY_PICKUP
85
     * @see PickupType
86
     *
87
     * @param string $pickupType
88
     *
89
     * @throws \SimpleUPS\Api\InvalidParameterException
90
     * @return Request
91
     */
92 View Code Duplication
    public function setPickupType($pickupType)
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...
93
    {
94
        $reflectionClass = new \ReflectionClass('SimpleUPS\Rates\PickupType');
95
        if (!in_array($pickupType, $reflectionClass->getConstants())) {
96
            throw new \SimpleUPS\Api\InvalidParameterException(
97
                'PickupType is invalid, refer to SimpleUPS\Rates\PickupType for valid pickup types'
98
            );
99
        }
100
101
        $this->pickupType = $pickupType;
102
        return $this;
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    private function getPickupType()
109
    {
110
        return $this->pickupType;
111
    }
112
113
    /**
114
     * How the shipment will be quoted
115
     * Defaults:
116
     * <ul>
117
     *  <li>RateType::DAILY_RATES when pickup type is PickupType::DAILY_PICKUP</li>
118
     *  <li>RateType::RETAIL_RATES when pickup type is PickupType::ONE_TIME_PICKUP, PickupType::ON_CALL_AIR, PickupType::LETTER_CENTER or PickupType::AIR_SERVICE_CENTER</li>
119
     * </ul>
120
     * @see PickupType
121
     * @see RateType
122
     *
123
     * @param string $rateType
124
     *
125
     * @throws \SimpleUPS\Api\InvalidParameterException
126
     * @return Request
127
     */
128 View Code Duplication
    public function setRateType($rateType)
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...
129
    {
130
        $reflectionClass = new \ReflectionClass('SimpleUPS\Rates\RateType');
131
        if (!in_array($rateType, $reflectionClass->getConstants())) {
132
            throw new \SimpleUPS\Api\InvalidParameterException(
133
                'RateType is invalid, refer to SimpleUPS\Rates\RateType for valid rate types'
134
            );
135
        }
136
137
        $this->rateType = $rateType;
138
        return $this;
139
    }
140
141
    /**
142
     * @return string
143
     */
144
    private function getRateType()
145
    {
146
        return $this->rateType;
147
    }
148
149
    /**
150
     * @param Shipment $shipment
151
     *
152
     * @return Request
153
     */
154
    public function setShipment(Shipment $shipment)
155
    {
156
        $this->shipment = $shipment;
157
        return $this;
158
    }
159
160
    /**
161
     * @return Shipment
162
     */
163
    public function getShipment()
164
    {
165
        return $this->shipment;
166
    }
167
}