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/UpgradeWizard/SugarMerge/SearchMerge.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
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
/*********************************************************************************
4
 * SugarCRM Community Edition is a customer relationship management program developed by
5
 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
6
7
 * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
8
 * Copyright (C) 2011 - 2014 Salesagility Ltd.
9
 *
10
 * This program is free software; you can redistribute it and/or modify it under
11
 * the terms of the GNU Affero General Public License version 3 as published by the
12
 * Free Software Foundation with the addition of the following permission added
13
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
14
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
15
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
16
 *
17
 * This program is distributed in the hope that it will be useful, but WITHOUT
18
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
20
 * details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License along with
23
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
24
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
 * 02110-1301 USA.
26
 *
27
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
28
 * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].
29
 *
30
 * The interactive user interfaces in modified source and object code versions
31
 * of this program must display Appropriate Legal Notices, as required under
32
 * Section 5 of the GNU Affero General Public License version 3.
33
 *
34
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
35
 * these Appropriate Legal Notices must retain the display of the "Powered by
36
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
37
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
38
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
39
 ********************************************************************************/
40
41
/*********************************************************************************
42
43
 * Description:  Defines the English language pack for the base application.
44
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
45
 * All Rights Reserved.
46
 * Contributor(s): ______________________________________..
47
 ********************************************************************************/
48
49
require_once('modules/UpgradeWizard/SugarMerge/ListViewMerge.php');
50
/**
51
 * SearchMerge is a class for merging search meta data together. This search meta-data has a listing of fields similar to ListViews
52
 *
53
 */
