Issues (52)

Security Analysis    not enabled

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.

include/read_dump.lib.php (11 issues)

1
<?php
2
3
/*
4
*******************************************************
5
***													***
6
*** backpack										***
7
*** Cedric MONTUY pour CHG-WEB                      ***
8
*** Original author : Yoshi Sakai					***
9
***													***
10
*******************************************************
11
*/
12
function PMA_splitSqlFile(&$ret, $sql, $release)
0 ignored issues
show
The parameter $release is not used and could be removed. ( Ignorable by Annotation )

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

12
function PMA_splitSqlFile(&$ret, $sql, /** @scrutinizer ignore-unused */ $release)

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

Loading history...
13
{
14
    $sql          = rtrim($sql, "\n\r");
15
    $sql_len      = strlen($sql);
16
    $char         = '';
0 ignored issues
show
The assignment to $char is dead and can be removed.
Loading history...
17
    $string_start = '';
18
    $in_string    = false;
19
    $nothing      = true;
20
    $time0        = time();
21
22
    for ($i = 0; $i < $sql_len; ++$i) {
23
        $char = $sql[$i];
24
25
        // We are in a string, check for not escaped end of strings except for
26
        // backquotes that can't be escaped
27
        if ($in_string) {
28
            for (; ;) {
29
                $i = strpos($sql, $string_start, $i);
30
                // No end of string found -> add the current substring to the
31
                // returned array
32
                if (!$i) {
33
                    $ret[] = $sql;
34
                    return true;
35
                }
36
                // Backquotes or no backslashes before quotes: it's indeed the
37
                // end of the string -> exit the loop
38
39
                if ('`' == $string_start || '\\' != $sql[$i - 1]) {
40
                    $string_start = '';
41
                    $in_string    = false;
42
                    break;
43
                }
44
                // one or more Backslashes before the presumed end of string...
45
46
                // ... first checks for escaped backslashes
47
                $j                 = 2;
48
                $escaped_backslash = false;
49
                while ($i - $j > 0 && '\\' == $sql[$i - $j]) {
50
                    $escaped_backslash = !$escaped_backslash;
0 ignored issues
show
The condition $escaped_backslash is always false.
Loading history...
51
                    $j++;
52
                }
53
                // ... if escaped backslashes: it's really the end of the
54
                // string -> exit the loop
55
                if ($escaped_backslash) {
56
                    $string_start = '';
57
                    $in_string    = false;
58
                    break;
59
                }
60
                // ... else loop
61
62
                $i++; // end if...elseif...else
63
            } // end for
64
        } // end if (in string)
65
66
        // lets skip comments (/*, -- and #)
67
        elseif (('-' == $char && $sql_len > $i + 2 && '-' == $sql[$i + 1] && $sql[$i + 2] <= ' ') || '#' == $char || ('/' == $char && $sql_len > $i + 1 && '*' == $sql[$i + 1])) {
68
            $i = strpos($sql, '/' == $char ? '*/' : "\n", $i);
69
            // didn't we hit end of string?
70
            if (false === $i) {
71
                break;
72
            }
73
            if ('/' == $char) {
74
                $i++;
75
            }
76
        } // We are not in a string, first check for delimiter...
77
        elseif (';' == $char) {
78
            // if delimiter found, add the parsed part to the returned array
79
            $ret[]   = ['query' => substr($sql, 0, $i), 'empty' => $nothing];
80
            $nothing = true;
81
            $sql     = ltrim(substr($sql, min($i + 1, $sql_len)));
82
            $sql_len = strlen($sql);
83
            if ($sql_len !== 0) {
84
                $i = -1;
85
            } else {
86
                // The submited statement(s) end(s) here
87
                return true;
88
            }
89
        } // end else if (is delimiter)
90
91
        // ... then check for start of a string,...
92
        elseif (('"' == $char) || ('\'' == $char) || ('`' == $char)) {
93
            $in_string    = true;
94
            $nothing      = false;
95
            $string_start = $char;
96
        } // end else if (is start of string)
97
98
        elseif ($nothing) {
99
            $nothing = false;
100
        }
101
102
        // loic1: send a fake header each 30 sec. to bypass browser timeout
103
        $time1 = time();
104
        if ($time1 >= $time0 + 30) {
105
            $time0 = $time1;
106
            header('X-pmaPing: Pong');
107
        } // end if
108
    } // end for
109
110
    // add any rest to the returned array
111
    if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) {
112
        $ret[] = ['query' => $sql, 'empty' => $nothing];
113
    }
114
115
    return true;
116
} // end of the 'PMA_splitSqlFile()' function
117
118
/**
119
 * Reads (and decompresses) a (compressed) file into a string
120
 *
121
 * @param string   the path to the file
122
 * @param string   the MIME type of the file, if empty MIME type is autodetected
123
 *
124
 * @return  string   the content of the file or
125
 *          boolean  FALSE in case of an error.
126
 * @global  array    the phpMyAdmin configuration
127
 *
128
 */
129
function PMA_readFile($path, $mime = '')
130
{
131
    global $cfg;
132
133
    if (!is_file($path)) {
134
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
135
    }
136
    switch ($mime) {
137
        case '':
138
            if (!$file = fopen($path, 'rb')) {
139
                return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
140
            }
141
            $test = fread($file, 3);
142
            fclose($file);
143
            if ($test[0] === chr(31) && $test[1] === chr(139)) {
144
                return PMA_readFile($path, 'application/x-gzip');
145
            }
146
            if ('BZh' == $test) {
147
                return PMA_readFile($path, 'application/x-bzip');
148
            }
149
            return PMA_readFile($path, 'text/plain');
150
        case 'text/plain':
151
            if (!$file = fopen($path, 'rb')) {
152
                return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
153
            }
154
            $content = fread($file, filesize($path));
155
            fclose($file);
156
            break;
157
        case 'application/x-gzip':
158
            if ($cfg['GZipDump'] && function_exists('gzopen')) {
159
                if (!$file = gzopen($path, 'rb')) {
160
                    return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
161
                }
162
                $content = '';
163
                while (!gzeof($file)) {
164
                    $content .= gzgetc($file);
165
                }
166
                gzclose($file);
167
            } else {
168
                return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
169
            }
170
            break;
171
        case 'application/x-bzip':
172
            if ($cfg['BZipDump'] && function_exists('bzdecompress')) {
173
                if (!$file = fopen($path, 'rb')) {
174
                    return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
175
                }
176
                $content = fread($file, filesize($path));
177
                fclose($file);
178
                $content = bzdecompress($content);
179
            } else {
180
                return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
181
            }
182
            break;
183
        default:
184
            return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type string.
Loading history...
185
    }
186
    return $content;
187
}
188