Issues (443)

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.

modules/toolbar/frontend/Module.php (3 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
 * @link      http://www.writesdown.com/
4
 * @copyright Copyright (c) 2015 WritesDown
5
 * @license   http://www.writesdown.com/license/
6
 */
7
8
namespace modules\toolbar\frontend;
9
10
use common\models\PostType;
11
use common\models\search\Option;
12
use common\models\Taxonomy;
13
use Yii;
14
use yii\base\Application;
15
use yii\base\BootstrapInterface;
16
use yii\bootstrap\Nav;
17
use yii\bootstrap\NavBar;
18
use yii\helpers\ArrayHelper;
19
use yii\helpers\Html;
20
use yii\web\View;
21
22
/**
23
 * Class Module
24
 *
25
 * @author  Agiel K. Saputra <[email protected]>
26
 * @since   0.2.0
27
 */
28
class Module extends \yii\base\Module implements BootstrapInterface
29
{
30
    /**
31
     * @var string
32
     */
33
    public $controllerNamespace = false;
34
35
    /**
36
     * @inheritdoc
37
     */
38 View Code Duplication
    public function init()
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...
39
    {
40
        parent::init();
41
        if (!isset(Yii::$app->i18n->translations['toolbar'])) {
42
            Yii::$app->i18n->translations['toolbar'] = [
43
                'class'          => 'yii\i18n\PhpMessageSource',
44
                'sourceLanguage' => Yii::$app->language,
45
                'basePath'       => __DIR__ . '/../messages',
46
            ];
47
        }
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53
    public function bootstrap($app)
54
    {
55
        if (!$app->user->isGuest) {
56
            $app->on(Application::EVENT_BEFORE_REQUEST, function () use ($app) {
57
                $app->getView()->on(View::EVENT_END_BODY, [$this, 'renderToolbar']);
58
            });
59
        }
60
    }
61
62
    /**
63
     * Renders mini-toolbar at the end of page body.
64
     *
65
     * @param \yii\base\Event $event
66
     */
67
    public function renderToolbar($event)
68
    {
69
        /* @var $view View */
70
        /* @var $urlBack \yii\web\UrlManager */
71
72
        $urlBack = Yii::$app->urlManagerBack;
73
        $view = $event->sender;
74
        $view->registerCss($view->renderPhpFile(__DIR__ . '/assets/toolbar.min.css'));
75
        NavBar::begin([
76
            'id'                    => 'wd-frontend-toolbar',
77
            'brandLabel'            => Html::img('@web/img/logo-mini.png'),
78
            'brandUrl'              => $urlBack->baseUrl,
79
            'innerContainerOptions' => ['class' => 'container-fluid'],
80
            'options'               => ['class' => 'navbar navbar-inverse navbar-fixed-top'],
81
        ]);
82
        echo Nav::widget([
83
            'encodeLabels' => false,
84
            'options'      => ['class' => 'navbar-nav'],
85
            'items'        => [
86
                [
87
                    'label' => '<span aria-hidden="true" class="glyphicon glyphicon-dashboard"></span> '
88
                        . Option::get('sitetitle'),
89
                    'items' => [
90
                        ['label' => Yii::t('toolbar', 'Dashboard'), 'url' => $urlBack->baseUrl],
91
                        [
92
                            'label'   => Yii::t('toolbar', 'Themes'),
93
                            'url'     => $urlBack->createUrl(['/theme']),
94
                            'visible' => Yii::$app->user->can('administrator'),
95
                        ],
96
                        [
97
                            'label'   => Yii::t('toolbar', 'Menus'),
98
                            'url'     => $urlBack->createUrl(['/menu']),
99
                            'visible' => Yii::$app->user->can('administrator'),
100
                        ],
101
                        [
102
                            'label'   => Yii::t('toolbar', 'Modules'),
103
                            'url'     => $urlBack->createUrl(['/module']),
104
                            'visible' => Yii::$app->user->can('administrator'),
105
                        ],
106
                        [
107
                            'label'   => Yii::t('toolbar', 'Widgets'),
108
                            'url'     => $urlBack->createUrl(['/widget']),
109
                            'visible' => Yii::$app->user->can('administrator'),
110
                        ],
111
                    ],
112
                ],
113
                [
114
                    'label' => '<span aria-hidden="true" class="glyphicon glyphicon-plus"></span> '
115
                        . Yii::t('toolbar', 'New'),
116
                    'items' => $this->getAddNewMenu() ? $this->getAddNewMenu() : null,
117
                ],
118
            ],
119
        ]);
120
        echo Nav::widget([
121
            'encodeLabels' => false,
122
            'options'      => ['class' => 'navbar-nav navbar-right'],
123
            'items'        => [
124
                [
125
                    'label' => '<span aria-hidden="true" class="glyphicon glyphicon-user"></span> '
126
                        . Yii::$app->user->identity->username,
127
                    'items' => [
128
                        ['label' => 'Profile', 'url' => $urlBack->createUrl(['/user/profile'])],
129
                        [
130
                            'label'       => 'Logout',
131
                            'url'         => ['/site/logout'],
132
                            'linkOptions' => ['data-method' => 'post'],
133
                        ],
134
                    ],
135
                ],
136
            ],
137
        ]);
138
        NavBar::end();
139
    }
140
141
    /**
142
     * Get menu dropdown for post type.
143
     *
144
     * @return array
145
     */
146 View Code Duplication
    protected function getPostTypeMenu()
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...
147
    {
148
        /* @var $urlBack \yii\web\UrlManager */
149
        /* @var $postTypes \common\models\PostType[] */
150
151
        $urlBack = Yii::$app->urlManagerBack;
152
        $items = [];
153
        $postTypes = PostType::find()->select(['id', 'singular_name', 'permission'])->all();
154
155
        foreach ($postTypes as $postType) {
156
            $items[] = [
157
                'label'   => $postType->singular_name,
158
                'url'     => $urlBack->createUrl(['/post/create', 'type' => $postType->id]),
159
                'visible' => Yii::$app->user->can($postType->permission),
160
            ];
161
        }
162
163
        return $items;
164
    }
165
166
    /**
167
     * Get dropdown menu for taxonomy.
168
     *
169
     * @return array
170
     */
171 View Code Duplication
    protected function getTaxonomyMenu()
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...
172
    {
173
        /* @var $urlBack \yii\web\UrlManager */
174
        /* @var $taxonomies \common\models\Taxonomy[] */
175
176
        $urlBack = Yii::$app->urlManagerBack;
177
        $items = [];
178
        $taxonomies = Taxonomy::find()->select(['id', 'singular_name'])->all();
179
180
        foreach ($taxonomies as $taxonomy) {
181
            $items[] = [
182
                'label'   => $taxonomy->singular_name,
183
                'url'     => $urlBack->createUrl(['/taxonomy/view', 'id' => $taxonomy->id]),
184
                'visible' => Yii::$app->user->can('editor'),
185
            ];
186
        }
187
188
        return $items;
189
    }
190
191
    /**
192
     * Get dropdown menu for add new.
193
     *
194
     * @return array
195
     */
196
    protected function getAddNewMenu()
197
    {
198
        /* @var $urlBack \yii\web\UrlManager */
199
200
        $urlBack = Yii::$app->urlManagerBack;
201
        $postTypeMenu = $this->getPostTypeMenu();
202
        $taxonomyMenu = $this->getTaxonomyMenu();
203
        $items = ArrayHelper::merge(
204
            $postTypeMenu,
205
            ['<li class="divider"></li>'],
206
            $taxonomyMenu,
207
            ['<li class="divider"></li>'],
208
            [
209
                [
210
                    'label'   => Yii::t('toolbar', 'Taxonomy'),
211
                    'url'     => $urlBack->createUrl('/taxonomy/create'),
212
                    'visible' => Yii::$app->user->can('administrator'),
213
                ],
214
                [
215
                    'label'   => Yii::t('toolbar', 'Post Type'),
216
                    'url'     => $urlBack->createUrl('/post-type/create'),
217
                    'visible' => Yii::$app->user->can('administrator'),
218
                ],
219
            ]
220
        );
221
222
        return $items;
223
    }
224
}
225