Issues (4069)

Security Analysis    not enabled

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.

modules/ModuleBuilder/MB/MBVardefs.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
 * SugarCRM Community Edition is a customer relationship management program developed by
4
 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
5
6
 * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
7
 * Copyright (C) 2011 - 2014 Salesagility Ltd.
8
 *
9
 * This program is free software; you can redistribute it and/or modify it under
10
 * the terms of the GNU Affero General Public License version 3 as published by the
11
 * Free Software Foundation with the addition of the following permission added
12
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
13
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
14
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15
 *
16
 * This program is distributed in the hope that it will be useful, but WITHOUT
17
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
19
 * details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License along with
22
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
23
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24
 * 02110-1301 USA.
25
 *
26
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
27
 * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].
28
 *
29
 * The interactive user interfaces in modified source and object code versions
30
 * of this program must display Appropriate Legal Notices, as required under
31
 * Section 5 of the GNU Affero General Public License version 3.
32
 *
33
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
34
 * these Appropriate Legal Notices must retain the display of the "Powered by
35
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
36
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
37
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
38
 ********************************************************************************/
39
40
class MBVardefs{
41
	var $templates = array();
42
	var $iTemplates = array();
43
	var $vardefs = array();
44
	var $vardef = array();
45
	var $path = '';
46
	var $name = '';
47
	var $errors = array();
48
49
	function __construct($name, $path, $key_name){
50
		$this->path = $path;
51
		$this->name = $name;
52
		$this->key_name = $key_name;
53
		$this->load();
54
	}
55
56
    /**
57
     * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
58
     */
59
    function MBVardefs($name, $path, $key_name){
60
        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
61
        if(isset($GLOBALS['log'])) {
62
            $GLOBALS['log']->deprecated($deprecatedMessage);
63
        }
64
        else {
65
            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
66
        }
67
        self::__construct($name, $path, $key_name);
68
    }
69
70
71
	function loadTemplate($by_group, $template, $file){
72
		$module = $this->name;
73
		$table_name = $this->name;
74
		$object_name = $this->key_name;
75
		$_object_name = strtolower($this->key_name);
76
77
		// required by the vardef template for team security in SugarObjects
78
		$table_name = strtolower($module);
79
80
		if(file_exists($file)){
81
			include($file);
82
            if (isset($vardefs))
0 ignored issues
show
The variable $vardefs seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
83
            {
84
                if($by_group){
85
                    $this->vardefs['fields'] [$template]= $vardefs['fields'];
86
                }else{
87
                    $this->vardefs['fields']= array_merge($this->vardefs['fields'], $vardefs['fields']);
88
                    if(!empty($vardefs['relationships'])){
89
                        $this->vardefs['relationships']= array_merge($this->vardefs['relationships'], $vardefs['relationships']);
90
                    }
91
                }
92
            }
93
		}
94
        //Bug40450 - Extra 'Name' field in a File type module in module builder
95
        if(array_key_exists('file', $this->templates))
96
        {
97
            unset($this->vardefs['fields']['name']);
98
            unset($this->vardefs['fields']['file']['name']);
99
        }
100
101
	}
102
103
	function mergeVardefs($by_group=false){
104
		$this->vardefs = array(
105
					'fields'=>array(),
106
					'relationships'=>array(),
107
		);
108
//		$object_name = $this->key_name;
109
//		$_object_name = strtolower($this->name);
110
		$module_name = $this->name;
111
		$this->loadTemplate($by_group,'basic',  MB_TEMPLATES . '/basic/vardefs.php');
112
		foreach($this->iTemplates as $template=>$val){
113
			$file = MB_IMPLEMENTS . '/' . $template . '/vardefs.php';
114
			$this->loadTemplate($by_group,$template, $file);
115
		}
116
		foreach($this->templates as $template=>$val){
117
			if($template == 'basic')continue;
118
			$file = MB_TEMPLATES . '/' . $template . '/vardefs.php';
119
			$this->loadTemplate($by_group,$template, $file);
120
		}
121
122
		if($by_group){
123
			$this->vardefs['fields'][$this->name] = $this->vardef['fields'];
124
		}else{
125
			$this->vardefs['fields'] = array_merge($this->vardefs['fields'], $this->vardef['fields']);
126
		}
127
	}
128
129
	function updateVardefs($by_group=false){
130
		$this->mergeVardefs($by_group);
131
	}
132
133
134
	function getVardefs(){
135
		return $this->vardefs;
136
	}
137
138
	function getVardef(){
139
		return $this->vardef;
140
	}
141
142
143
    function addFieldVardef($vardef)
144
    {
145
        if(!isset($vardef['default']) || strlen($vardef['default']) == 0)
146
        {
147
            unset($vardef['default']);
148
        }
149
        $this->vardef['fields'][$vardef['name']] = $vardef;
150
    }
151
152
	function deleteField($field){
153
		unset($this->vardef['fields'][$field->name]);
154
	}
155
156
	function save(){
157
		$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
158
		write_array_to_file('vardefs', $this->vardef, $this->path . '/vardefs.php','w', $header);
159
	}
160
161
	function build($path){
162
		$header = file_get_contents('modules/ModuleBuilder/MB/header.php');
163
		write_array_to_file('dictionary["' . $this->name . '"]', $this->getVardefs(), $path . '/vardefs.php', 'w', $header);
164
	}
165
	function load(){
166
		$this->vardef = array('fields'=>array(), 'relationships'=>array());
167
		if(file_exists($this->path . '/vardefs.php')){
168
			include($this->path. '/vardefs.php');
169
			$this->vardef = $vardefs;
170
		}
171
	}
172
173
174
175
176
177
}
178
?>