This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | * This call can be used when you need input from the customer |
||
5 | * in the order process. |
||
6 | * |
||
7 | * To use |
||
8 | * |
||
9 | * 1. create class that extends OrderStepController |
||
10 | * 2. make sure the class has a $url_segment static var |
||
11 | * 3. create content and/or form for page |
||
12 | * 4. make sure you set up route (route.yml) to get to the |
||
13 | */ |
||
14 | abstract class OrderStepController extends Controller |
||
15 | { |
||
16 | private static $allowed_actions = array( |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
![]() |
|||
17 | 'error' => true, |
||
18 | ); |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $alternativeContent = ""; |
||
24 | |||
25 | /** |
||
26 | * when no action is selected |
||
27 | * this action runs... |
||
28 | */ |
||
29 | public function index($request) |
||
0 ignored issues
–
show
|
|||
30 | { |
||
31 | $this->alternativeContent = '<p class="message bad">Sorry, we can not find the page you are looking for.</p>'; |
||
32 | |||
33 | return $this->renderWith('Page'); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * there is an error ... |
||
38 | */ |
||
39 | public function error($request) |
||
0 ignored issues
–
show
|
|||
40 | { |
||
41 | $this->alternativeContent = '<p class="message bad">Sorry, an error occurred, please contact us for more information....</p>'; |
||
42 | |||
43 | return $this->renderWith('Page'); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return string |
||
48 | */ |
||
49 | protected static function name_of_controller_class() |
||
50 | { |
||
51 | return get_called_class(); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @param Order $order |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | protected static function secure_hash($order) |
||
60 | { |
||
61 | $obj = Injector::inst()->get(self::name_of_controller_class()); |
||
62 | |||
63 | return $obj->secureHash($order); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | protected function nameOfControllerClass() |
||
70 | { |
||
71 | return self::name_of_controller_class(); |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * related OrderStatusLog class. |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | abstract protected function nameOfLogClass(); |
||
80 | |||
81 | /** |
||
82 | * main content ... |
||
83 | * |
||
84 | * @return string |
||
0 ignored issues
–
show
|
|||
85 | */ |
||
86 | public function Content($order = null) |
||
87 | { |
||
88 | if ($this->alternativeContent) { |
||
89 | return $this->alternativeContent; |
||
90 | } |
||
91 | return $this->standardContent($order); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @return string ($html) |
||
0 ignored issues
–
show
|
|||
96 | */ |
||
97 | protected function standardContent($order = null) |
||
0 ignored issues
–
show
|
|||
98 | { |
||
99 | user_error("Make sure to put some content here in classes that extend ".$this->class); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * the form on the field. |
||
104 | * |
||
105 | * @return Form |
||
106 | */ |
||
107 | protected function Form() |
||
108 | { |
||
109 | return $this->Form; |
||
0 ignored issues
–
show
The property
Form does not exist on object<OrderStepController> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?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. ![]() |
|||
110 | } |
||
111 | |||
112 | /** |
||
113 | * code of related order step. |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | abstract protected function codeOfRelevantOrderStep(); |
||
118 | |||
119 | /** |
||
120 | * used to secure page. |
||
121 | * |
||
122 | * @param Order $order |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | abstract protected function secureHash($order); |
||
127 | |||
128 | /** |
||
129 | * @oaram string $action |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | public function Link($action = null) |
||
134 | { |
||
135 | $link = '/'.Config::inst()->get($this->nameOfControllerClass(), 'url_segment').'/'; |
||
136 | if ($action) { |
||
137 | $link = $link.$action.'/'; |
||
138 | } |
||
139 | |||
140 | return $link.$this->getOrderGetParams(); |
||
141 | } |
||
142 | |||
143 | public function errorLink() |
||
144 | { |
||
145 | return $this->Link('error'); |
||
146 | } |
||
147 | |||
148 | /** |
||
149 | * is the order valid? |
||
150 | * |
||
151 | * @return bool |
||
152 | */ |
||
153 | protected function checkOrder($dataOrRequest = null) |
||
154 | { |
||
155 | $order = $this->Order($dataOrRequest); |
||
156 | if ($order && $order->exists()) { |
||
0 ignored issues
–
show
|
|||
157 | return true; |
||
158 | } else { |
||
159 | return false; |
||
160 | } |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * @var Order |
||
165 | */ |
||
166 | private static $_order = null; |
||
167 | |||
168 | /** |
||
169 | * finds the order ... |
||
170 | * |
||
171 | * @param mixed |
||
172 | * |
||
173 | * @return Order |
||
0 ignored issues
–
show
|
|||
174 | */ |
||
175 | protected function Order($dataOrRequest = null) |
||
176 | { |
||
177 | if (!self::$_order) { |
||
178 | if ( |
||
179 | is_array($dataOrRequest) && |
||
180 | isset($dataOrRequest['OrderID']) && |
||
181 | isset($dataOrRequest['OrderSessionID']) |
||
182 | ) { |
||
183 | $id = intval($dataOrRequest['OrderID']); |
||
184 | $sessionID = Convert::raw2sql($dataOrRequest['OrderSessionID']); |
||
185 | } elseif (isset($_POST['OrderID']) && isset($_POST['OrderSessionID'])) { |
||
186 | $id = intval($_POST['OrderID']); |
||
187 | $sessionID = Convert::raw2sql($_POST['OrderSessionID']); |
||
188 | } elseif (isset($_GET['OrderID']) && isset($_GET['OrderSessionID'])) { |
||
189 | $id = intval($_GET['OrderID']); |
||
190 | $sessionID = Convert::raw2sql($_GET['OrderSessionID']); |
||
191 | } elseif ($dataOrRequest instanceof SS_HTTPRequest) { |
||
192 | $id = intval($dataOrRequest->param('ID')); |
||
193 | $sessionID = Convert::raw2sql($dataOrRequest->param('OtherID')); |
||
194 | } else { |
||
195 | $id = intval($this->request->param('ID')); |
||
196 | $sessionID = Convert::raw2sql($this->request->param('OtherID')); |
||
197 | } |
||
198 | self::$_order = Order::get()->byID($id); |
||
0 ignored issues
–
show
It seems like
\Order::get()->byID($id) can also be of type object<DataObject> . However, the property $_order is declared as type object<Order> . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||
199 | if (self::$_order) { |
||
200 | if ($this->secureHash(self::$_order) != $sessionID) { |
||
0 ignored issues
–
show
self::$_order of type object<DataObject> is not a sub-type of object<Order> . It seems like you assume a child class of the class DataObject to be always present.
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass. Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type. ![]() |
|||
201 | self::$_order = null; |
||
202 | } |
||
203 | } |
||
204 | } |
||
205 | |||
206 | return self::$_order; |
||
207 | } |
||
208 | |||
209 | /** |
||
210 | * @return string |
||
0 ignored issues
–
show
|
|||
211 | */ |
||
212 | protected function getOrderGetParams() |
||
213 | { |
||
214 | if ($order = $this->Order()) { |
||
215 | return '?OrderID='.$order->ID.'&OrderSessionID='.self::secure_hash($order); |
||
216 | } |
||
217 | } |
||
218 | |||
219 | /** |
||
220 | * @return OrderStep |
||
221 | */ |
||
222 | protected function orderStep() |
||
223 | { |
||
224 | return DataObject::get_one( |
||
225 | 'OrderStep', |
||
226 | array('Code' => $this->codeOfRelevantOrderStep()) |
||
227 | ); |
||
228 | } |
||
229 | } |
||
230 |