Issues (4388)

Security Analysis    no vulnerabilities found

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/Console/Installer.php (135 issues)

1
<?php
0 ignored issues
show
Filename "Installer.php" doesn't match the expected filename "installer.php"
Loading history...
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Header blocks must be separated by a single blank line
Loading history...
This file is missing a doc comment.
Loading history...
Class found in ".php" file; use ".inc" extension instead
Loading history...
2
declare(strict_types=1);
3
4
/**
0 ignored issues
show
The file-level docblock must follow the opening PHP tag in the file header
Loading history...
Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead
Loading history...
Block comments must be started with /*
Loading history...
5
 * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
6
 * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
0 ignored issues
show
Doc comment short description must be on a single line, further text should be a separate paragraph
Loading history...
7
 *
8
 * Licensed under The MIT License
9
 * For full copyright and license information, please see the LICENSE.txt
10
 * Redistributions of files must retain the above copyright notice.
11
 *
12
 * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
0 ignored issues
show
@copyright tag must contain a year and the name of the copyright holder
Loading history...
13
 * @link      https://cakephp.org CakePHP(tm) Project
0 ignored issues
show
Tag value indented incorrectly; expected 1 space but found 6
Loading history...
The tag in position 2 should be the @license tag
Loading history...
14
 * @since     3.0.0
0 ignored issues
show
The tag in position 3 should be the @link tag
Loading history...
Tag value indented incorrectly; expected 1 space but found 5
Loading history...
15
 * @license   https://opensource.org/licenses/mit-license.php MIT License
0 ignored issues
show
The tag in position 4 should be the @since tag
Loading history...
Tag value indented incorrectly; expected 1 space but found 3
Loading history...
16
 */
0 ignored issues
show
Missing @author tag in file comment
Loading history...
Missing @package tag in file comment
Loading history...
Missing @category tag in file comment
Loading history...
Header blocks must be separated by a single blank line
Loading history...
PHP version not specified
Loading history...
17
namespace App\Console;
18
19
if (!defined('STDIN')) {
0 ignored issues
show
Expected 1 space(s) after NOT operator; 0 found
Loading history...
20
    define('STDIN', fopen('php://stdin', 'r'));
21
}
22
23
use Cake\Utility\Security;
24
use Composer\Script\Event;
25
use Exception;
0 ignored issues
show
Non-namespaced classes/interfaces/traits should not be referenced with use statements
Loading history...
26
27
/**
28
 * Provides installation hooks for when this application is installed through
29
 * composer. Customize this class to suit your needs.
0 ignored issues
show
Doc comment short description must be on a single line, further text should be a separate paragraph
Loading history...
30
 */
