Issues (6)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/AbstractQueryBuilder.php (2 issues)

1
<?php
2
/**
3
 * This file is part of the DbImporter package.
4
 *
5
 * (c) Mauro Cassani<https://github.com/mauretto78>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace DbImporter\QueryBuilder;
12
13
use DbImporter\QueryBuilder\Contracts\QueryBuilderInterface;
14
use Doctrine\Common\Collections\ArrayCollection;
15
16
abstract class AbstractQueryBuilder implements QueryBuilderInterface
17
{
18
    /**
19
     * @var string
20
     */
21
    protected $table;
22
23
    /**
24
     * @var bool
25
     */
26
    protected $debug;
27
28
    /**
29
     * @var array
30
     */
31
    protected $mapping;
32
33
    /**
34
     * @var ArrayCollection
35
     */
36
    protected $data;
37
38
    /**
39
     * MySqlQueryBuilderTest constructor.
40
     * @param $table
41
     * @param $debug
42
     * @param array $mapping
43
     * @param array $data
44
     */
45
    public function __construct(
46
        $table,
47
        array $mapping,
48
        array $data,
49
        $debug
50
    ) {
51
        $this->table = $table;
52
        $this->mapping = $mapping;
53
        $this->data = $data;
0 ignored issues
show
Documentation Bug introduced by
It seems like $data of type array is incompatible with the declared type Doctrine\Common\Collections\ArrayCollection of property $data.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
54
        $this->debug = $debug;
55
    }
56
57
    /**
58
     * @param $index
59
     * @param $array
60
     * @return string
61
     */
62
    protected function appendComma($index, $array)
63
    {
64
        if ($index < (count($array))) {
65
            return  ', ';
66
        }
67
    }
68
69
    /**
70
     * @param $mode
71
     * @return array
72
     */
73
    protected function getQueriesBody($mode, $limit)
74
    {
75
        if ($mode == 'multiple') {
76
            return $this->getMultipleInsertQueriesBody($limit);
77
        }
78
79
        return $this->getSingleInsertQueriesBody();
80
    }
81
82
    /**
83
     * @return array
84
     */
85
    protected function getMultipleInsertQueriesBody($limit)
86
    {
87
        $sql = [];
88
        $data = array_chunk($this->data, $limit, true);
0 ignored issues
show
$this->data of type Doctrine\Common\Collections\ArrayCollection is incompatible with the type array expected by parameter $input of array_chunk(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

88
        $data = array_chunk(/** @scrutinizer ignore-type */ $this->data, $limit, true);
Loading history...
89
90
        foreach ($data as $array) {
91
            $count = count($array);
92
            $string = '';
93
94
            for ($c = 1; $c <= $count; $c++) {
95
                $string .= '('.$this->getItemPlaceholders($c).')';
96
                $string .= $this->appendComma($c, $array);
97
            }
98
99
            $sql[] = $string;
100
        }
101
102
        return $sql;
103
    }
104
105
    /**
106
     * @return array
107
     */
108
    protected function getSingleInsertQueriesBody()
109
    {
110
        $sql = [];
111
        $count = count($this->data);
112
113
        for ($c = 1; $c <= $count; $c++) {
114
            $sql[] = '('.$this->getItemPlaceholders().')';
115
        }
116
117
        return $sql;
118
    }
119
120
    /**
121
     * @param $index
122
     * @return string
123
     */
124
    private function getItemPlaceholders($index = null)
125
    {
126
        $sql = '';
127
        $c = 1;
128
        $values = array_values($this->mapping);
129
130
        foreach ($values as $map) {
131
            $sql .= ($index) ? ':'.$map.'_'.$index : ':'.$map;
132
            $sql .= $this->appendComma($c, $values);
133
            $c++;
134
        }
135
136
        return $sql;
137
    }
138
}
139