Issues (39)

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/giiant/crud/cornernote/views/index.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
use yii\helpers\Inflector;
4
use yii\helpers\StringHelper;
5
use yii\helpers\VarDumper;
6
use cornernote\gii\helpers\TabPadding;
7
8
/**
9
 * @var yii\web\View $this
10
 * @var schmunk42\giiant\generators\crud\Generator $generator
11
 */
12
13
$urlParams = $generator->generateUrlParams();
14
$nameAttribute = $generator->getNameAttribute();
15
16
/** @var \yii\db\ActiveRecord $model */
17
$model = new $generator->modelClass;
18
$safeAttributes = $model->safeAttributes();
19
if (empty($safeAttributes)) {
20
    $safeAttributes = $model->getTableSchema()->columnNames;
21
}
22
23
echo "<?php\n";
24
?>
25
26
use yii\helpers\Html;
27
use yii\helpers\Url;
28
use yii\bootstrap\ButtonDropdown;
29
use <?= $generator->indexWidgetType === 'grid' ? "yii\\grid\\GridView" : "yii\\widgets\\ListView" ?>;
30
use cornernote\returnurl\ReturnUrl;
31
32
/**
33
 * @var yii\web\View $this
34
 * @var yii\data\ActiveDataProvider $dataProvider
35
 * @var <?= ltrim($generator->searchModelClass, '\\') ?> $searchModel
36
 */
37
38
$this->title = <?= $generator->generateString(Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass)))) ?>;
39
$this->params['breadcrumbs'][] = $this->title;
40
?>
41
42
<div class="<?= Inflector::camel2id(StringHelper::basename($generator->modelClass), '-', true) ?>-index">
43
44
    <div class="clearfix">
45
46
        <p class="pull-left">
47
            <?= "<?= " ?>Html::a('<span class="fa fa-plus"></span> ' . <?= $generator->generateString('Create') ?> . ' ' . <?= $generator->generateString(Inflector::camel2words(StringHelper::basename($generator->modelClass))) ?>, ['create', 'ru' => ReturnUrl::getToken()], ['class' => 'btn btn-success']) ?>
48
            <?= "<?= " ?>Html::button('<span class="fa fa-search"></span> ' . <?= $generator->generateString('Search') ?> . ' ' . <?= $generator->generateString(Inflector::pluralize(Inflector::camel2words(StringHelper::basename($generator->modelClass)))) ?>, ['class' => 'btn btn-info', 'data-toggle' => 'modal', 'data-target' => '#<?= Inflector::camel2id(StringHelper::basename($generator->modelClass), '-', true) ?>-searchModal']) ?>
49
        </p>
50
51
        <div class="pull-right">
52
<?php
53
            $items = [];
54
            $model = new $generator->modelClass;
55
            foreach ($generator->getModelRelations($model) AS $relation) {
56
                // relation dropdown links
57
                $iconType = ($relation->multiple) ? 'arrow-right' : 'arrow-left';
58
                if ($generator->isPivotRelation($relation)) {
59
                    $iconType = 'random';
60
                }
61
                $controller = $generator->pathPrefix . Inflector::camel2id(
62
                        StringHelper::basename($relation->modelClass),
63
                        '-',
64
                        true
65
                    );
66
                $route = $generator->createRelationRoute($relation,'index');
67
                $label      = Inflector::titleize(StringHelper::basename($relation->modelClass), '-', true);
0 ignored issues
show
'-' is of type string, but the function expects a boolean.

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...
The call to Inflector::titleize() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
68
                $items[] = [
69
                    'label' => '<i class="fa fa-' . $iconType . '"></i> ' . $label,
70
                    'url'   => [$route]
71
                ];
72
            }
73
            ?>
74
75
            <?= "<?php \n" ?>
76
            /*
77
            echo ButtonDropdown::widget([
78
                'id' => 'giiant-relations',
79
                'encodeLabel' => false,
80
                'label' => '<span class="fa fa-paperclip"></span> ' . <?= $generator->generateString('Relations') ?>,
81
                'dropdown' => [
82
                    'options' => [
83
                        'class' => 'dropdown-menu-right'
84
                    ],
85
                    'encodeLabels' => false,
86
                    'items' => <?= TabPadding::pad(VarDumper::export($items), 5) ?>,
87
                ],
88
            ]);
89
            */
90
            <?= "?>" ?>
91
92
93
        </div>
94
95
    </div>
96
97
    <?= "<?php " . ($generator->indexWidgetType === 'grid' ? '' : '') ?>echo $this->render('_search', ['model' => $searchModel]); ?>
98
99
<?php if ($generator->indexWidgetType === 'grid'): ?>
100
    <div class="table-responsive">
101
        <?= "<?= " ?>GridView::widget([
102
            'layout' => '{summary}{pager}{items}{pager}',
103
            'dataProvider' => $dataProvider,
104
            'filterModel' => $searchModel,
105
            'columns' => [
106
<?php
107
        $class = $generator->modelClass;
108
        $actionButtonColumn = <<<PHP
109
                [
110
                    'class' => '{$generator->actionButtonClass}',
111
                    'urlCreator' => function (\$action, \$model, \$key, \$index) {
112
                        /** @var {$class} \$model */
113
                        // using the column name as key, not mapping to 'id' like the standard generator
114
                        \$params = is_array(\$key) ? \$key : [\$model->primaryKey()[0] => (string)\$key];
115
                        \$params[0] = Yii::\$app->controller->id ? Yii::\$app->controller->id . '/' . \$action : \$action;
116
                        \$params['ru'] = ReturnUrl::getToken();
117
                        return Url::toRoute(\$params);
118
                    },
119
                    'contentOptions' => ['nowrap' => 'nowrap']
120
                ],
121
PHP;
122
123
        // action buttons first
124
        echo $actionButtonColumn;
125
126
        $count = 0;
127
        echo "\n"; // code-formatting
128
129
        foreach ($safeAttributes as $attribute) {
130
            $format = $generator->columnFormat($attribute,$model);
131
            if ($format == false) continue;
132
            $format = (++$count < 10) ? "{$format},\n" : "        /*" . trim($format) . "*/\n";
133
            echo TabPadding::pad($format, 2, true);
134
        }
135
136
        ?>
137
            ],
138
        ]); ?>
139
    </div>
140
141
<?php else: ?>
142
        <?= "<?= " ?> ListView::widget([
143
            'dataProvider' => $dataProvider,
144
            'itemOptions' => ['class' => 'item'],
145
            'itemView' => function ($model, $key, $index, $widget) {
146
                return Html::a(Html::encode($model-><?= $nameAttribute ?>), ['view', <?= $urlParams ?>]);
147
            },
148
        ]); ?>
149
150
<?php endif; ?>
151
</div>