Issues (41)

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.

src/CartPositionTrait.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
3
/*
4
 * Cart module for Yii2
5
 *
6
 * @link      https://github.com/hiqdev/yii2-cart
7
 * @package   yii2-cart
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hiqdev\yii2\cart;
13
14
use Yii;
15
use yii\base\Model;
16
use yii\grid\GridView;
17
use yii\helpers\Html;
18
19
/**
20
 * CartPositionTrait trait
21
 * It is intended to be used in classes implementing [[CartPositionInterface]].
22
 * Holds:
23
 * - object (model) and ID.
24
 * - name and description
25
 * Provides:
26
 * - icon with getIcon() to be redefined in childs
27
 */
28
trait CartPositionTrait
29
{
30
    use \yz\shoppingcart\CartPositionTrait;
31
32
    /**
33
     * @var Model object being put in cart
34
     */
35
    protected $_model;
36
37
    /**
38
     * @var string|int ID of object being put in cart
39
     */
40
    protected $_id;
41
42
    public function rules()
43
    {
44
        return [
45
            [['model_id'], 'integer', 'min' => 1],
46
            [['name', 'description', 'parent_id'], 'string'],
47
        ];
48
    }
49
50
    public function attributeLabels()
51
    {
52
        return [
53
            'model_id' => Yii::t('cart', 'ID'),
54
            'name' => Yii::t('cart', 'Name'),
55
            'price' => Yii::t('cart', 'Price'),
56
            'quantity' => Yii::t('cart', 'Quantity'),
57
            'description' => Yii::t('cart', 'Description'),
58
        ];
59
    }
60
61
    public function attributes()
62
    {
63
        return [
64
            'model_id',
65
            'parent_id',
66
            'name',
67
            'quantity',
68
            'description',
69
        ];
70
    }
71
72
    /**
73
     * This closure will be called in [[GridView::rowOptions]].
74
     *
75
     * @param integer $key the key value associated with the current data model
76
     * @param integer $index the zero-based index of the data model in the model array returned by [[dataProvider]]
77
     * @param GridView $grid the GridView object
78
     * @return array
79
     */
80
    public function getRowOptions($key, $index, $grid)
81
    {
82
        return [];
83
    }
84
85
    public function getIcon()
86
    {
87
        return '<i class="fa fa-check"></i>';
88
    }
89
90
    public function getName()
91
    {
92
        return $this->name;
0 ignored issues
show
The property name does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
93
    }
94
95
    public function getDescription()
96
    {
97
        return $this->description;
0 ignored issues
show
The property description does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
98
    }
99
100
    public function renderDescription()
101
    {
102
        return $this->getIcon() . ' ' . $this->getName() . ' ' . Html::tag('span', $this->getDescription(), ['class' => 'text-muted']);
103
    }
104
105
    public function getAdditionalLinks(): array
106
    {
107
        return [];
108
    }
109
110
    public function getRelatedPositions(): array
111
    {
112
        return [];
113
    }
114
115
    public function hasParent(): bool
116
    {
117
        return !empty($this->parent_id);
0 ignored issues
show
The property parent_id does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
118
    }
119
120
    public function getModel(): ?Model
121
    {
122
        return $this->_model;
123
    }
124
125
    public function setModel(Model $model): void
126
    {
127
        $this->_model = $model;
128
    }
129
}
130