Issues (14)

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.

Module.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
 * Module.php
4
 * @author Revin Roman
5
 * @link https://rmrevin.ru
6
 */
7
8
namespace rmrevin\yii\module\Comments;
9
10
use rmrevin\yii\module\Comments;
11
use yii\helpers\ArrayHelper;
12
13
/**
14
 * Class Module
15
 * @package rmrevin\yii\module\Comments
16
 */
17
class Module extends \yii\base\Module
18
{
19
20
    /** @var string module name */
21
    public static $moduleName = 'comments';
22
23
    /** @var string|null */
24
    public $userIdentityClass = null;
25
26
    /** @var bool */
27
    public $useRbac = true;
28
29
    /**
30
     * Array that will store the models used in the package
31
     * e.g. :
32
     * [
33
     *     'Comment' => 'frontend/models/comments/CommentModel'
34
     * ]
35
     *
36
     * The classes defined here will be merged with getDefaultModels()
37
     * having he manually defined by the user preference.
38
     *
39
     * @var array
40
     */
41
    public $modelMap = [];
42
43 1
    public function init()
44
    {
45 1
        parent::init();
46
47 1
        if ($this->userIdentityClass === null) {
48
            $this->userIdentityClass = \Yii::$app->getUser()->identityClass;
0 ignored issues
show
The method getUser does only exist in yii\web\Application, but not in yii\console\Application.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
49
        }
50
51
        // Merge the default model classes
52
        // with the user defined ones.
53 1
        $this->defineModelClasses();
54 1
    }
55
56
    /**
57
     * @return static
58
     */
59
    public static function instance()
60
    {
61
        return \Yii::$app->getModule(static::$moduleName);
62
    }
63
64
    /**
65
     * Merges the default and user defined model classes
66
     * Also let's the developer to set new ones with the
67
     * parameter being those the ones with most preference.
68
     *
69
     * @param array $modelClasses
70
     */
71 1
    public function defineModelClasses($modelClasses = [])
72
    {
73 1
        $this->modelMap = ArrayHelper::merge(
74 1
            $this->getDefaultModels(),
75 1
            $this->modelMap,
76
            $modelClasses
77 1
        );
78 1
    }
79
80
    /**
81
     * Get default model classes
82
     */
83 1
    protected function getDefaultModels()
84
    {
85
        return [
86 1
            'Comment' => Comments\models\Comment::className(),
87 1
            'CommentQuery' => Comments\models\queries\CommentQuery::className(),
88 1
            'CommentCreateForm' => Comments\forms\CommentCreateForm::className(),
89 1
        ];
90
    }
91
92
    /**
93
     * Get defined className of model
94
     *
95
     * Returns an string or array compatible
96
     * with the Yii::createObject method.
97
     *
98
     * @param string $name
99
     * @param array $config // You should never send an array with a key defined as "class" since this will
100
     *                      // overwrite the main className defined by the system.
101
     * @return string|array
102
     */
103
    public function model($name, $config = [])
104
    {
105
        $modelData = $this->modelMap[ucfirst($name)];
106
107
        if (!empty($config)) {
108
            if (is_string($modelData)) {
109
                $modelData = ['class' => $modelData];
110
            }
111
112
            $modelData = ArrayHelper::merge(
113
                $modelData,
114
                $config
115
            );
116
        }
117
118
        return $modelData;
119
    }
120
}
121