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.

code/forms/fields/OrderStepField.php (5 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 field shows the admin (and maybe the customer) where the Order is at (which orderstep).
6
 *
7
 * @authors: Nicolaas [at] Sunny Side Up .co.nz
8
 * @package: ecommerce
9
 * @sub-package: forms
10
 * @inspiration: Silverstripe Ltd, Jeremy
11
 **/
12
class OrderStepField extends DatalessField
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $content;
18
19
    /**
20
     * @param string $name
21
     * @param Order  $order
22
     * @param Member $member
0 ignored issues
show
Should the type for parameter $member not be null|Member?

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...
23
     */
24
    public function __construct($name, Order $order, Member $member = null)
25
    {
26
        if (!$member) {
27
            $member = $order->Member();
0 ignored issues
show
The method Member() does not exist on Order. Did you maybe mean CreateOrReturnExistingMember()?

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...
28
        }
29
        if (!$member) {
30
            $member = new Member();
31
        }
32
        $orderSteps = OrderStep::get();
33
        $where = '"HideStepFromCustomer" = 0';
0 ignored issues
show
$where is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
34
        $currentStep = $order->CurrentStepVisibleToCustomer();
0 ignored issues
show
$currentStep is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
35
        if ($member->IsShopAdmin()) {
36
            $currentStep = $order->MyStep();
37
        } else {
38
            $currentStep = $order->CurrentStepVisibleToCustomer();
39
            $orderSteps = $orderSteps
40
                ->filter(array('HideStepFromCustomer' => 0));
41
        }
42
        $future = false;
43
        $html = '
44
        <div class="orderStepField">
45
            <ol>';
46
        if ($orderSteps->count()) {
47
            foreach ($orderSteps as $orderStep) {
48
                if ($orderStep->HideFromEveryone()) {
49
                    continue;
50
                }
51
                $description = '';
52
                if ($member->IsShopAdmin()) {
53
                    if ($orderStep->Description) {
54
                        $description = ' title="'.Convert::raw2att($orderStep->Description).'" ';
55
                    }
56
                }
57
                $class = '';
58
                if ($orderStep->ID == $currentStep->ID) {
59
                    $future = true;
60
                    $class .= ' current';
61
                } elseif ($future) {
62
                    $class .= ' todo';
63
                } else {
64
                    $class .= ' done';
65
                }
66
                $html .= '<li class="'.$class.'" '.$description.'><a href="'.$orderStep->CMSEditLink().'">'.$orderStep->Title.'</a></li>';
67
            }
68
        } else {
69
            $html .= 'no steps';
70
        }
71
        $html .= '</ol><div class="clear"></div></div>';
72
        $this->content = $html;
73
        Requirements::themedCSS('OrderStepField', 'ecommerce');
74
        parent::__construct($name);
75
    }
76
77
    /**
78
     * standard SS method.
79
     *
80
     * @param array $properties
81
     *
82
     * @return HTML
83
     */
84
    public function FieldHolder($properties = array())
85
    {
86
        return is_object($this->content) ? $this->content->forTemplate() : $this->content;
87
    }
88
89
    /**
90
     * standard SS method.
91
     *
92
     * @param array $properties
93
     *
94
     * @return HTML
95
     */
96
    public function Field($properties = array())
97
    {
98
        return $this->FieldHolder();
99
    }
100
101
    /**
102
     * Sets the content of this field to a new value.
103
     *
104
     * @param string $content
105
     */
106
    public function setContent($content)
107
    {
108
        $this->content = $content;
109
    }
110
111
    /**
112
     * @return string
113
     */
114
    public function getContent()
115
    {
116
        return $this->content;
117
    }
118
119
    /**
120
     * Synonym of {@link setContent()} so that LiteralField is more compatible with other field types.
121
     *
122
     * @param mixed
123
     */
124
    public function setValue($value)
125
    {
126
        return $this->setContent($value);
127
    }
128
129
    /**
130
     * standard SS method.
131
     *
132
     * @return Field
0 ignored issues
show
Should the return type not be OrderStepField?

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...
133
     */
134
    public function performReadonlyTransformation()
135
    {
136
        $clone = clone $this;
137
        $clone->setReadonly(true);
138
139
        return $clone;
140
    }
141
}
142