Issues (2002)

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.

model/process/OrderSteps/OrderStep_Created.php (8 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
4
/**
5
 * This is the first Order Step.
6
 *
7
 * @authors: Nicolaas [at] Sunny Side Up .co.nz
8
 * @package: ecommerce
9
 * @sub-package: model
10
 * @inspiration: Silverstripe Ltd, Jeremy
11
 **/
12
class OrderStep_Created extends OrderStep implements OrderStepInterface
13
{
14
    private static $defaults = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
15
        'CustomerCanEdit' => 1,
16
        'CustomerCanPay' => 1,
17
        'CustomerCanCancel' => 1,
18
        'Name' => 'Create',
19
        'Code' => 'CREATED',
20
        'ShowAsUncompletedOrder' => 1,
21
    );
22
23
    /**
24
     *initStep:
25
     * makes sure the step is ready to run.... (e.g. check if the order is ready to be emailed as receipt).
26
     * should be able to run this function many times to check if the step is ready.
27
     *
28
     * @see Order::doNextStatus
29
     *
30
     * @param Order object
31
     *
32
     * @return bool - true if the current step is ready to be run...
33
     **/
34
    public function initStep(Order $order)
35
    {
36
        return true;
37
    }
38
39
    /**
40
     * Add the member to the order, in case the member is not an admin.
41
     *
42
     * @param DataObject - $order Order
43
     *
44
     * @return bool
45
     **/
46
    public function doStep(Order $order)
47
    {
48
        if (!$order->MemberID) {
0 ignored issues
show
The property MemberID does not exist on object<Order>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
49
            $member = Member::currentUser();
50
            if ($member) {
51
                if (!$member->IsShopAdmin()) {
52
                    $order->MemberID = $member->ID();
0 ignored issues
show
The property MemberID does not exist on object<Order>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
53
                    $order->write();
54
                }
55
            }
56
        }
57
58
        return true;
59
    }
60
61
    /**
62
     * We can run the next step, once any items have been added.
63
     *
64
     * @see Order::doNextStatus
65
     *
66
     * @param Order $order
67
     *
68
     * @return OrderStep | Null (next step OrderStep object)
0 ignored issues
show
Should the return type not be OrderStep|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
69
     **/
70
    public function nextStep(Order $order)
71
    {
72
        if ($order->TotalItems($recalculate = true)) {
73
            return parent::nextStep($order);
74
        }
75
76
        return;
77
    }
78
79
    /**
80
     * Allows the opportunity for the Order Step to add any fields to Order::getCMSFields.
81
     *
82
     *@param FieldList $fields
83
     *@param Order $order
84
     *
85
     *@return FieldList
86
     **/
87
    public function addOrderStepFields(FieldList $fields, Order $order)
88
    {
89
        $fields = parent::addOrderStepFields($fields, $order);
90
        if (!$order->IsSubmitted()) {
91
            //LINE BELOW IS NOT REQUIRED
92
            $header = _t('OrderStep.SUBMITORDER', 'Submit Order');
93
            $label = _t('OrderStep.SUBMITNOW', 'Submit Now');
94
            $msg = _t('OrderStep.MUSTDOSUBMITRECORD', '<p>Tick the box below to submit this order.</p>');
95
            $problems = array();
96
            if (!$order->getTotalItems()) {
97
                $problems[] = 'There are no --- Order Items (products) --- associated with this order.';
98
            }
99
            if (!$order->MemberID) {
0 ignored issues
show
The property MemberID does not exist on object<Order>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
100
                $problems[] = 'There is no --- Customer --- associated with this order.';
101
            }
102
            if (!$order->BillingAddressID) {
0 ignored issues
show
The property BillingAddressID does not exist on object<Order>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
103
                $problems[] = 'There is no --- Billing Address --- associated with this order.';
104
            } elseif ($billingAddress = $order->BillingAddress()) {
0 ignored issues
show
The method BillingAddress() does not exist on Order. Did you maybe mean getBillingAddressField()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
105
                $requiredBillingFields = $billingAddress->getRequiredFields();
106
                if ($requiredBillingFields && is_array($requiredBillingFields) && count($requiredBillingFields)) {
107
                    foreach ($requiredBillingFields as $requiredBillingField) {
108
                        if (!$billingAddress->$requiredBillingField) {
109
                            $problems[] = "There is no --- $requiredBillingField --- recorded in the billing address.";
110
                        }
111
                    }
112
                }
113
            }
114
            if (count($problems)) {
115
                $msg = '<p>You can not submit this order because:</p> <ul><li>'.implode('</li><li>', $problems).'</li></ul>';
116
            }
117
            $fields->addFieldToTab('Root.Next', new HeaderField('CreateSubmitRecordHeader', $header, 3), 'ActionNextStepManually');
118
            $fields->addFieldToTab('Root.Next', new LiteralField('CreateSubmitRecordMessage', $msg), 'ActionNextStepManually');
119
            if (!$problems) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $problems of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
120
                $fields->addFieldToTab('Root.Next', new CheckboxField('SubmitOrderViaCMS', $label), 'ActionNextStepManually');
121
            }
122
        }
123
124
        return $fields;
125
    }
126
127
    /**
128
     * Explains the current order step.
129
     *
130
     * @return string
131
     */
132
    protected function myDescription()
133
    {
134
        return _t('OrderStep.CREATED_DESCRIPTION', 'During this step the customer creates her or his order. The shop admininistrator does not do anything during this step.');
135
    }
136
}
137