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

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\grid;
12
13
use hipanel\helpers\FontIcon;
14
use hipanel\modules\finance\widgets\DocumentByMonthButton;
15
use hipanel\widgets\ArraySpoiler;
16
use Yii;
17
use yii\base\InvalidConfigException;
18
use yii\helpers\Html;
19
20
class DocumentsColumn extends \hipanel\grid\DataColumn
21
{
22
    public $format = 'raw';
23
24
    public $type;
25
26
    public function init()
27
    {
28
        if ($this->type === null) {
29
            throw new InvalidConfigException('Property "type" must be set');
30
        }
31
    }
32
33
    public function getDataCellValue($model, $key, $index)
34
    {
35
        return ArraySpoiler::widget([
36
            'mode' => ArraySpoiler::MODE_SPOILER,
37
            'data' => parent::getDataCellValue($model, $key, $index),
38
            'delimiter' => ' ',
39
            'formatter' => function ($doc) {
40
                return Html::a(
41
                    FontIcon::i('fa-file-pdf-o') . date(' M Y', strtotime($doc->validity_start)),
42
                    ["/file/{$doc->file_id}/{$doc->filename}", 'nocache' => 1],
43
                    [
44
                        'target' => '_blank',
45
                        'class' => 'btn btn-app pull-left',
46
                        'style' => 'width: 8em;',
47
                    ]
48
                );
49
            },
50
            'template' => '<div class="text-right clearfix" style="margin-bottom: 10px;padding-left: 10px;">' . $this->generateManagementButtons($model) . '{button}</div><div>{visible}{hidden}</div>',
51
            'visibleCount' => 3,
52
            'button' => [
53
                'label' => FontIcon::i('fa-history') . ' ' . Yii::t('hipanel', 'Show all'),
54
                'class' => 'btn btn-xs btn-default',
55
                'data' => [
56
                    'toggle' => 'button',
57
                ],
58
            ],
59
        ]);
60
    }
61
62
    protected function generateManagementButtons($model)
63
    {
64
        if (!Yii::$app->user->can('document.generate')) {
65
            return null;
66
        }
67
68
        $buttons[] = $this->renderSeeNewButton($model);
0 ignored issues
show
Coding Style Comprehensibility introduced by
$buttons was never initialized. Although not strictly required by PHP, it is generally a good practice to add $buttons = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
69
        $buttons[] = $this->renderUpdateButton($model);
70
71
        return Html::tag('div', implode('', $buttons), ['class' => 'btn-group', 'style' => 'display: block;']);
72
    }
73
74
    public function renderSeeNewButton($model)
75
    {
76
        return DocumentByMonthButton::widget([
77
            'modalHeader' => Yii::t('hipanel:finance', 'See new'),
78
            'buttonLabel' => Yii::t('hipanel:finance', 'See new'),
79
            'model' => $model,
80
            'action' => $this->getRouteForSeeNew(),
81
            'type' => $this->type,
82
        ]);
83
    }
84
85
    protected function renderUpdateButton($model)
86
    {
87
        return DocumentByMonthButton::widget([
88
            'model' => $model,
89
            'modalHeader' => Yii::t('hipanel:finance', 'Confirm document updating'),
90
            'modalHeaderColor' => 'label-warning',
91
            'buttonLabel' => Yii::t('hipanel:finance', 'Update'),
92
            'action' => $this->getRouteForUpdate(),
93
            'type' => $this->type,
94
            'prepend' => implode('', [
95
                Html::activeHiddenInput($model, 'type', ['value' => $this->type]),
96
                Html::beginTag('blockquote', ['class' => 'text-warning']),
97
                    Html::tag('h5', Yii::t('hipanel:finance', 'Are you sure you want to update document?')),
98
                    Html::tag('h5', Yii::t('hipanel:finance', 'Current document will be substituted with newer version!')),
99
                Html::endTag('blockquote'),
100
            ]),
101
        ]);
102
    }
103
104
    protected function getRouteForSeeNew()
105
    {
106
        return [
107
            '@purse/pre-generate-document',
108
            'type' => $this->type,
109
        ];
110
    }
111
112
    protected function getRouteForUpdate()
113
    {
114
        return ['@purse/generate-and-save-document'];
115
    }
116
}
117