Issues (19)

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/QueryBuilder/Clause/JoinTrait.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
/**
4
 * This file is part of UnderQuery package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\UnderQuery\QueryBuilder\Clause;
13
14
use Phuria\UnderQuery\JoinType;
15
use Phuria\UnderQuery\Language\Expression\RelativeClause;
16
use Phuria\UnderQuery\Table\JoinMetadata;
17
use Phuria\UnderQuery\Table\TableInterface;
18
19
/**
20
 * @author Beniamin Jonatan Šimko <[email protected]>
21
 */
22
trait JoinTrait
23
{
24
    /**
25
     * @var array $joinTables
26
     */
27
    private $joinTables = [];
28
29
    /**
30
     * @param mixed       $table
31
     * @param string|null $alias
32
     *
33
     * @return TableInterface
34
     */
35
    abstract public function createTable($table, $alias = null);
36
37
    /**
38
     * @param string      $joinType
39
     * @param mixed       $table
40
     * @param string|null $alias
41
     * @param string|null $joinOn
42
     *
43
     * @return TableInterface
44
     */
45
    public function doJoin($joinType, $table, $alias = null, $joinOn = null)
46 3
    {
47
        $this->joinTables[] = $tableObject = $this->createTable($table, $alias);
48 3
49
        $joinMetadata = new JoinMetadata();
50 3
        $joinMetadata->setJoinType($joinType);
51 3
52
        if ($joinOn) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $joinOn of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
53 3
            $relativeOn = new RelativeClause($tableObject, $joinOn, RelativeClause::SELF_DIRECTIVE);
54 1
            $joinMetadata->setJoinOn($relativeOn);
55 1
        }
56 1
57
        $tableObject->setJoinMetadata($joinMetadata);
58 3
        is_callable($table) && $table($tableObject, $joinMetadata);
59 3
60
        return $tableObject;
61 3
    }
62
63
    /**
64
     * @param mixed       $table
65
     * @param string|null $alias
66
     * @param string|null $joinOn
67
     *
68
     * @return TableInterface
69
     */
70
    public function join($table, $alias = null, $joinOn = null)
71 3
    {
72
        return $this->doJoin(JoinType::JOIN, $table, $alias, $joinOn);
73 3
    }
74
75
    /**
76
     * @param mixed       $table
77
     * @param string|null $alias
78
     * @param string|null $joinOn
79
     *
80
     * @return TableInterface
81
     */
82
    public function straightJoin($table, $alias = null, $joinOn = null)
83 1
    {
84
        return $this->doJoin(JoinType::STRAIGHT_JOIN, $table, $alias, $joinOn);
85 1
    }
86
87
    /**
88
     * @param mixed       $table
89
     * @param string|null $alias
90
     * @param string|null $joinOn
91
     *
92
     * @return TableInterface
93
     */
94
    public function crossJoin($table, $alias = null, $joinOn = null)
95 1
    {
96
        return $this->doJoin(JoinType::CROSS_JOIN, $table, $alias, $joinOn);
97 1
    }
98
99
    /**
100
     * @param mixed       $table
101
     * @param string|null $alias
102
     * @param string|null $joinOn
103
     *
104
     * @return TableInterface
105
     */
106
    public function leftJoin($table, $alias = null, $joinOn = null)
107 1
    {
108
        return $this->doJoin(JoinType::LEFT_JOIN, $table, $alias, $joinOn);
109 1
    }
110
111
    /**
112
     * @param mixed       $table
113
     * @param string|null $alias
114
     * @param string|null $joinOn
115
     *
116
     * @return TableInterface
117
     */
118
    public function rightJoin($table, $alias = null, $joinOn = null)
119 1
    {
120
        return $this->doJoin(JoinType::RIGHT_JOIN, $table, $alias, $joinOn);
121 1
    }
122
123
    /**
124
     * @param mixed       $table
125
     * @param string|null $alias
126
     * @param string|null $joinOn
127
     *
128
     * @return TableInterface
129
     */
130
    public function innerJoin($table, $alias = null, $joinOn = null)
131 1
    {
132
        return $this->doJoin(JoinType::INNER_JOIN, $table, $alias, $joinOn);
133 1
    }
134
135
    /**
136
     * @return array
137
     */
138
    public function getJoinTables()
139 1
    {
140
        return $this->joinTables;
141
    }
142
}