Issues (426)

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/models/TariffProfile.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
 * Finance module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-finance
6
 * @package   hipanel-module-finance
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\finance\models;
12
13
use Yii;
14
15
/**
16
 * Class Tariff.
17
 * @property resource[]|DomainResource[]|ServerResource[] $resources
18
 */
19
class TariffProfile extends \hipanel\base\Model
20
{
21
    use \hipanel\base\ModelTrait;
22
23
    public static function tableName()
24
    {
25
        return 'tariffprofile';
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function rules()
32
    {
33
        $main = [
34
            [['name'], 'safe'],
35
            [
36
                ['name'],
37
                'required',
38
                'on' => ['update', 'create'],
39
                'when' => function ($model) {
40
                    return !$model->isDefault();
41
                },
42
            ],
43
            [['id'], 'integer'],
44
            [['id'], 'required', 'on' => ['update', 'delete']],
45
            [['tariff_names'], 'safe'],
46
            [['seller_id', 'client_id'], 'integer'],
47
            [['seller', 'client', 'items'], 'safe'],
48
            [['tariffs'], 'safe'],
49
        ];
50
51
        $tariffTypes = [Tariff::TYPE_DOMAIN, Tariff::TYPE_CERT, Tariff::TYPE_XEN, Tariff::TYPE_OPENVZ, Tariff::TYPE_SERVER];
52
        foreach ($tariffTypes as $type) {
53
            if (in_array($type, [Tariff::TYPE_DOMAIN, Tariff::TYPE_CERT], true)) {
54
                $main[] = [[$type], 'integer'];
55
            } else {
56
                $main[] = [[$type], 'filter', 'filter' => function ($value) { return explode(',', $value); }];
57
                $main[] = [[$type], 'each', 'rule' => ['trim'], 'on' => ['update', 'create']];
58
                $main[] = [[$type], 'each', 'rule' => ['integer'], 'on' => ['update', 'create']];
59
            }
60
        }
61
62
        return $main;
63
    }
64
65
    public function beforeValidate()
66
    {
67
        foreach ([Tariff::TYPE_XEN, Tariff::TYPE_OPENVZ, Tariff::TYPE_SERVER] as $attribute) {
68
            if (empty($this->$attribute)) {
69
                continue;
70
            }
71
            $this->$attribute = reset($this->$attribute);
72
        }
73
74
        return parent::beforeValidate();
75
    }
76
77
    /**
78
     * {@inheritdoc}
79
     */
80
    public function attributeLabels()
81
    {
82
        return $this->mergeAttributeLabels([
83
            'name' => Yii::t('hipanel.finance.tariffprofile', 'Name'),
84
            'tariff_names' => Yii::t('hipanel.finance.tariffprofile', 'Tariffs'),
85
            'domain' => Yii::t('hipanel.finance.tariffprofile', 'Domain tariff'),
86
            'certificate' => Yii::t('hipanel.finance.tariffprofile', 'Certificate tariff'),
87
            'svds' => Yii::t('hipanel.finance.tariffprofile', 'XEN tariffs'),
88
            'ovds' => Yii::t('hipanel.finance.tariffprofile', 'Open-VZ tariffs'),
89
            'server' => Yii::t('hipanel.finance.tariffprofile', 'Server tariffs'),
90
        ]);
91
    }
92
93
    /**
94
     * Check is model is default profile
95
     *
96
     * @return bool
97
     */
98
    public function isDefault() : bool
99
    {
100
        return (bool) ((string) $this->id === (string) $this->client_id);
0 ignored issues
show
The property id does not exist on object<hipanel\modules\f...e\models\TariffProfile>. 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...
The property client_id does not exist on object<hipanel\modules\f...e\models\TariffProfile>. 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...
101
    }
102
103
    /**
104
     * Human readable title
105
     *
106
     * @return string
107
     */
108
    public function getTitle(): string
109
    {
110
        return $this->isDefault() ? Yii::t('hipanel.finance.tariffprofile', 'Default') : $this->name;
0 ignored issues
show
The property name does not exist on object<hipanel\modules\f...e\models\TariffProfile>. 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...
111
    }
112
}
113