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/FieldsDependency.php (1 issue)

1
<?php
2
/**
3
 * Fields dependency 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
 * Fields dependency class.
16
 */
17
class FieldsDependency
18
{
19
	/**
20
	 * @var array Views labels
21
	 */
22
	const VIEWS = [
23
		'Create' => 'LBL_VIEW_CREATE',
24
		'Edit' => 'LBL_VIEW_EDIT',
25
		'Detail' => 'LBL_VIEW_DETAIL',
26
		'QuickCreate' => 'LBL_QUICK_CREATE',
27
		'QuickEdit' => 'LBL_QUICK_EDIT',
28
	];
29
	/**
30
	 * @var int
31
	 */
32
	public const GUI_BACKEND = 0;
33
	/**
34
	 * @var int
35
	 */
36
	public const GUI_FRONTEND = 1;
37
	/**
38
	 * Cache variable for list of fields to hide for a record in a view.
39
	 *
40
	 * @see FieldsDependency::getByRecordModel()
41
	 *
42
	 * @var array
43
	 */
44
	public static $recordModelCache = [];
45
46
	/**
47
	 * Get the dependency list for module.
48
	 *
49
	 * @param int      $tabId
50
	 * @param int|null $gui
51
	 *
52
	 * @return array
53
	 */
54
	public static function getByModule(int $tabId, ?int $gui = null): array
55
	{
56
		if (Cache::has('FieldsDependency', $tabId)) {
57
			$fields = Cache::get('FieldsDependency', $tabId);
58
		} else {
59
			$fields = [];
60
			$dataReader = (new \App\Db\Query())->from('s_#__fields_dependency')->where(['status' => 0, 'tabid' => $tabId])
61
				->createCommand()->query();
62
			while ($row = $dataReader->read()) {
63
				$row['gui'] = (int) $row['gui'];
64
				$row['mandatory'] = (int) $row['mandatory'];
65
				$row['conditions'] = Json::decode($row['conditions']) ?? [];
66
				$row['fields'] = Json::decode($row['fields']) ?? [];
67
				$row['conditionsFields'] = Json::decode($row['conditionsFields']) ?? [];
68
				$views = Json::decode($row['views']) ?? [];
69
				unset($row['views']);
70
				foreach ($views as $view) {
71
					$fields[$view][] = $row;
72
				}
73
			}
74
			Cache::save('FieldsDependency', $tabId, $fields);
75
		}
76
		if (isset($gui)) {
77
			foreach ($fields as $view => $rows) {
78
				foreach ($rows as $key => $row) {
79
					if ($gui !== $row['gui']) {
80
						unset($fields[$view][$key]);
81
					}
82
				}
83
			}
84
		}
85
		return $fields;
86
	}
87
88
	/**
89
	 * Get the list of fields to hide for a record in a view.
90
	 *
91
	 * @see FieldsDependency::$recordModelCache
92
	 *
93
	 * @param string               $view
94
	 * @param \Vtiger_Record_Model $recordModel
95
	 * @param bool                 $cache
96
	 *
97
	 * @return array
98
	 */
99
	public static function getByRecordModel(string $view, \Vtiger_Record_Model $recordModel, bool $cache = true): array
100
	{
101
		$cacheKey = $view . $recordModel->getId();
102
		if ($cache && isset(self::$recordModelCache[$cacheKey])) {
103
			return self::$recordModelCache[$cacheKey];
104
		}
105
		$return = [
106
			'show' => ['backend' => [], 'frontend' => [], 'mandatory' => []],
107
			'hide' => ['backend' => [], 'frontend' => [], 'mandatory' => []],
108
			'mandatory' => [],
109
			'conditionsFields' => [],
110
		];
111
		$fields = self::getByModule($recordModel->getModule()->getId());
112
		if ($fields && isset($fields[$view])) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $fields of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
113
			foreach ($fields[$view] as $row) {
114
				$status = (!$row['conditions'] || Condition::checkConditions($row['conditions'], $recordModel)) ? 'show' : 'hide';
115
				if (self::GUI_FRONTEND === $row['gui']) {
116
					$return[$status]['frontend'] = array_merge($return[$status]['frontend'], $row['fields']);
117
				} else {
118
					$return[$status]['backend'] = array_merge($return[$status]['backend'], $row['fields']);
119
				}
120
				if (1 === $row['mandatory']) {
121
					$return[$status]['mandatory'] = array_merge($return[$status]['mandatory'], $row['fields']);
122
					$return['mandatory'] = array_merge($return['mandatory'], $row['fields']);
123
				}
124
				$return['conditionsFields'] = array_merge($return['conditionsFields'], $row['conditionsFields']);
125
			}
126
		}
127
		return self::$recordModelCache[$cacheKey] = $return;
128
	}
129
}
130