GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (2170)

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.

application/actions/SubmitFormAction.php (9 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
namespace app\actions;
4
5
use Yii;
6
use app\behaviors\spamchecker\SpamCheckerBehavior;
7
use app\models\Form;
8
use app\models\BaseObject;
9
use app\models\ObjectPropertyGroup;
10
use app\models\Property;
11
use app\models\SpamChecker;
12
use app\models\Submission;
13
use app\properties\AbstractModel;
14
use app\properties\HasProperties;
15
use kartik\form\ActiveForm;
16
use yii\base\Action;
17
use yii\helpers\ArrayHelper;
18
use yii\web\NotFoundHttpException;
19
use yii\web\Response;
20
21
class SubmitFormAction extends Action
22
{
23
    /**
24
     * @inheritdoc
25
     * @param int $id
26
     * @return int|mixed
27
     * @throws NotFoundHttpException
28
     */
29
    public function run($id)
30
    {
31
        /** @var Form|HasProperties $form */
32
        if (null === $form = Form::findById($id)) {
33
            throw new NotFoundHttpException();
34
        }
35
36
        $post = Yii::$app->request->post();
37
38
        // удаляем required правило для файлов
39
        $intersectKeys = [];
40
        if (isset($_FILES[$form->abstractModel->formName()]) && isset($post[$form->abstractModel->formName()])) {
41
            $intersectKeys = array_intersect_key(
42
                $post[$form->abstractModel->formName()],
43
                $_FILES[$form->abstractModel->formName()]['name']
44
            );
45
        }
46
        
47
        if(!empty($intersectKeys)) {
48
            $intersectKeys = array_keys($intersectKeys);
49
            $oldRulesModel = $form->abstractModel->getRules();
50
            $newRulesModel = [];
51
            foreach($oldRulesModel as $curRule){
52
                if(!is_array($curRule[1])
53
                    && $curRule[1] == 'required'
54
                    && in_array($curRule[0], $intersectKeys)) {
55
                    continue;
56
                }
57
                $newRulesModel[] = $curRule;
58
            }
59
            $form->abstractModel->clearRules();
60
            $form->abstractModel->addRules($newRulesModel);
61
        }
62
        // удаляем required правило для файлов
63
64
65
        $form->abstractModel->setAttributesValues($post);
66
        /** @var AbstractModel|SpamCheckerBehavior $model */
67
        $model = $form->getAbstractModel();
0 ignored issues
show
Documentation Bug introduced by
The method getAbstractModel does not exist on object<app\models\Form>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
68
69
        if (Yii::$app->request->isAjax && isset($post['ajax'])) {
70
            Yii::$app->response->format = Response::FORMAT_JSON;
71
            return ActiveForm::validate($model);
72
        }
73
74
        /** @var \app\models\BaseObject $object */
75
        $object = BaseObject::getForClass(Form::className());
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
76
        $propGroups = ObjectPropertyGroup::find()->where(
77
            [
78
                'and',
79
                'object_id = :object',
80
                'object_model_id = :id'
81
            ],
82
            [
83
                ':object' => $object->id,
84
                ':id' => $id
85
            ]
86
        )->asArray()->all();
87
        $propIds = ArrayHelper::getColumn($propGroups, 'property_group_id');
88
89
        // Spam checking
90
        $activeSpamChecker = SpamChecker::getActive();
91
        $data = [];
92
        $haveSpam = false;
93
        if ($activeSpamChecker !== null && !empty($activeSpamChecker->api_key)) {
94
            $data[$activeSpamChecker->name]['class'] = $activeSpamChecker->behavior;
95
            $data[$activeSpamChecker->name]['value']['key'] = $activeSpamChecker->api_key;
96
            $properties = Property::getForGroupId($propIds[0]);
97
            foreach ($properties as $prop) {
98
                if (!isset($activeSpamChecker->{$prop->interpret_as})
99
                    || empty($activeSpamChecker->{$prop->interpret_as})
100
                ) {
101
                    continue;
102
                }
103
                $data[$activeSpamChecker->name]['value'][$activeSpamChecker->{$prop->interpret_as}] =
104
                    is_array($post[$form->abstractModel->formName()][$prop->key])
105
                        ? implode(' ', $post[$form->abstractModel->formName()][$prop->key])
106
                        : $post[$form->abstractModel->formName()][$prop->key];
107
            }
108
            $model->attachBehavior(
0 ignored issues
show
The method attachBehavior does only exist in app\properties\AbstractModel, but not in app\behaviors\spamchecker\SpamCheckerBehavior.

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...
109
                'spamChecker',
110
                [
111
                    'class' => SpamCheckerBehavior::className(),
0 ignored issues
show
Deprecated Code introduced by
The method yii\base\BaseObject::className() has been deprecated with message: since 2.0.14. On PHP >=5.5, use `::class` instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
112
                    'data' => $data,
113
                ]
114
            );
115
            $haveSpam = $model->isSpam();
0 ignored issues
show
The method isSpam does only exist in app\behaviors\spamchecker\SpamCheckerBehavior, but not in app\properties\AbstractModel.

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...
116
        }
117
        $date = new \DateTime();
118
        /** @var Submission|HasProperties $submission */
119
        $submission = new Submission(
120
            [
121
                'form_id' => $form->id,
122
                'date_received' => $date->format('Y-m-d H:i:s'),
123
                'ip' => Yii::$app->request->userIP,
124
                'user_agent' => Yii::$app->request->userAgent,
125
                'spam' => (int)$haveSpam,
126
                'submission_referrer' => Yii::$app->request->referrer
127
            ]
128
        );
129
        if (false === Yii::$app->user->isGuest) {
130
            $submission->processed_by_user_id = Yii::$app->user->identity->getId();
131
        }
132
        if (!($form->abstractModel->validate() && $submission->save())) {
0 ignored issues
show
The method save does only exist in app\models\Submission, but not in app\properties\HasProperties.

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...
133
            return "0";
134
        }
135
        if (isset($post[$form->abstractModel->formName()])) {
136
            $data = [
137
                HasProperties::FIELD_ADD_PROPERTY_GROUP => [
138
                    $submission->formName() => array_keys($form->getPropertyGroups()),
0 ignored issues
show
The method formName does only exist in app\models\Submission, but not in app\properties\HasProperties.

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...
Documentation Bug introduced by
The method getPropertyGroups does not exist on object<app\models\Form>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
139
                ],
140
                $submission->abstractModel->formName() => $post[$form->abstractModel->formName()],
141
            ];
142
            if (isset($_FILES[$form->abstractModel->formName()])) {
143
                $_FILES[$submission->abstractModel->formName()] = $_FILES[$form->abstractModel->formName()];
144
            }
145
            $submission->saveProperties($data);
0 ignored issues
show
The method saveProperties does only exist in app\properties\HasProperties, but not in app\models\Submission.

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...
146
        }
147
        return $submission->id;
148
    }
149
}
150