Issues (3)

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/Doorman.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
namespace Clarkeash\Doorman;
4
5
use Clarkeash\Doorman\Exceptions\DoormanException;
6
use Clarkeash\Doorman\Exceptions\ExpiredInviteCode;
7
use Clarkeash\Doorman\Exceptions\InvalidInviteCode;
8
use Clarkeash\Doorman\Exceptions\MaxUsesReached;
9
use Clarkeash\Doorman\Exceptions\NotYourInviteCode;
10
use Clarkeash\Doorman\Models\BaseInvite;
11
use Illuminate\Database\Eloquent\ModelNotFoundException;
12
use Illuminate\Support\Str;
13
14
class Doorman
15
{
16
    public $error = '';
17
18
    /**
19
     * @var BaseInvite
20
     */
21
    protected $invite;
22
23 38
    public function __construct(BaseInvite $invite)
24
    {
25 38
        $this->invite = $invite;
26 38
    }
27
28
    /**
29
     * @param             $code
30
     * @param string|null $email
31
     * @throws ExpiredInviteCode
32
     * @throws InvalidInviteCode
33
     * @throws MaxUsesReached
34
     * @throws NotYourInviteCode
35
     */
36 10
    public function redeem($code, string $email = null)
37
    {
38 10
        $invite = $this->prep($code, $email);
39
40 6
        $invite->increment('uses');
0 ignored issues
show
The method increment() cannot be called from this context as it is declared protected in class Illuminate\Database\Eloquent\Model.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
41 6
    }
42
43
    /**
44
     * @param             $code
45
     * @param string|null $email
46
     *
47
     * @return bool
48
     */
49 11
    public function check($code, string $email = null)
50
    {
51
        try {
52 11
            $this->prep($code, $email);
53 6
            return true;
54 5
        } catch (DoormanException $e) {
55 5
            $this->error = $e->getMessage();
56 5
            return false;
57
        }
58
    }
59
60
    /**
61
     * @param             $code
62
     * @param string|null $email
63
     *
64
     * @return \Clarkeash\Doorman\Models\BaseInvite
65
     * @throws \Clarkeash\Doorman\Exceptions\ExpiredInviteCode
66
     * @throws \Clarkeash\Doorman\Exceptions\InvalidInviteCode
67
     * @throws \Clarkeash\Doorman\Exceptions\MaxUsesReached
68
     * @throws \Clarkeash\Doorman\Exceptions\NotYourInviteCode
69
     */
70 21
    protected function prep($code, string $email = null)
71
    {
72 21
        $this->error = '';
73 21
        $invite = $this->lookupInvite($code);
74 19
        $this->validateInvite($invite, $email);
75
76 12
        return $invite;
77
    }
78
79
    /**
80
     * @param $code
81
     *
82
     * @return \Clarkeash\Doorman\Models\BaseInvite
83
     * @throws \Clarkeash\Doorman\Exceptions\InvalidInviteCode
84
     */
85 21
    protected function lookupInvite($code): BaseInvite
86
    {
87
        try {
88 21
            return $this->invite->where('code', '=', Str::upper($code))->firstOrFail();
89 2
        } catch (ModelNotFoundException $e) {
90 2
            throw new InvalidInviteCode(trans('doorman::messages.invalid', ['code' => $code]));
91
        }
92
    }
93
94
    /**
95
     * @param \Clarkeash\Doorman\Models\BaseInvite $invite
96
     * @param string|null $email
97
     *
98
     * @throws \Clarkeash\Doorman\Exceptions\ExpiredInviteCode
99
     * @throws \Clarkeash\Doorman\Exceptions\MaxUsesReached
100
     * @throws \Clarkeash\Doorman\Exceptions\NotYourInviteCode
101
     */
102 19
    protected function validateInvite(BaseInvite $invite, string $email = null)
103
    {
104 19
        if ($invite->isFull()) {
105 2
            throw new MaxUsesReached(trans('doorman::messages.maxed', ['code' => $invite->code]));
106
        }
107
108 17
        if ($invite->hasExpired()) {
109 2
            throw new ExpiredInviteCode(trans('doorman::messages.expired', ['code' => $invite->code]));
110
        }
111
112 15
        if ($invite->isRestricted() && !$invite->isRestrictedFor($email)) {
113 3
            throw new NotYourInviteCode(trans('doorman::messages.restricted', ['code' => $invite->code]));
114
        }
115 12
    }
116
117
    /**
118
     * @return Generator
119
     */
120 17
    public function generate()
121
    {
122 17
        return app(Generator::class);
123
    }
124
}
125