Issues (50)

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.

lib/Query/Query.php (2 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
declare(strict_types=1);
4
5
namespace Psi\Component\ObjectAgent\Query;
6
7
final class Query
8
{
9
    private $classFqn;
10
    private $expression;
11
    private $orderings;
12
    private $firstResult;
13
    private $maxResults;
14
    private $joins;
15
    private $selects;
16
17
    private function __construct(
18
        string $classFqn,
19
        array $selects = [],
20
        array $joins = [],
21
        Expression $expression = null,
22
        array $orderings = [],
23
        int $firstResult = null,
24
        int $maxResults = null
25
    ) {
26
        $this->classFqn = $classFqn;
27
        $this->expression = $expression;
28
        $this->orderings = $orderings;
29
        $this->firstResult = $firstResult;
30
        $this->maxResults = $maxResults;
31
        $this->joins = $joins;
32
        $this->selects = $selects;
33
34
        array_walk($joins, function (Join $join) {
0 ignored issues
show
The parameter $join is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
35
        });
36
    }
37
38
    public static function create(
39
        string $classFqn,
40
        array $query = []
41
    ) {
42
        $defaults = [
43
            'selects' => [],
44
            'criteria' => null,
45
            'orderings' => [],
46
            'joins' => [],
47
            'firstResult' => null,
48
            'maxResults' => null,
49
        ];
50
51 View Code Duplication
        if ($diff = array_diff(array_keys($query), array_keys($defaults))) {
0 ignored issues
show
This code seems to be duplicated across 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...
52
            throw new \InvalidArgumentException(sprintf(
53
                'Invalid query keys "%s", valid keys: "%s"',
54
                implode('", "', $diff), implode('", "', array_keys($defaults))
55
            ));
56
        }
57
58
        $query = array_merge($defaults, $query);
59
60
        return new self($classFqn, $query['selects'], $query['joins'], $query['criteria'], $query['orderings'], $query['firstResult'], $query['maxResults']);
61
    }
62
63
    public static function comparison(string $comparator, $value1, $value2 = null): Comparison
64
    {
65
        return new Comparison($comparator, $value1, $value2);
66
    }
67
68
    public static function composite(string $type, ...$expressions): Composite
69
    {
70
        return new Composite($type, $expressions);
71
    }
72
73
    public static function join(string $type, string $alias)
74
    {
75
        return new Join($type, $alias);
76
    }
77
78
    public function cloneWith(array $parts)
79
    {
80
        return self::create(
81
            $this->getClassFqn(),
82
            [
83
                'selects' => array_key_exists('selects', $parts) ? $parts['selects'] : $this->selects,
84
                'criteria' => array_key_exists('criteria', $parts) ? $parts['criteria'] : $this->expression,
85
                'orderings' => array_key_exists('orderings', $parts) ? $parts['orderings'] : $this->orderings,
86
                'joins' => array_key_exists('joins', $parts) ? $parts['joins'] : $this->joins,
87
                'firstResult' => array_key_exists('firstResult', $parts) ? $parts['firstResult'] : $this->firstResult,
88
                'maxResults' => array_key_exists('maxResults', $parts) ? $parts['maxResults'] : $this->maxResults,
89
            ]
90
        );
91
    }
92
93
    public function getClassFqn(): string
94
    {
95
        return $this->classFqn;
96
    }
97
98
    public function hasExpression()
99
    {
100
        return null !== $this->expression;
101
    }
102
103
    public function getExpression(): Expression
104
    {
105
        return $this->expression;
106
    }
107
108
    public function getOrderings(): array
109
    {
110
        return $this->orderings;
111
    }
112
113
    public function getMaxResults()
114
    {
115
        return $this->maxResults;
116
    }
117
118
    public function getFirstResult()
119
    {
120
        return $this->firstResult;
121
    }
122
123
    public function getJoins(): array
124
    {
125
        return $this->joins;
126
    }
127
128
    public function getSelects(): array
129
    {
130
        return $this->selects;
131
    }
132
}
133