Issues (15)

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/Command/Migrate.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
 * Part of Cli for CodeIgniter
4
 *
5
 * @author     Kenji Suzuki <https://github.com/kenjis>
6
 * @license    MIT License
7
 * @copyright  2015 Kenji Suzuki
8
 * @link       https://github.com/kenjis/codeigniter-cli
9
 */
10
11
namespace Kenjis\CodeIgniter_Cli\Command;
12
13
use Aura\Cli\Status;
14
15
/**
16
 * @property \CI_Migration $migration
17
 * @property \CI_Loader    $load
18
 * @property \CI_Config    $config
19
 */
20
class Migrate extends Command
21
{
22
    public function __invoke($command = null)
23
    {
24
        $this->load->library('migration');
25
        $this->load->config('migration');
26
27
        if ($command === 'status') {
28
            $this->listMigrationFiles();
29
            return;
30
        }
31
32
        if ($command === 'version') {
33
            $this->showVersions();
34
            return;
35
        }
36
37
        // if argument is digits, migrate to the version
38
        if (ctype_digit($command)) {
39
            if ($this->migrateToVersion($command) === false) {
40
                return Status::FAILURE;
41
            } else {
42
                $this->showVersions();
43
                return;
44
            }
45
        }
46
47
        if ($command !== null) {
48
            $this->stdio->errln(
49
                '<<red>>No such command: ' . $command . '<<reset>>'
50
            );
51
            return Status::USAGE;
52
        }
53
54
        // if no argument, migrate to current
55 View Code Duplication
        if ($this->migration->current() === false) {
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...
56
            $this->stdio->errln(
57
                '<<red>>' . $this->migration->error_string() . '<<reset>>'
58
            );
59
            return Status::FAILURE;
60
        } else {
61
            $this->showVersions();
62
        }
63
    }
64
65
    private function migrateToVersion($version)
66
    {
67 View Code Duplication
        if ($this->migration->version($version) === false) {
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...
68
            $this->stdio->errln(
69
                '<<red>>' . $this->migration->error_string() . '<<reset>>'
70
            );
71
            return false;
72
        }
73
        
74
        return true;
75
    }
76
77
    private function getDbVersion()
78
    {
79
        $row = $this->db->select('version')->get($this->config->item('migration_table'))->row();
80
        return $row ? $row->version : '0';
81
    }
82
83
    private function showVersions()
84
    {
85
        $this->stdio->outln(
86
            ' current: <<green>>' . $this->config->item('migration_version') . '<<reset>>'
87
            . ' (in config/migration.php)'
88
        );
89
        $version = $this->getDbVersion();
90
        $this->stdio->outln(
91
            'database: <<bold>>' . $version . '<<reset>>'
92
            . ' (in database table)'
93
        );
94
        $version = $this->getLatestVersion();
95
        $this->stdio->outln(
96
            '  latest: ' . $version . ''
97
            . ' (in migration files)'
98
        );
99
    }
100
101
    private function getLatestVersion()
102
    {
103
        $files = $this->migration->find_migrations();
104
        
105
        if ($files === []) {
106
            return 'null';
107
        }
108
        
109
        end($files);
110
        return key($files);
111
    }
112
113
    private function listMigrationFiles()
114
    {
115
        $this->stdio->outln(
116
            $this->config->item('migration_path')
117
        );
118
119
        $current = $this->config->item('migration_version');
120
        $db = $this->getDbVersion();
121
122
        $files = $this->migration->find_migrations();
123
        foreach ($files as $v => $file) {
124
            if ($v == $current && $v == $db) {
125
                $this->stdio->outln(
126
                    '  <<green>>' . basename($file) .' (current/database)<<reset>>'
127
                );
128
            } elseif ($v == $current) {
129
                $this->stdio->outln(
130
                    '  <<green>>' . basename($file) .' (current)<<reset>>'
131
                );
132
            } elseif ($v == $db) {
133
                $this->stdio->outln(
134
                    '  <<bold>>' . basename($file) .' (database)<<reset>>'
135
                );
136
            } else {
137
                $this->stdio->outln('  ' . basename($file));
138
            }
139
        }
140
    }
141
}
142