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 (7)

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/Database/QueryCacheBuilder.php (4 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 Neurony\QueryCache\Database;
4
5
use Exception;
6
use Illuminate\Database\ConnectionInterface;
7
use Illuminate\Database\Query\Builder as QueryBuilder;
8
use Illuminate\Database\Query\Grammars\Grammar;
9
use Illuminate\Database\Query\Processors\Processor;
10
11
class QueryCacheBuilder extends QueryBuilder
12
{
13
    /**
14
     * The cache tag value.
15
     * The value comes from the Neurony\QueryCache\Traits\IsCacheable.
16
     *
17
     * @var string
18
     */
19
    protected $cacheTag;
20
21
    /**
22
     * The cache type value.
23
     * Can have one of the values present in the QueryCache class -> TYPE_CACHE constants.
24
     * The value comes from the Neurony\QueryCache\IsCacheable.
25
     *
26
     * @var string
27
     */
28
    protected $cacheType;
29
30
    /**
31
     * Create a new query builder instance.
32
     *
33
     * @param ConnectionInterface $connection
34
     * @param Grammar|null $grammar
35
     * @param Processor|null $processor
36
     * @param string|null $cacheTag
37
     * @param int|null $cacheType
38
     */
39
    public function __construct(
40
        ConnectionInterface $connection,
41
        Grammar $grammar = null,
42
        Processor $processor = null,
43
        $cacheTag = null, $cacheType = null
44
    ) {
45
        parent::__construct($connection, $grammar, $processor);
46
47
        $this->cacheType = $cacheType;
0 ignored issues
show
Documentation Bug introduced by
It seems like $cacheType can also be of type integer. However, the property $cacheType is declared as type string. 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...
48
        $this->cacheTag = $cacheTag;
49
    }
50
51
    /**
52
     * Returns a unique string that can identify this query.
53
     *
54
     * @return string
55
     */
56
    public function getQueryCacheKey(): string
57
    {
58
        return json_encode([
59
            $this->toSql() => $this->getBindings(),
60
        ]);
61
    }
62
63
    /**
64
     * Flush the query cache based on the model's cache tag.
65
     *
66
     * @return void
67
     * @throws Exception
68
     */
69
    public function flushQueryCache(): void
70
    {
71
        cache()->store(
72
            app('cache.query')->getAllQueryCacheStore()
73
        )->tags($this->cacheTag)->flush();
74
    }
75
76
    /**
77
     * Insert a new record into the database.
78
     *
79
     * @param array $values
80
     * @return bool
81
     * @throws Exception
82
     */
83
    public function insert(array $values): bool
84
    {
85
        $this->flushQueryCache();
86
87
        return parent::insert($values);
88
    }
89
90
    /**
91
     * Update a record in the database.
92
     *
93
     * @param array $values
94
     * @return int
95
     * @throws Exception
96
     */
97
    public function update(array $values): int
98
    {
99
        $this->flushQueryCache();
100
101
        return parent::update($values);
102
    }
103
104
    /**
105
     * Delete a record from the database.
106
     *
107
     * @param int|null $id
108
     * @return int|null
109
     * @throws Exception
110
     */
111
    public function delete($id = null): ?int
112
    {
113
        $this->flushQueryCache();
114
115
        return parent::delete($id);
116
    }
117
118
    /**
119
     * Run a truncate statement on the table.
120
     *
121
     * @return void
122
     * @throws Exception
123
     */
124
    public function truncate(): void
125
    {
126
        $this->flushQueryCache();
127
128
        parent::truncate();
129
    }
130
131
    /**
132
     * Run the query as a "select" statement against the connection.
133
     *
134
     * @return array
135
     * @throws Exception
136
     */
137
    protected function runSelect(): array
138
    {
139
        switch ($this->cacheType) {
140
            case app('cache.query')->cacheAllQueriesForeverType():
141
                return $this->runSelectWithAllQueriesCached();
142
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
143
            case app('cache.query')->cacheOnlyDuplicateQueriesOnceType():
144
                return $this->runSelectWithDuplicateQueriesCached();
145
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
146
            default:
147
                return parent::runSelect();
148
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
149
        }
150
    }
151
152
    /**
153
     * Run the query as a "select" statement against the connection.
154
     * Also while fetching the results, cache all queries.
155
     *
156
     * @return mixed
157
     * @throws Exception
158
     */
159
    protected function runSelectWithAllQueriesCached()
160
    {
161
        return cache()->store(
162
            app('cache.query')->getAllQueryCacheStore()
163
        )->tags($this->cacheTag)->rememberForever($this->getQueryCacheKey(), function () {
164
            return parent::runSelect();
165
        });
166
    }
167
168
    /**
169
     * Run the query as a "select" statement against the connection.
170
     * Also while fetching the results, cache only duplicate queries for the current request.
171
     *
172
     * @return mixed
173
     * @throws Exception
174
     */
175
    protected function runSelectWithDuplicateQueriesCached()
176
    {
177
        return cache()->store(
178
            app('cache.query')->getDuplicateQueryCacheStore()
179
        )->tags($this->cacheTag)->remember($this->getQueryCacheKey(), 1, function () {
180
            return parent::runSelect();
181
        });
182
    }
183
}
184