Issues (13)

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.

src/Classes/ClubKonnectResponse.php (1 issue)

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
 * Created By: Henry Ejemuta
4
 * PC: Enrico Systems
5
 * Project: laravel-clubkonnect
6
 * Company: Stimolive Technologies Limited
7
 * Class Name: ClubKonnectResponse.php
8
 * Date Created: 9/27/20
9
 * Time Created: 6:00 PM
10
 */
11
12
namespace HenryEjemuta\LaravelClubKonnect\Classes;
13
14
15
use HenryEjemuta\LaravelClubKonnect\Enums\ClubKonnectStatusCodeEnum;
16
use HenryEjemuta\LaravelClubKonnect\Exceptions\ClubKonnectErrorException;
17
18
class ClubKonnectResponse
19
{
20
    private $message;
21
22
    /**
23
     * @var bool
24
     */
25
    private $hasError;
26
27
    /**
28
     * @var ClubKonnectErrorException
29
     */
30
    private $error;
31
32
    /**
33
     * @var int
34
     */
35
    private $code;
36
37
    /**
38
     * Response Body from
39
     * @var object|null $body
40
     */
41
    private $body;
42
43
44
    /**
45
     * ClubKonnectResponse constructor.
46
     * @param object|array|null $responseBody
47
     */
48
    public function __construct($responseBody = null)
49
    {
50
        if (isset($responseBody->status)) {
51
            $statusCode = ClubKonnectStatusCodeEnum::getStatusCode($responseBody->status);
52
            $this->code = $statusCode->getCode();
53
            $remark = ($responseBody->status == $statusCode->getRemark()) ? '' : $statusCode->getRemark();
54
            $this->message = $remark . (!empty($remark) ? ', ' : '') . $statusCode->getDescription();
55
        } else {
56
            $this->code = 200;
57
            $this->message = '';
58
        }
59
60
        $this->body = $responseBody;
0 ignored issues
show
Documentation Bug introduced by
It seems like $responseBody can also be of type array. However, the property $body is declared as type object|null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
61
        $this->hasError = !in_array($this->code, ClubKonnectStatusCodeEnum::$successCodes);
62
63
        if ($this->hasError) {
64
            $this->error = new ClubKonnectErrorException($this->message, $this->code);
65
        } else {
66
            $this->error = null;
67
        }
68
69
    }
70
71
    /**
72
     * Determine if this is a success response object
73
     * @return bool
74
     */
75
    public function successful(): bool
76
    {
77
        return !($this->hasError);
78
    }
79
80
    /**
81
     * @return string
82
     */
83
    public function getCode(): string
84
    {
85
        return $this->code;
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    public function getMessage(): string
92
    {
93
        return $this->message;
94
    }
95
96
    /**
97
     * Returns ClubKonnectErrorException with appropriate ClubKonnect status code and Message if this isn't a successful response, otherwise, null is returned
98
     * @return ClubKonnectErrorException|null
99
     */
100
    public function getErrorException()
101
    {
102
        return $this->error;
103
    }
104
105
    /**
106
     * Return the response body as specified in the ClubKunnect API documentation for the corresponding request. This would be null on fail request
107
     * @return object|array|null
108
     */
109
    public function getBody()
110
    {
111
        return $this->body;
112
    }
113
114
    public function __toString()
115
    {
116
        return json_encode($this->body);
117
    }
118
119
}
120