0 ignored issues
show
Missing @package tag in class comment
Loading history...
Missing @category tag in class comment
Loading history...
Missing @license tag in class comment
Loading history...
Missing @author tag in class comment
Loading history...
Missing @link tag in class comment
Loading history...
31
class Installer
32
{
0 ignored issues
show
Opening brace should be on the same line as the declaration
Loading history...
Opening brace should be on the same line as the declaration for class Installer
Loading history...
33
    /**
34
     * An array of directories to be made writable
35
     */
36
    public const WRITABLE_DIRS = [
37
        'logs',
38
        'tmp',
39
        'tmp/cache',
40
        'tmp/cache/models',
41
        'tmp/cache/persistent',
42
        'tmp/cache/views',
43
        'tmp/sessions',
44
        'tmp/tests',
45
    ];
46
47
    /**
48
     * Does some routine installation tasks so people don't have to.
49
     *
50
     * @param \Composer\Script\Event $event The composer event object.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
51
     * @throws \Exception Exception raised by validator.
0 ignored issues
show
Separate the @param and @throws sections by a blank line.
Loading history...
@throws comment must be on the next line
Loading history...
52
     * @return void
0 ignored issues
show
If there is no return value for a function, there must not be a @return tag.
Loading history...
Separate the @throws and @return sections by a blank line.
Loading history...
53
     */
54
    public static function postInstall(Event $event)
55
    {
0 ignored issues
show
Opening brace should be on the same line as the declaration
Loading history...
56
        $io = $event->getIO();
57
58
        $rootDir = dirname(dirname(__DIR__));
59
60
        static::createAppLocalConfig($rootDir, $io);
61
        static::createWritableDirectories($rootDir, $io);
62
63
        static::setFolderPermissions($rootDir, $io);
64
        static::setSecuritySalt($rootDir, $io);
65
66
        $class = 'Cake\Codeception\Console\Installer';
67
        if (class_exists($class)) {
68
            $class::customizeCodeceptionBinary($event);
69
        }
70
    }
71
72
    /**
73
     * Create config/app_local.php file if it does not exist.
74
     *
75
     * @param string $dir The application's root directory.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 19 spaces after parameter type; 1 found
Loading history...
76
     * @param \Composer\IO\IOInterface $io IO interface to write to console.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 2 spaces after parameter name; 1 found
Loading history...
77
     * @return void
0 ignored issues
show
Separate the @param and @return sections by a blank line.
Loading history...
If there is no return value for a function, there must not be a @return tag.
Loading history...
78
     */
79
    public static function createAppLocalConfig($dir, $io)
0 ignored issues
show
Type hint "\Composer\IO\IOInterface" missing for $io
Loading history...
Type hint "string" missing for $dir
Loading history...
80
    {
0 ignored issues
show
Opening brace should be on the same line as the declaration
Loading history...
81
        $appLocalConfig = $dir . '/config/app_local.php';
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
82
        $appLocalConfigTemplate = $dir . '/config/app_local.example.php';
83
        if (!file_exists($appLocalConfig)) {
0 ignored issues
show
Expected 1 space(s) after NOT operator; 0 found
Loading history...
84
            copy($appLocalConfigTemplate, $appLocalConfig);
85
            $io->write('Created `config/app_local.php` file');
86
        }
87
    }
88
89
    /**
90
     * Create the `logs` and `tmp` directories.
91
     *
92
     * @param string $dir The application's root directory.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 19 spaces after parameter type; 1 found
Loading history...
93
     * @param \Composer\IO\IOInterface $io IO interface to write to console.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 2 spaces after parameter name; 1 found
Loading history...
94
     * @return void
0 ignored issues
show
If there is no return value for a function, there must not be a @return tag.
Loading history...
Separate the @param and @return sections by a blank line.
Loading history...
95
     */
96
    public static function createWritableDirectories($dir, $io)
0 ignored issues
show
Type hint "string" missing for $dir
Loading history...
Type hint "\Composer\IO\IOInterface" missing for $io
Loading history...
97
    {
0 ignored issues
show
Opening brace should be on the same line as the declaration
Loading history...
98
        foreach (static::WRITABLE_DIRS as $path) {
99
            $path = $dir . '/' . $path;
100
            if (!file_exists($path)) {
0 ignored issues
show
Expected 1 space(s) after NOT operator; 0 found
Loading history...
101
                mkdir($path);
102
                $io->write('Created `' . $path . '` directory');
103
            }
104
        }
105
    }
106
107
    /**
108
     * Set globally writable permissions on the "tmp" and "logs" directory.
109
     *
110
     * This is not the most secure default, but it gets people up and running quickly.
0 ignored issues
show
Line exceeds 80 characters; contains 86 characters
Loading history...
111
     *
112
     * @param string $dir The application's root directory.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 19 spaces after parameter type; 1 found
Loading history...
113
     * @param \Composer\IO\IOInterface $io IO interface to write to console.
0 ignored issues
show
Expected 2 spaces after parameter name; 1 found
Loading history...
Parameter comment must be on the next line
Loading history...
114
     * @return void
0 ignored issues
show
Separate the @param and @return sections by a blank line.
Loading history...
If there is no return value for a function, there must not be a @return tag.
Loading history...
115
     */
116
    public static function setFolderPermissions($dir, $io)
0 ignored issues
show
Type hint "string" missing for $dir
Loading history...
Type hint "\Composer\IO\IOInterface" missing for $io
Loading history...
117
    {
0 ignored issues
show
Opening brace should be on the same line as the declaration
Loading history...
118
        // ask if the permissions should be changed
0 ignored issues
show
Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
Loading history...
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
Coding Style Documentation introduced by
Inline comments must start with a capital letter
Loading history...
119
        if ($io->isInteractive()) {
120
            $validator = function ($arg) {
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 12 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
121
                if (in_array($arg, ['Y', 'y', 'N', 'n'])) {
122
                    return $arg;
123
                }
0 ignored issues
show
No blank line found after control structure
Loading history...
124
                throw new Exception('This is not a valid answer. Please choose Y or n.');
125
            };
126
            $setFolderPermissions = $io->askAndValidate(
127
                '<info>Set Folder Permissions ? (Default to Y)</info> [<comment>Y,n</comment>]? ',
128
                $validator,
129
                10,
130
                'Y'
131
            );
132
133
            if (in_array($setFolderPermissions, ['n', 'N'])) {
134
                return;
135
            }
136
        }
137
138
        // Change the permissions on a path and output the results.
139
        $changePerms = function ($path) use ($io) {
140
            $currentPerms = fileperms($path) & 0777;
0 ignored issues
show
Operation must be bracketed
Loading history...
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
141
            $worldWritable = $currentPerms | 0007;
0 ignored issues
show
Operation must be bracketed
Loading history...
142
            if ($worldWritable == $currentPerms) {
0 ignored issues
show
Operator == prohibited; use === instead
Loading history...
143
                return;
144
            }
145
146
            $res = chmod($path, $worldWritable);
147
            if ($res) {
148
                $io->write('Permissions set on ' . $path);
149
            } else {
0 ignored issues
show
Expected newline after closing brace
Loading history...
150
                $io->write('Failed to set permissions on ' . $path);
151
            }
152
        };
153
154
        $walker = function ($dir) use (&$walker, $changePerms) {
155
            $files = array_diff(scandir($dir), ['.', '..']);
156
            foreach ($files as $file) {
157
                $path = $dir . '/' . $file;
158
159
                if (!is_dir($path)) {
0 ignored issues
show
Expected 1 space(s) after NOT operator; 0 found
Loading history...
160
                    continue;
161
                }
162
163
                $changePerms($path);
164
                $walker($path);
165
            }
166
        };
167
168
        $walker($dir . '/tmp');
169
        $changePerms($dir . '/tmp');
170
        $changePerms($dir . '/logs');
171
    }
172
173
    /**
174
     * Set the security.salt value in the application's config file.
175
     *
176
     * @param string $dir The application's root directory.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 19 spaces after parameter type; 1 found
Loading history...
177
     * @param \Composer\IO\IOInterface $io IO interface to write to console.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 2 spaces after parameter name; 1 found
Loading history...
178
     * @return void
0 ignored issues
show
Separate the @param and @return sections by a blank line.
Loading history...
If there is no return value for a function, there must not be a @return tag.
Loading history...
179
     */
180
    public static function setSecuritySalt($dir, $io)
0 ignored issues
show
Type hint "string" missing for $dir
Loading history...
Type hint "\Composer\IO\IOInterface" missing for $io
Loading history...
181
    {
0 ignored issues
show
Opening brace should be on the same line as the declaration
Loading history...
182
        $newKey = hash('sha256', Security::randomBytes(64));
183
        static::setSecuritySaltInFile($dir, $io, $newKey, 'app_local.php');
184
    }
185
186
    /**
187
     * Set the security.salt value in a given file
188
     *
189
     * @param string $dir The application's root directory.
0 ignored issues
show
Expected 19 spaces after parameter type; 1 found
Loading history...
Parameter comment must be on the next line
Loading history...
Expected 4 spaces after parameter name; 1 found
Loading history...
190
     * @param \Composer\IO\IOInterface $io IO interface to write to console.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 5 spaces after parameter name; 1 found
Loading history...
191
     * @param string $newKey key to set in the file
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 19 spaces after parameter type; 1 found
Loading history...
Parameter comment must start with a capital letter
Loading history...
Parameter comment must end with a full stop
Loading history...
192
     * @param string $file A path to a file relative to the application's root
0 ignored issues
show
Parameter comment must end with a full stop
Loading history...
Expected 19 spaces after parameter type; 1 found
Loading history...
Expected 3 spaces after parameter name; 1 found
Loading history...
Parameter comment must be on the next line
Loading history...
193
     * @return void
0 ignored issues
show
Separate the @param and @return sections by a blank line.
Loading history...
If there is no return value for a function, there must not be a @return tag.
Loading history...
194
     */
195
    public static function setSecuritySaltInFile($dir, $io, $newKey, $file)
0 ignored issues
show
Type hint "string" missing for $dir
Loading history...
Type hint "string" missing for $newKey
Loading history...
Type hint "string" missing for $file
Loading history...
Type hint "\Composer\IO\IOInterface" missing for $io
Loading history...
196
    {
0 ignored issues
show
Opening brace should be on the same line as the declaration
Loading history...
197
        $config = $dir . '/config/' . $file;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
198
        $content = file_get_contents($config);
199
200
        $content = str_replace('__SALT__', $newKey, $content, $count);
201
202
        if ($count == 0) {
0 ignored issues
show
Operator == prohibited; use === instead
Loading history...
203
            $io->write('No Security.salt placeholder to replace.');
204
205
            return;
206
        }
207
208
        $result = file_put_contents($config, $content);
209
        if ($result) {
210
            $io->write('Updated Security.salt value in config/' . $file);
211
212
            return;
213
        }
0 ignored issues
show
No blank line found after control structure
Loading history...
214
        $io->write('Unable to update Security.salt value.');
215
    }
216
217
    /**
218
     * Set the APP_NAME value in a given file
219
     *
220
     * @param string $dir The application's root directory.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 5 spaces after parameter name; 1 found
Loading history...
Expected 19 spaces after parameter type; 1 found
Loading history...
221
     * @param \Composer\IO\IOInterface $io IO interface to write to console.
0 ignored issues
show
Parameter comment must be on the next line
Loading history...
Expected 6 spaces after parameter name; 1 found
Loading history...
222
     * @param string $appName app name to set in the file
0 ignored issues
show
Expected 19 spaces after parameter type; 1 found
Loading history...
Parameter comment must start with a capital letter
Loading history...
Parameter comment must end with a full stop
Loading history...
Parameter comment must be on the next line
Loading history...
223
     * @param string $file A path to a file relative to the application's root
0 ignored issues
show
Expected 19 spaces after parameter type; 1 found
Loading history...
Expected 4 spaces after parameter name; 1 found
Loading history...
Parameter comment must end with a full stop
Loading history...
Parameter comment must be on the next line
Loading history...
224
     * @return void
0 ignored issues
show
Separate the @param and @return sections by a blank line.
Loading history...
If there is no return value for a function, there must not be a @return tag.
Loading history...
225
     */
226
    public static function setAppNameInFile($dir, $io, $appName, $file)
0 ignored issues
show
Type hint "string" missing for $appName
Loading history...
Type hint "\Composer\IO\IOInterface" missing for $io
Loading history...
Type hint "string" missing for $dir
Loading history...
Type hint "string" missing for $file
Loading history...
227
    {
0 ignored issues
show
Opening brace should be on the same line as the declaration
Loading history...
228
        $config = $dir . '/config/' . $file;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
229
        $content = file_get_contents($config);
230
        $content = str_replace('__APP_NAME__', $appName, $content, $count);
231
232
        if ($count == 0) {
0 ignored issues
show
Operator == prohibited; use === instead
Loading history...
233
            $io->write('No __APP_NAME__ placeholder to replace.');
234
235
            return;
236
        }
237
238
        $result = file_put_contents($config, $content);
239
        if ($result) {
240
            $io->write('Updated __APP_NAME__ value in config/' . $file);
241
242
            return;
243
        }
0 ignored issues
show
No blank line found after control structure
Loading history...
244
        $io->write('Unable to update __APP_NAME__ value.');
245
    }
0 ignored issues
show
Expected 1 blank line after function; 0 found
Loading history...
246
}
247