Issues (256)

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/grid/IpGridView.php (2 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
 * Hosting Plugin for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-hosting
6
 * @package   hipanel-module-hosting
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\hosting\grid;
12
13
use hipanel\grid\BoxedGridView;
14
use hipanel\grid\MainColumn;
15
use hipanel\grid\XEditableColumn;
16
use hipanel\helpers\FontIcon;
17
use hipanel\helpers\Url;
18
use hipanel\modules\hosting\menus\IpActionsMenu;
19
use hipanel\modules\hosting\models\HdomainSearch;
20
use hipanel\modules\hosting\models\Ip;
21
use hipanel\modules\hosting\widgets\ip\ApplyPtrChange;
22
use hipanel\modules\hosting\widgets\ip\IpTag;
23
use hipanel\widgets\ArraySpoiler;
24
use hipanel\widgets\XEditable;
25
use hiqdev\yii2\menus\grid\MenuColumn;
26
use Yii;
27
use yii\base\InvalidParamException;
28
use yii\helpers\Html;
29
30
class IpGridView extends BoxedGridView
31
{
32
    public $controllerUrl = '@ip';
33
34
    public $ipTags = [];
35
36
    public function columns()
37
    {
38
        return array_merge(parent::columns(), [
39
            'ip' => [
40
                'class' => MainColumn::class,
41
                'filterAttribute' => 'ip_like',
42
            ],
43
            'note' => [
44
                'class' => XEditableColumn::class,
45
                'pluginOptions' => [
46
                    'url'       => Url::to('set-note'),
47
                ],
48
                'widgetOptions' => [
49
                    'linkOptions' => [
50
                        'data-type' => 'textarea',
51
                    ],
52
                ],
53
                'visible' => Yii::$app->user->can('admin'),
54
            ],
55
            'tags' => [
56
                'format' => 'raw',
57
                'attribute' => 'tag',
58
                'header' => Yii::t('hipanel:hosting', 'Tags'),
59
                'visible' => Yii::$app->user->can('admin'),
60
                'filter' => function ($column, $model) {
61
                    return Html::activeDropDownList($model, 'tag_in', array_merge(['' => Yii::t('hipanel', '---')], $this->ipTags), ['class' => 'form-control']);
62
                },
63
                'value' => function ($model) {
64
                    $labels = [];
65
                    foreach ($model->tags as $tag) {
66
                        $labels[] = IpTag::widget(['tag' => $tag]);
67
                    }
68
69
                    return implode(' ', $labels);
70
                },
71
            ],
72
            'counters' => [
73
                'format' => 'html',
74
                'header' => Yii::t('hipanel:hosting', 'Counters'),
75
                'value' => function ($model) {
76
                    $html = '';
77
                    foreach ($model->objects_count as $count) {
78
                        if ($count['type'] === 'hdomain') {
79
                            $url['ok'] = ['@hdomain', (new HdomainSearch())->formName() => ['ip_like' => $model->ip]];
80
                            $url['deleted'] = ['@hdomain', (new HdomainSearch())->formName() => ['ip_like' => $model->ip, 'state' => 'deleted']];
81
                            $type = function ($count) {
82
                                return Yii::t('hipanel:hosting', '{0, plural, one{domain} other{domains}}', (int) $count);
0 ignored issues
show
(int) $count is of type integer, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
83
                            };
84
                        } else {
85
                            throw new InvalidParamException('The object type is not supported', $model);
0 ignored issues
show
Deprecated Code introduced by
The class yii\base\InvalidParamException has been deprecated with message: since 2.0.14. Use [[InvalidArgumentException]] instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
86
                        }
87
88
                        if ($count['ok']) {
89
                            $html .= Html::a(
90
                                (int) $count['ok'] . '&nbsp;' . FontIcon::i('fa-check') . ' ' . $type($count['ok']),
91
                                $url['ok'],
92
                                ['class' => 'btn btn-success btn-xs']
93
                            );
94
                        }
95
                        $html .= ' ';
96
                        if ($count['deleted'] > 0) {
97
                            $html .= Html::a(
98
                                (int) $count['deleted'] . '&nbsp;' . FontIcon::i('fa-trash') . ' ' . $type($count['deleted']),
99
                                $url['deleted'],
100
                                ['class' => 'btn btn-xs btn-warning']
101
                            );
102
                        }
103
                    }
104
105
                    return $html;
106
                },
107
            ],
108
            'links' => [
109
                'format' => 'html',
110
                'value' => function ($model) {
111
                    $items = [];
112
                    foreach ($model->links as $link) {
113
                        $item = Html::a($link->device, ['@server/view', 'id' => $link->device_id]);
114
                        if ($link->service_id) {
115
                            $item .= '&nbsp;' . FontIcon::i('fa-long-arrow-right');
116
                            $item .= '&nbsp;' . Html::a($link->service ?: $link->soft, ['@service/view', 'id' => $link->service_id]);
117
                        }
118
                        $items[] = $item;
119
                    }
120
121
                    return ArraySpoiler::widget(['data' => $items, 'visibleCount' => 3]);
122
                },
123
            ],
124
            'services' => [
125
                'attribute' => 'links',
126
                'format' => 'html',
127
                'label' => Yii::t('hipanel:server', 'Services'),
128
                'value' => function ($model) {
129
                    return ArraySpoiler::widget([
130
                        'data' => $model->links,
131
                        'formatter' => function ($link) {
132
                            if (Yii::$app->user->can('support') && Yii::getAlias('@service', false)) {
133
                                return Html::a($link->service, ['@service/view', 'id' => $link->service_id]);
134
                            }
135
136
                            return $link->service;
137
                        },
138
                    ]);
139
                },
140
            ],
141
            'actions' => [
142
                'class' => MenuColumn::class,
143
                'menuClass' => IpActionsMenu::class,
144
            ],
145
            'ptr' => [
146
                'options' => [
147
                    'style' => 'width: 40%',
148
                ],
149
                'format' => 'raw',
150
                'value' => static function (Ip $model): string {
151
                    if ($model->canSetPtr()) {
152
                        return XEditable::widget([
153
                            'model' => $model,
154
                            'attribute' => 'ptr',
155
                            'pluginOptions' => [
156
                                'url' => Url::to('@ip/set-ptr'),
157
                            ],
158
                        ]);
159
                    }
160
161
                    return ApplyPtrChange::widget(compact('model'));
162
                },
163
            ],
164
        ]);
165
    }
166
}
167