Issues (3882)

Security Analysis    39 potential vulnerabilities

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 (9)
Response Splitting can be used to send arbitrary responses.
  File Manipulation (2)
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 (7)
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 (13)
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 (8)
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.

app/Cli.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * CLI file.
4
 *
5
 * @package App
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Mariusz Krzaczkowski <[email protected]>
10
 */
11
12
namespace App;
13
14
/**
15
 * CLI class.
16
 */
17
class Cli
18
{
19
	/** @var \League\CLImate\CLImate CLImate instance. */
20
	public $climate;
21
22
	/** @var bool Php support exec */
23
	public $exec = true;
24
25
	/**
26
	 * Construct.
27
	 */
28
	public function __construct()
29
	{
30
		$this->exec = \function_exists('exec');
31
		$this->climate = new \League\CLImate\CLImate();
32
		if (!$this->exec) {
33
			$this->climate->setUtil(new \League\CLImate\Util\UtilFactory(new class() extends \League\CLImate\Util\System\System {
34
				public function width()
35
				{
36
					return 120;
37
				}
38
39
				public function height()
40
				{
41
					return 40;
42
				}
43
44
				protected function systemHasAnsiSupport()
45
				{
46
					return true;
47
				}
48
49
				public function exec($command, $full = false)
50
				{
51
					return '';
52
				}
53
			}));
54
		}
55
		$this->climate->clear();
56
		if (\function_exists('getmyuid') && getmyuid() !== fileowner(__FILE__)) {
57
			$this->climate->to('error')->lightRed('Error:  YetiForce CLI works only on the OS user who owns the CRM files');
58
			return;
59
		}
60
		if (\PHP_SAPI !== 'cli') {
61
			$this->climate->to('error')->lightRed('Error: YetiForce CLI only works from the operating system console (CLI)');
62
			return;
63
		}
64
		$this->climate->lightGreen()->border('─', 200);
65
		$this->climate->tab(2)->lightGreen('Y e t i F o r c e     C L I');
66
		$this->climate->lightGreen()->border('─', 200);
67
		$this->climate->white('Version: ' . Version::get() . ' | CRM URL: ' . \Config\Main::$site_URL);
0 ignored issues
show
The type Config\Main was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
68
		$this->climate->lightGreen()->border('─', 200);
69
		\App\User::setCurrentUserId(\Users::getActiveAdminId());
70
		\App\Language::setTemporaryLanguage('en-US');
71
72
		$this->climate->arguments->add([
73
			'module' => [
74
				'prefix' => 'm',
75
				'description' => 'Module name',
76
			],
77
			'action' => [
78
				'prefix' => 'a',
79
				'description' => 'Module action name',
80
			],
81
			'help' => [
82
				'prefix' => 'h',
83
				'description' => 'Help',
84
			],
85
		]);
86
		$this->climate->arguments->parse();
87
		if ($this->climate->arguments->defined('help')) {
88
			$this->showHelp();
89
			$this->climate->usage();
90
		} elseif ($this->climate->arguments->defined('module') && !$this->climate->arguments->defined('action') && !empty($this->climate->arguments->get('module'))) {
91
			$this->actionsList($this->climate->arguments->get('module'));
92
		} elseif ($this->climate->arguments->defined('module') && $this->climate->arguments->defined('action')) {
93
			$className = "\\App\\Cli\\{$this->climate->arguments->get('module')}";
94
			$instance = new $className($this);
95
			if (!method_exists($instance, $this->climate->arguments->get('action'))) {
96
				$this->climate->to('error')->lightRed("Error: Action '{$this->climate->arguments->get('action')}' does not exist in '{$this->climate->arguments->get('module')}'");
97
				return;
98
			}
99
			$this->climate->backgroundBlue()->out($instance->methods[$this->climate->arguments->get('action')]);
100
			$this->climate->border('─', 200);
101
			\call_user_func([$instance, $this->climate->arguments->get('action')]);
102
		} else {
103
			$this->modulesList();
104
		}
105
	}
106
107
	/**
108
	 * Show modules list.
109
	 *
110
	 * @return void
111
	 */
112
	public function modulesList(): void
113
	{
114
		if (!$this->exec) {
115
			$this->showHelp();
116
			$this->climate->usage();
117
			return;
118
		}
119
		$modules = $this->getModulesList();
120
		$modules['Exit'] = 'Exit';
121
		$input = $this->climate->radio('Module:', $modules);
122
		$module = $input->prompt();
123
		if ('Exit' === $module || empty($module)) {
124
			return;
125
		}
126
		$this->climate->clear();
127
		$this->actionsList($module);
128
	}
129
130
	/**
131
	 * Get modules list.
132
	 *
133
	 * @return string[]
134
	 */
135
	private function getModulesList(): array
136
	{
137
		$modules = [];
138
		foreach (new \DirectoryIterator(ROOT_DIRECTORY . '/app/Cli') as $fileInfo) {
139
			if ($fileInfo->isFile() && 'Base' !== $fileInfo->getBasename('.php')) {
140
				$module = $fileInfo->getBasename('.php');
141
				$className = "\\App\\Cli\\{$module}";
142
				$instance = new $className($this);
143
				$modules[$module] = $instance->moduleName;
144
			}
145
		}
146
		return $modules;
147
	}
148
149
	/**
150
	 * Show actions list.
151
	 *
152
	 * @param string $module
153
	 *
154
	 * @return void
155
	 */
156
	public function actionsList(string $module): void
157
	{
158
		$className = "\\App\\Cli\\{$module}";
159
		if (!class_exists($className)) {
160
			$this->climate->to('error')->lightRed("Error: Module '$module' does not exist");
161
			return;
162
		}
163
		if (!$this->exec) {
164
			$this->showHelp();
165
			$this->climate->usage();
166
			return;
167
		}
168
		$instance = new $className($this);
169
		$input = $this->climate->radio('Action:', array_merge($instance->methods, ['Exit' => 'Exit']));
170
		$action = $input->prompt();
171
		$this->climate->clear();
172
		if ('Exit' === $action) {
173
			$this->modulesList();
174
		} else {
175
			\call_user_func([$instance, $action]);
176
		}
177
	}
178
179
	/**
180
	 * Show help.
181
	 *
182
	 * @return void
183
	 */
184
	private function showHelp(): void
185
	{
186
		if ($this->climate->arguments->defined('module')) {
187
			$module = $this->climate->arguments->get('module');
188
			$className = "\\App\\Cli\\{$module}";
189
			if (!class_exists($className)) {
190
				$this->climate->to('error')->lightRed("Error: Module '{$this->climate->arguments->get('module')}' does not exist");
191
				return;
192
			}
193
			$instance = new $className($this);
194
			if ($this->climate->arguments->defined('action') && !empty($this->climate->arguments->get('action'))) {
195
				if (!method_exists($instance, $this->climate->arguments->get('action'))) {
196
					$this->climate->to('error')->lightRed("Error: Action '{$this->climate->arguments->get('action')}' does not exist in '{$this->climate->arguments->get('module')}'");
197
					return;
198
				}
199
				$instance->helpMode = true;
200
				\call_user_func([$instance, $this->climate->arguments->get('action')]);
201
			} else {
202
				$this->climate->white('Action list for module ' . $this->climate->arguments->get('module'));
203
				$this->climate->columns(array_merge([' > Action name <' => ' > Description <'], $instance->methods));
204
				$this->climate->lightGreen()->border('─', 200);
205
				foreach (array_keys($instance->methods) as $method) {
206
					$this->climate->white("php cli.php -m $module -a $method");
207
				}
208
				$this->climate->lightGreen()->border('─', 200);
209
			}
210
		} else {
211
			$modules = $this->getModulesList();
212
			$modules = array_keys($modules);
213
			$this->climate->white('Modules list:')->columns($modules);
214
			$this->climate->lightGreen()->border('─', 200);
215
			foreach ($modules as $module) {
216
				$this->climate->white("php cli.php -m $module");
217
			}
218
			$this->climate->lightGreen()->border('─', 200);
219
		}
220
	}
221
}
222