Issues (2)

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.

models/Command.php (1 issue)

Labels
Severity

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
 * @package File manager
5
 * @author Iurii Makukh <[email protected]>
6
 * @copyright Copyright (c) 2017, Iurii Makukh <[email protected]>
7
 * @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0+
8
 */
9
10
namespace gplcart\modules\file_manager\models;
11
12
use Exception;
13
use gplcart\core\Handler;
14
use gplcart\core\Hook;
15
use SplFileInfo;
16
17
/**
18
 * Manages basic behaviors and data related to File manager module
19
 */
20
class Command
21
{
22
23
    /**
24
     * Hook class instance
25
     * @var \gplcart\core\Hook $hook
26
     */
27
    protected $hook;
28
29
    /**
30
     * @param Hook $hook
31
     */
32
    public function __construct(Hook $hook)
33
    {
34
        $this->hook = $hook;
35
    }
36
37
    /**
38
     * Returns an array of supported commands
39
     * @return array
40
     */
41
    public function getHandlers()
42
    {
43
        $commands = &gplcart_static('module.file_manager.handlers');
44
45
        if (isset($commands)) {
46
            return $commands;
47
        }
48
49
        $commands = (array) gplcart_config_get(__DIR__ . '/../config/commands.php');
50
51
        foreach ($commands as $id => &$command) {
52
            $command['command_id'] = $id;
53
        }
54
55
        $this->hook->attach('module.file_manager.handlers', $commands, $this);
56
        return $commands;
57
    }
58
59
    /**
60
     * Returns a single command
61
     * @param string $command
62
     * @return array
63
     */
64
    public function get($command)
65
    {
66
        $commands = $this->getHandlers();
67
        return empty($commands[$command]) ? array() : $commands[$command];
68
    }
69
70
    /**
71
     * Returns an array of allowed commands for the given file
72
     * @param SplFileInfo|array $file
73
     * @return array
74
     */
75
    public function getAllowed($file)
76
    {
77
        $commands = array();
78
79
        foreach ($this->getHandlers() as $id => $command) {
80
            if ($this->isAllowed($command, $file)) {
0 ignored issues
show
It seems like $file defined by parameter $file on line 75 can also be of type array; however, gplcart\modules\file_man...ls\Command::isAllowed() does only seem to accept object<SplFileInfo>, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
81
                $commands[$id] = $command;
82
            }
83
        }
84
85
        return $commands;
86
    }
87
88
    /**
89
     * Whether the command is allowed for the file
90
     * @param array $command
91
     * @param SplFileInfo $file
92
     * @return boolean
93
     */
94
    public function isAllowed(array $command, $file)
95
    {
96
        if (!$file instanceof SplFileInfo || empty($command['command_id'])) {
97
            return false;
98
        }
99
100
        $result = $this->callHandler($command, 'allowed', array($file, $command));
101
102
        return is_bool($result) ? $result : false;
103
    }
104
105
    /**
106
     * Call a command handler
107
     * @param array $command
108
     * @param string $method
109
     * @param array $args
110
     * @return mixed
111
     */
112
    public function callHandler(array $command, $method, $args = array())
113
    {
114
        try {
115
            $handlers = $this->getHandlers();
116
            return Handler::call($handlers, $command['command_id'], $method, $args);
117
        } catch (Exception $ex) {
118
            return $ex->getMessage();
119
        }
120
    }
121
122
    /**
123
     * Submit a command
124
     * @param array $command
125
     * @param array $args
126
     * @return array
127
     */
128
    public function submit(array $command, array $args)
129
    {
130
        $result = (array) $this->callHandler($command, 'submit', $args);
131
        $result += array('redirect' => '', 'message' => '', 'severity' => '');
132
        return $result;
133
    }
134
135
    /**
136
     * Returns an array of data used to display the command
137
     * @param array $command
138
     * @param array $args
139
     * @return array
140
     */
141
    public function getView(array $command, array $args)
142
    {
143
        return $this->callHandler($command, 'view', $args);
144
    }
145
146
}
147