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

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.

Providers/DSL/QueryCompilerConfiguration.php (3 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 Pinq\Providers\DSL;
4
5
use Pinq\Caching;
6
use Pinq\Expressions as O;
7
use Pinq\Providers\Configuration;
8
use Pinq\Providers\DSL\Compilation\Compilers\IRequestQueryCompiler;
9
use Pinq\Providers\DSL\Compilation\ICompiledQuery;
10
use Pinq\Providers\DSL\Compilation\IQueryTemplate;
11
use Pinq\Providers\DSL\Compilation\IStaticQueryTemplate;
12
use Pinq\Providers\DSL\Compilation\IStaticRequestTemplate;
13
use Pinq\Providers\DSL\Compilation\Parameters;
14
use Pinq\Providers\DSL\Compilation\RequestTemplate;
15
use Pinq\Providers\DSL\Compilation\StaticRequestTemplate;
16
use Pinq\Queries;
17
18
/**
19
 * Base class of the query compiler configuration.
20
 *
21
 * @author Elliot Levin <[email protected]>
22
 */
23
abstract class QueryCompilerConfiguration implements IQueryCompilerConfiguration
24
{
25
    /**
26
     * @var Caching\ICacheAdapter
27
     */
28
    protected $compiledQueryCache;
29
30
    /**
31
     * @var Configuration\IQueryConfiguration
32
     */
33
    protected $queryConfiguration;
34
35
    /**
36
     * @var Queries\Builders\IRequestQueryBuilder
37
     */
38
    protected $requestQueryBuilder;
39
40
    public function __construct()
41
    {
42
        $this->compiledQueryCache  = $this->buildCompiledQueryCache();
43
        $this->queryConfiguration  = $this->buildQueryConfiguration();
44
        $this->requestQueryBuilder = $this->queryConfiguration->getRequestQueryBuilder();
45
    }
46
47
    final public function getQueryConfiguration()
48
    {
49
        return $this->queryConfiguration;
50
    }
51
52
    protected function buildQueryConfiguration()
53
    {
54
        return new Configuration\DefaultQueryConfiguration();
55
    }
56
57
    protected function buildCompiledQueryCache()
58
    {
59
        return Caching\CacheProvider::getCacheAdapter()->forNamespace(get_class($this));
60
    }
61
62
    public function getCompiledQueryCache(Queries\ISourceInfo $sourceInfo)
63
    {
64
        return $this->compiledQueryCache->forNamespace($sourceInfo->getHash());
65
    }
66
67
    public function getCompiledRequestQueryHash(
68
            O\Expression $requestExpression,
69
            /* out */ O\IEvaluationContext $evaluationContext = null)
70
    {
71
        $queryTemplate = $this->loadRequestQueryTemplate(
72
                $requestExpression,
73
                $evaluationContext,
74
                /* out */ $resolvedParameters,
75
                /* out */ $queryCache,
76
                /* out */ $templateHash
77
        );
78
79
        if ($queryTemplate instanceof IStaticRequestTemplate) {
80
            return $templateHash;
81
        }
82
83
        $queryTemplate->resolveStructuralParameters($resolvedParameters, /* out */ $structuralHash);
84
85
        return $templateHash . '-' . $structuralHash;
86
    }
87
88 View Code Duplication
    public function loadCompiledRequestQuery(
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...
89
            O\Expression $requestExpression,
90
            O\IEvaluationContext $evaluationContext = null,
91
            Queries\IResolvedParameterRegistry &$resolvedParameters = null
92
    ) {
93
        $requestTemplate = $this->loadRequestQueryTemplate(
94
                $requestExpression,
95
                $evaluationContext,
96
                /* out */ $resolvedParameters,
97
                /* out */ $queryCache,
98
                /* out */ $templateHash
99
        );
100
101
        return $this->loadCompiledQueryFromTemplate(
102
                $queryCache,
103
                $templateHash,
104
                $requestTemplate,
105
                $resolvedParameters,
106
                [$this, 'compileRequestQuery']
107
        );
108
    }
109
110 View Code Duplication
    protected function loadRequestQueryTemplate(
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...
111
            O\Expression $queryExpression,
112
            O\IEvaluationContext $evaluationContext = null,
113
            /* out */ Queries\IResolvedParameterRegistry &$resolvedParameters = null,
114
            /* out */ Caching\ICacheAdapter &$queryCache = null,
115
            /* out */ &$templateHash)
116
    {
117
        return $this->loadQueryTemplate($queryExpression,
118
                $evaluationContext,
119
                $resolvedParameters,
120
                [$this->requestQueryBuilder, 'resolveRequest'],
121
                [$this->requestQueryBuilder, 'parseRequest'],
122
                [$this, 'createRequestTemplate'],
123
                $queryCache,
124
                $templateHash);
125
    }
126
127
    protected function loadQueryTemplate(
128
            O\Expression $queryExpression,
129
            O\IEvaluationContext $evaluationContext = null,
130
            Queries\IResolvedParameterRegistry &$resolvedParameters = null,
131
            callable $resolveQueryCallback,
132
            callable $parseQueryCallback,
133
            callable $createTemplateCallback,
134
            /* out */ Caching\ICacheAdapter &$queryCache = null,
135
            /* out */ &$templateHash
136
    ) {
137
        /** @var $resolution Queries\IResolvedQuery */
138
        $resolution   = $resolveQueryCallback($queryExpression, $evaluationContext);
139
        $templateHash = $resolution->getHash();
140
141
        $queryCache    = $this->getCompiledQueryCache($resolution->getQueryable()->getSourceInfo());
142
        $queryTemplate = $queryCache->tryGet($templateHash);
143
144
        if (!($queryTemplate instanceof Compilation\IQueryTemplate)) {
145
            /** @var $query Queries\IQuery */
146
            $query = $parseQueryCallback($queryExpression, $evaluationContext);
147
            /** @var $queryTemplate Compilation\IQueryTemplate */
148
            $queryTemplate = $createTemplateCallback($query);
149
            $queryCache->save($templateHash, $queryTemplate);
150
        }
151
152
        $resolvedParameters = $queryTemplate->getParameters()->resolve($resolution);
153
154
        return $queryTemplate;
155
    }
156
157
    protected function loadCompiledQueryFromTemplate(
158
            Caching\ICacheAdapter $queryCache,
159
            $templateHash,
160
            IQueryTemplate $template,
161
            Queries\IResolvedParameterRegistry $parameters,
162
            callable $compileRequestCallback
163
    ) {
164
        if ($template instanceof IStaticQueryTemplate) {
165
            return $template->getCompiledQuery();
166
        }
167
168
        $resolvedStructuralParameters = $template->resolveStructuralParameters($parameters, $hash);
169
        $compiledQueryHash            = md5($templateHash . '-' . $hash);
170
        $compiledQuery                = $queryCache->tryGet($compiledQueryHash);
171
172
        if (!($compiledQuery instanceof ICompiledQuery)) {
173
            $compiledQuery = $compileRequestCallback($template, $resolvedStructuralParameters);
174
            $queryCache->save($compiledQueryHash, $compiledQuery);
175
        }
176
177
        return $compiledQuery;
178
    }
179
180
    /**
181
     * Returns a registry of all the structural parameters of the query.
182
     *
183
     * @param Queries\IQuery $query
184
     *
185
     * @return Parameters\ParameterRegistry
186
     */
187
    abstract protected function locateStructuralParameters(Queries\IQuery $query);
188
189
    protected function createRequestTemplate(Queries\IRequestQuery $requestQuery)
190
    {
191
        $structuralParameters = $this->locateStructuralParameters($requestQuery);
192
193
        if ($structuralParameters->count() === 0) {
194
            return new StaticRequestTemplate($requestQuery->getParameters(), $this->buildCompiledRequestQuery(
195
                    $requestQuery
196
            ));
197
        }
198
199
        return new RequestTemplate($requestQuery, $structuralParameters);
200
    }
201
202
    /**
203
     * Creates a new query with inlined resolved structural parameters.
204
     *
205
     * @param Queries\IQuery                       $query
206
     * @param Parameters\ResolvedParameterRegistry $structuralParameters
207
     *
208
     * @return Queries\IRequestQuery|Queries\IOperationQuery
209
     */
210
    abstract protected function inlineStructuralParameters(
211
            Queries\IQuery $query,
212
            Parameters\ResolvedParameterRegistry $structuralParameters
213
    );
214
215
    public function compileRequestQuery(
216
            Compilation\IRequestTemplate $template,
217
            Parameters\ResolvedParameterRegistry $structuralExpressions
218
    ) {
219
        $structuredQuery = $this->inlineStructuralParameters($template->getQuery(), $structuralExpressions);
220
221
        return $this->buildCompiledRequestQuery($structuredQuery);
0 ignored issues
show
It seems like $structuredQuery defined by $this->inlineStructuralP...$structuralExpressions) on line 219 can also be of type object<Pinq\Queries\IOperationQuery>; however, Pinq\Providers\DSL\Query...dCompiledRequestQuery() does only seem to accept object<Pinq\Queries\IRequestQuery>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
222
    }
223
224
    /**
225
     * @param Queries\IRequestQuery $query
226
     *
227
     * @return Compilation\ICompiledRequest
228
     */
229
    protected function buildCompiledRequestQuery(Queries\IRequestQuery $query)
230
    {
231
        $compiler = $this->getRequestQueryCompiler($query);
232
        $compiler->compile();
233
234
        return $compiler->getCompilation()->asCompiled();
235
    }
236
237
    /**
238
     * @param Queries\IRequestQuery $query
239
     *
240
     * @return IRequestQueryCompiler
241
     */
242
    abstract protected function getRequestQueryCompiler(Queries\IRequestQuery $query);
243
}
244