Issues (434)

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/controllers/TariffController.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
 * 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\controllers;
12
13
use hipanel\actions\ComboSearchAction;
14
use hipanel\actions\IndexAction;
15
use hipanel\actions\SmartDeleteAction;
16
use hipanel\actions\SmartUpdateAction;
17
use hipanel\actions\ValidateFormAction;
18
use hipanel\filters\EasyAccessControl;
19
use hipanel\models\Ref;
20
use hipanel\modules\finance\logic\AbstractTariffManager;
21
use hipanel\modules\finance\logic\CertificateTariffManager;
22
use hipanel\modules\finance\logic\DomainTariffManager;
23
use hipanel\modules\finance\logic\OvdsTariffManager;
24
use hipanel\modules\finance\logic\ServerTariffManager;
25
use hipanel\modules\finance\logic\SvdsTariffManager;
26
use hipanel\modules\finance\logic\TariffManagerFactory;
27
use Yii;
28
29
class TariffController extends \hipanel\base\CrudController
30
{
31 View Code Duplication
    public function behaviors()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
32
    {
33
        return array_merge(parent::behaviors(), [
0 ignored issues
show
Bug Best Practice introduced by
The return type of return array_merge(paren...'*' => 'plan.read')))); (array<*,array>) is incompatible with the return type of the parent method hipanel\base\Controller::behaviors of type array[].

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
34
            'access-control' => [
35
                'class' => EasyAccessControl::class,
36
                'actions' => [
37
                    'create,import,copy' => 'plan.create',
38
                    'update'    => 'plan.update',
39
                    'delete'    => 'plan.delete',
40
                    '*'         => 'plan.read',
41
                ],
42
            ],
43
        ]);
44
    }
45
46 1
    public function actions()
47
    {
48 1
        return array_merge(parent::actions(), [
49 1
            'index' => [
50
                'class' => IndexAction::class,
51
                'data' => function () {
52
                    return [
53
                        'types' => Ref::getList('type,tariff', 'hipanel:finance:tariff:types'),
54
                    ];
55 1
                },
56
            ],
57
            'search' => [
58
                'class' => ComboSearchAction::class,
59
            ],
60
            'validate-form' => [
61
                'class' => ValidateFormAction::class,
62
            ],
63
            'set-note' => [
64
                'class' => SmartUpdateAction::class,
65 1
                'success' => Yii::t('hipanel', 'Note updated'),
66
            ],
67
            'delete' => [
68
                'class' => SmartDeleteAction::class,
69 1
                'success' => Yii::t('hipanel:finance:tariff', 'Tariff deleted'),
70
            ],
71
        ]);
72
    }
73
74 View Code Duplication
    public function actionCreateDomain($parent_id = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
75
    {
76
        /** @var DomainTariffManager $manager */
77
        $manager = TariffManagerFactory::createByType('domain', $parent_id);
78
        $form = $manager->form;
79
80
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
81
            $manager->insert();
82
83
            return $this->redirect(['view', 'id' => $form->id]);
84
        }
85
86
        return $this->render('domain/create', ['model' => $form]);
87
    }
88
89 View Code Duplication
    public function actionCreateSvds($parent_id = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
    {
91
        /** @var SvdsTariffManager $manager */
92
        $manager = TariffManagerFactory::createByType('svds', $parent_id);
93
94
        $form = $manager->form;
95
96
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
97
            $manager->insert();
98
99
            return $this->redirect(['view', 'id' => $form->id]);
100
        }
101
102
        return $this->render('vds/create', ['model' => $form]);
103
    }
104
105 View Code Duplication
    public function actionCreateOvds($parent_id = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
106
    {
107
        /** @var OvdsTariffManager $manager */
108
        $manager = TariffManagerFactory::createByType('ovds', $parent_id);
109
        $form = $manager->form;
110
111
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
112
            $manager->insert();
113
114
            return $this->redirect(['view', 'id' => $form->id]);
115
        }
116
117
        return $this->render('vds/create', ['model' => $form]);
118
    }
119
120 View Code Duplication
    public function actionCreateCertificate($parent_id = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
121
    {
122
        /** @var CertificateTariffManager $manager */
123
        $manager = TariffManagerFactory::createByType('certificate', $parent_id);
124
        $form = $manager->form;
125
126
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
127
            $manager->insert();
128
129
            return $this->redirect(['view', 'id' => $form->id]);
130
        }
131
132
        return $this->render('certificate/create', ['model' => $form]);
133
    }
134
135 View Code Duplication
    public function actionCreateServer($parent_id = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
136
    {
137
        /** @var ServerTariffManager $manager */
138
        $manager = TariffManagerFactory::createByType('server', $parent_id);
139
        $form = $manager->form;
140
141
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
142
            $manager->insert();
143
144
            return $this->redirect(['view', 'id' => $form->id]);
145
        }
146
147
        return $this->render('server/create', ['model' => $form]);
148
    }
149
150 View Code Duplication
    public function actionUpdate($id)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
151
    {
152
        /** @var AbstractTariffManager $manager */
153
        $manager = TariffManagerFactory::createById($id, ['scenario' => 'update']);
154
        $form = $manager->form;
155
156
        if (Yii::$app->request->isPost && $form->load(Yii::$app->request->post())) {
157
            $manager->update();
158
159
            return $this->redirect(['view', 'id' => $form->id]);
160
        }
161
162
        return $this->render($manager->getType() . '/update', ['model' => $form]);
163
    }
164
165
    public function actionCopy()
166
    {
167
        $id = Yii::$app->request->post('selection')[0];
168
        $manager = TariffManagerFactory::createById($id, ['scenario' => 'create']);
169
        $form = $manager->form;
170
        $form->id = null;
171
172
        return $this->render($manager->getType() . '/copy', ['model' => $form]);
173
    }
174
175
    public function actionView($id)
176
    {
177
        $manager = TariffManagerFactory::createById($id);
178
179
        return $this->render('view', ['manager' => $manager]);
180
    }
181
}
182