54
class SearchMerge extends ListViewMerge{
55
	protected $varName = 'searchdefs';
56
	protected $viewDefs = 'Search';
57
	protected $panelName = 'layout';
58
	
59
	/**
60
	 * Loads the meta data of the original, new, and custom file into the variables originalData, newData, and customData respectively it then transforms them into a structure that EditView Merge would understand
61
	 *
62
	 * @param STRING $module - name of the module's files that are to be merged
63
	 * @param STRING $original_file - path to the file that originally shipped with sugar
64
	 * @param STRING $new_file - path to the new file that is shipping with the patch 
65
	 * @param STRING $custom_file - path to the custom file
66
	 */
67
	protected function loadData($module, $original_file, $new_file, $custom_file){
68
		EditViewMerge::loadData($module, $original_file, $new_file, $custom_file);
69
		$this->originalData = array($module=>array( $this->viewDefs=>$this->originalData[$module]));
70
		$this->customData = array($module=>array( $this->viewDefs=>$this->customData[$module]));
71
		$this->newData = array($module=>array( $this->viewDefs=>$this->newData[$module]));
72
	
73
	}
74
	/**
75
	 * This takes in a  list of panels and returns an associative array of field names to the meta-data of the field as well as the locations of that field
76
	 * Since searchdefs have the concept of basic and advanced those act as panels for merging
77
	 * @param ARRAY $panels - this is the 'panel' section of the meta-data for list views all the meta data is one panel since it is just a list of fields
78
	 * @return ARRAY $fields - an associate array of fields and their meta-data as well as their location
79
	 */
80
	
81
	protected function getFields(&$panels, $multiple = true){
82
		$fields = array();
83
		if(!$multiple)$panels = array($panels);
84
		
85
		foreach($panels as $panel_id=>$panel){
86
				foreach($panel as $col_id=>$col){
87
					if(is_array($col)){
88
						$field_name = $col['name'];
89
					}else{
90
						$field_name = $col;
91
					}
92
					$fields[$field_name . $panel_id] = array('data'=>$col, 'loc'=>array('row'=>$col_id, 'panel'=>$panel_id));
93
				}
94
			}
95
			
96
			return $fields;
97
		}
98
	
99
	/**
100
	 * This builds the array of fields from the merged fields in the right order
101
	 * when building the panels for a list view the most important thing is order 
102
	 * so we ensure the fields that came from the custom file keep 
103
	 * their order then we add any new fields at the end
104
	 *
105
	 * @return ARRAY
106
	 */
107
	protected function buildPanels(){
108
		$panels  = array();
109
		
110
		//first only deal with ones that have their location coming from the custom source
111
		foreach($this->mergedFields as $id =>$field){
112
			if($field['loc']['source'] == 'custom'){
113
				$panels[$field['loc']['panel']][] = $field['data'];
114
				unset($this->mergedFields[$id]);
115
			}
116
		}
117
118
		return $panels;
119
	}
120
	
121
	/**
122
	 * Sets the panel section for the meta-data after it has been merged
123
	 *
124
	 */
125
	protected function setPanels(){
126
		$this->newData[$this->module][$this->viewDefs][$this->panelName] = $this->buildPanels();
127
		$this->newData[$this->module] = $this->newData[$this->module][$this->viewDefs];
128
		
129
	}
130
	public function save($to){
131
		return write_array_to_file("$this->varName['$this->module']", $this->newData[$this->module], $to);
132
	}
133
	
134
	/**
135
	 * public function that will merge meta data from an original sugar file that shipped with the product, a customized file, and a new file shipped with an upgrade
136
	 *
137
	 * @param STRING $module - name of the module's files that are to be merged
138
	 * @param STRING $original_file - path to the file that originally shipped with sugar
139
	 * @param STRING $new_file - path to the new file that is shipping with the patch 
140
	 * @param STRING $custom_file - path to the custom file
141
	 * @param BOOLEAN $save - boolean on if it should save the results to the custom file or not
142
	 * @return BOOLEAN - if the merged file was saved if false is passed in for the save parameter it always returns true
143
	 */
144
	public function merge($module, $original_file, $new_file, $custom_file=false, $save=true){
145
		//Bug 37207
146
		if($module == 'Connectors') {
147
		   return false;
148
		}			
149
		
150
		$this->clear();
151
		$this->log("\n\n". 'Starting a merge in ' . get_class($this));
152
		$this->log('merging the following files');
153
		$this->log('original file:'  . $original_file);
154
		$this->log('new file:'  . $new_file);
155
		$this->log('custom file:'  . $custom_file);	
156
		if(empty($custom_file) && $save){
157
			return true;
158
		}else{			
159
			$this->loadData($module, $original_file, $new_file, $custom_file);
0 ignored issues
show
It seems like $custom_file defined by parameter $custom_file on line 144 can also be of type false; however, SearchMerge::loadData() does only seem to accept string, 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...
160
						
161
			if(!isset($this->originalData[$module])) {
162
			   return false;
163
			}
164
			
165
			$this->mergeMetaData();
166
			if($save && !empty($this->newData) && !empty($custom_file)){
167
				//backup the file
168
				copy($custom_file, $custom_file . '.suback.php');
169
				return $this->save($custom_file);
170
			}
171
		}
172
		if(!$save)return true;
173
		return false;
174
	}	
175
	
176
	protected function mergeTemplateMeta()
177
	{
178
	    if( isset($this->customData[$this->module][$this->viewDefs][$this->templateMetaName]) )
179
	    {
180
	       $this->newData[$this->module][$this->viewDefs][$this->templateMetaName] = $this->customData[$this->module][$this->viewDefs][$this->templateMetaName];
181
	    }
182
	    
183
	    if(!isset($this->newData[$this->module][$this->viewDefs][$this->templateMetaName]['maxColumnsBasic']) && isset($this->newData[$this->module][$this->viewDefs][$this->templateMetaName]['maxColumns']))
184
	    {
185
	    	$this->newData[$this->module][$this->viewDefs][$this->templateMetaName]['maxColumnsBasic'] = $this->newData[$this->module][$this->viewDefs][$this->templateMetaName]['maxColumns'];
186
	    }
187
	}	
188
	
189
}
190
?>