Issues (229)

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/MainColumn.php (1 issue)

Labels
Severity

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
 * HiPanel core package
4
 *
5
 * @link      https://hipanel.com/
6
 * @package   hipanel-core
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2014-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\grid;
12
13
use Closure;
14
use hipanel\helpers\ArrayHelper;
15
use hipanel\widgets\NoteBlock;
16
use hipanel\widgets\XEditable;
17
use Yii;
18
use yii\helpers\Html;
19
use yii\helpers\Url;
20
21
class MainColumn extends DataColumn
22
{
23
    /**
24
     * @var true|string|array
25
     * true - note editing is enabled in this column, target attribute name is `note`
26
     * string - target atttribute name
27
     * array - array of notes for an attribute
28
     */
29
    public $note;
30
31
    /**
32
     * @var string name of attribute with extra data showed under main data
33
     */
34
    public $extraAttribute;
35
36
    /**
37
     * @var array will be passed to the ```pluginOptions``` of [[XEditable]] plugin
38
     */
39
    public $noteOptions = [];
40
41
    /**
42
     * @var string|Closure badges string or callback to render badges
43
     */
44
    public $badges;
45
46
    /**
47
     * Builds url.
48
     * @param string $url
49
     * @return string
50
     */
51
    protected function buildUrl($url)
52
    {
53
        if (strncmp($url, '/', 1) === 0) {
54
            return $url;
55
        }
56
        $baseUrl = isset($this->grid->controllerUrl) ? $this->grid->controllerUrl : '';
57
58
        return $baseUrl ? Url::to($baseUrl . '/' . $url) : Url::to($url);
59
    }
60
61
    public function init()
62
    {
63
        parent::init();
64
        $this->noteOptions = ArrayHelper::merge([
65
            'url' => $this->buildUrl('set-note'),
66
        ], $this->noteOptions);
67
    }
68
69
    /** {@inheritdoc} */
70
    protected function renderDataCellContent($model, $key, $index)
71
    {
72
        $value = $this->renderValue($model, $key, $index);
73
        $note = $this->renderNoteLink($model, $key, $index);
74
        $extra = $this->renderExtra($model);
75
        $badges = $this->renderBadges($model, $key, $index);
76
77
        return $value . $extra . $badges . $note;
78
    }
79
80
    protected function renderValue($model, $key, $index)
81
    {
82
        if ($this->value !== null) {
83
            if (is_string($this->value)) {
84
                $value = ArrayHelper::getValue($model, $this->value);
85
            } else {
86
                $value = call_user_func($this->value, $model, $key, $index, $this);
87
            }
88
        } else {
89
            $value = $this->renderViewLink($model, $key, $index);
90
        }
91
        return $value;
92
    }
93
94
    protected function renderBadges($model, $key, $index)
95
    {
96
        $badges = $this->badges instanceof Closure
97
                    ? call_user_func($this->badges, $model, $key, $index)
98
                    : $this->badges;
99
100
        return $badges ? (' ' . $badges) : '';
101
    }
102
103
    protected function renderExtra($model)
104
    {
105
        $value = $this->extraAttribute ? $model->{$this->extraAttribute} : null;
106
107
        return $value ? "<br>$value" : '';
108
    }
109
110
    protected function renderViewLink($model, $key, $index)
111
    {
112
        $value = parent::renderDataCellContent($model, $key, $index);
113
114
        return Html::a($value, [$this->buildUrl('view'), 'id' => $model->id], ['class' => 'bold']);
115
    }
116
117
    /**
118
     * Renders link to edit note.
119
     * @param $model
120
     * @param $key
121
     * @param $index
122
     * @return string
123
     */
124
    protected function renderNoteLink($model, $key, $index)
125
    {
126
        if (empty($this->note)) {
127
            return '';
128
        }
129
        if (is_array($this->note)) {
130
            return array_reduce(
131
                $this->note,
132
                fn (string $res, string $note): string => $res . NoteBlock::widget([
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_VARIABLE, expecting ',' or ')'
Loading history...
133
                    'model' => $model,
134
                    'note' => $note,
135
                    'noteOptions' => $this->noteOptions[$note],
136
                ]),
137
                '',
138
            );
139
        }
140
        if (is_string($this->note)) {
141
            return NoteBlock::widget([
142
                'model' => $model,
143
                'note' => $this->note,
144
                'noteOptions' => $this->noteOptions,
145
            ]);
146
        }
147
        return '';
148
    }
149
}
150