Issues (80)

Security Analysis    no request data  

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.

api/Lib/DsManager/Helpers/MatchSimulator.php (6 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
4
namespace App\Lib\DsManager\Helpers;
5
6
7
use App\Lib\DsManager\Models\Orm\LeagueRound;
8
use App\Lib\DsManager\Models\Orm\Match;
9
use App\Lib\DsManager\Models\Orm\Match as MatchOrm;
10
use App\Lib\DsManager\Models\Orm\MatchResult;
11
12
/**
13
 * Class MatchSimulator
14
 * @package App\Lib\DsManager\Helpers
15
 */
16
class MatchSimulator
17
{
18
    /**
19
     * @param $roundId
20
     * @return string
21
     */
22
    public static function simulateRound($roundId)
23
    {
24
        $result = self::getCompleteRound($roundId);
25
        if (!empty($result)
26
            &&
27
            !$result->simulated
28
        ) {
29
            $matches = Match::where(
30
                [
31
                    'league_round_id' => $roundId
32
                ]
33
            )->get();
34
            foreach ($matches as $match) {
35
                self::simulateSimpleResult($match->id)->toArray();
36
            }
37
            LeagueRound::find($roundId)->update(['simulated' => true]);
38
            $result = self::getCompleteRound($roundId);
39
        }
40
        return $result;
41
    }
42
43
    /**
44
     * @param $matchId
45
     * @return mixed
46
     */
47 View Code Duplication
    public static function simulateCompleteResult($matchId)
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...
48
    {
49
        $result = self::getCompleteResult($matchId);
50
        if (!empty($result)
51
            && !$result->simulated
0 ignored issues
show
The property simulated does not exist on object<App\Lib\DsManager\Models\Orm\MatchResult>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
52
            && self::simulate($matchId) === 1
53
        ) {
54
            $result = self::getCompleteResult($matchId);
55
        }
56
        return $result;
57
    }
58
59
    /**
60
     * @param $matchId
61
     * @return mixed
62
     */
63 View Code Duplication
    public static function simulateSimpleResult($matchId)
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...
64
    {
65
        $result = self::getSimpleResult($matchId);
66
        if (!empty($result)
67
            && !$result->simulated
0 ignored issues
show
The property simulated does not exist on object<App\Lib\DsManager\Models\Orm\MatchResult>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
68
            && self::simulate($matchId) === 1
69
        ) {
70
            $result = self::getSimpleResult($matchId);
71
        }
72
        return $result;
73
    }
74
75
    /**
76
     * @param $matchId
77
     * @return mixed
78
     */
79
    private static function simulate($matchId)
80
    {
81
        $match = \App\Lib\DsManager\Models\Match::fromArray(
82
            MatchOrm::complete()
0 ignored issues
show
The method complete() does not exist on App\Lib\DsManager\Models\Orm\Match. Did you maybe mean scopeComplete()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
83
                ->where(
84
                    [
85
                        'id' => $matchId
86
                    ]
87
                )->first()->toArray()
88
        );
89
        $matchResult = $match->simulate()->toArray();
90
        $result = MatchResult::where(
91
            [
92
                'id' => $matchId
93
            ]
94
        )->update(
95
            MatchResult::resolveAttributes(
96
                $matchResult,
97
                $matchId
98
            )
99
        );
100
        return $result;
101
    }
102
103
104
    /**
105
     * @param $matchId
106
     * @return MatchResult
107
     */
108
    private static function getCompleteResult($matchId)
109
    {
110
        return MatchResult::complete()->where(
111
            [
112
                'id' => $matchId
113
            ]
114
        )->first();
115
    }
116
117
    /**
118
     * @param $matchId
119
     * @return MatchResult
120
     */
121
    private static function getSimpleResult($matchId)
122
    {
123
        return MatchResult::teams()->where(
124
            [
125
                'id' => $matchId
126
            ]
127
        )->first();
128
    }
129
130
    /**
131
     * @param $roundId
132
     * @return mixed
133
     */
134
    private static function getCompleteRound($roundId)
135
    {
136
        return LeagueRound::complete()->where(
0 ignored issues
show
The method complete() does not exist on App\Lib\DsManager\Models\Orm\LeagueRound. Did you maybe mean scopeComplete()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
137
            [
138
                'id' => $roundId
139
            ]
140
        )->first();
141
    }
142
143
}