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.

include/generic/Save2.php (1 issue)

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:  TODO: To be written.
44
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
45
 * All Rights Reserved.
46
 * Contributor(s): ______________________________________..
47
 ********************************************************************************/
48
49
/*
50
ARGS:
51
 $_REQUEST['method']; : options: 'SaveRelationship','Save','DeleteRelationship','Delete'
52
 $_REQUEST['module']; : the module associated with this Bean instance (will be used to get the class name)
53
 $_REQUEST['record']; : the id of the Bean instance
54
// $_REQUEST['related_field']; : the field name on the Bean instance that contains the relationship
55
// $_REQUEST['related_record']; : the id of the related record
56
// $_REQUEST['related_']; : the
57
// $_REQUEST['return_url']; : the URL to redirect to
58
//$_REQUEST['return_type']; : when set the results of a report will be linked with the parent.
59
*/
60
61
62
require_once('include/formbase.php');
63
64
$refreshsubpanel=true;
65
if (isset($_REQUEST['return_type'])  && $_REQUEST['return_type'] == 'report') {
66
	save_from_report($_REQUEST['subpanel_id'] //report_id
67
					 ,$_REQUEST['record'] //parent_id
68
					 ,$_REQUEST['module'] //module_name
69
					 ,$_REQUEST['subpanel_field_name'] //link attribute name
70
	);
71
} else if (isset($_REQUEST['return_type'])  && $_REQUEST['return_type'] == 'addtoprospectlist') {
72
73
	$GLOBALS['log']->debug(print_r($_REQUEST,true));
74
	if(!empty($_REQUEST['prospect_list_id']) and !empty($_REQUEST['prospect_ids']))
75
	{
76
	    add_prospects_to_prospect_list(
77
	        $_REQUEST['prospect_list_id'],
78
	        $_REQUEST['prospect_ids']
79
	    );
80
	}
81
	else
82
	{
83
	    $parent = BeanFactory::getBean($_REQUEST['module'], $_REQUEST['record']);
84
	    add_to_prospect_list(urldecode($_REQUEST['subpanel_module_name']),$_REQUEST['parent_module'],$_REQUEST['parent_type'],$_REQUEST['subpanel_id'],
85
	        $_REQUEST['child_id'],$_REQUEST['link_attribute'],$_REQUEST['link_type'], $parent);
86
	}
87
88
	$refreshsubpanel=false;
89
}else if (isset($_REQUEST['return_type'])  && $_REQUEST['return_type'] == 'addcampaignlog') {
90
    //if param is set to "addcampaignlog", then we need to create a campaign log entry
91
    //for each campaign id passed in.
92
93
    // Get a list of campaigns selected.
94
    if (isset($_REQUEST['subpanel_id'])  && !empty($_REQUEST['subpanel_id'])) {
95
        $campaign_ids = $_REQUEST['subpanel_id'];
96
        global $beanFiles;
97
        global $beanList;
98
        //retrieve current bean
99
        $bean_name = $beanList[$_REQUEST['module']];
100
        require_once($beanFiles[$bean_name]);
101
        $focus = new $bean_name();
102
        $focus->retrieve($_REQUEST['record']);
103
104
        require_once('modules/Campaigns/utils.php');
105
        //call util function to create the campaign log entry
106
        foreach($campaign_ids as $id){
107
            create_campaign_log_entry($id, $focus, $focus->module_dir,$focus, $focus->id);
108
        }
109
        $refreshsubpanel=true;
110
    }
111
}
112
else {
113
114
	global $beanFiles,$beanList;
115
 	$bean_name = $beanList[$_REQUEST['module']];
116
 	require_once($beanFiles[$bean_name]);
117
 	$focus = new $bean_name();
118
119
 	$focus->retrieve($_REQUEST['record']);
120
121
 	// If the user selected "All records" from the selection menu, we pull up the list
122
 	// based on the query they used on that popup to relate them to the parent record
123
 	if(!empty($_REQUEST['select_entire_list']) &&  $_REQUEST['select_entire_list'] != 'undefined' && isset($_REQUEST['current_query_by_page'])){
124
		$order_by = '';
125
		$current_query_by_page = $_REQUEST['current_query_by_page'];
126
 		$current_query_by_page_array = sugar_unserialize(base64_decode($current_query_by_page));
127
128
        $module = $current_query_by_page_array['module'];
129
        $seed = BeanFactory::getBean($module);
130
        if(empty($seed)) sugar_die($GLOBALS['app_strings']['ERROR_NO_BEAN']);
131
 		$where_clauses = '';
132
 		require_once('include/SearchForm/SearchForm2.php');
133
134
 		if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
135
            require('custom/modules/'.$module.'/metadata/metafiles.php');
136
        }elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
137
            require('modules/'.$module.'/metadata/metafiles.php');
138
        }
139
140
        if (file_exists('custom/modules/'.$module.'/metadata/searchdefs.php'))
141
        {
142
        	require_once('custom/modules/'.$module.'/metadata/searchdefs.php');
143
        }
144
        elseif (!empty($metafiles[$module]['searchdefs']))
145
        {
146
        	require_once($metafiles[$module]['searchdefs']);
147
        }
148
        elseif (file_exists('modules/'.$module.'/metadata/searchdefs.php'))
149
        {
150
        	require_once('modules/'.$module.'/metadata/searchdefs.php');
151
        }
152
153
        if(!empty($metafiles[$module]['searchfields'])){
154
        	require_once($metafiles[$module]['searchfields']);
155
        }
156
        elseif(file_exists('modules/'.$module.'/metadata/SearchFields.php')){
157
        	require_once('modules/'.$module.'/metadata/SearchFields.php');
158
        }
159
        if(!empty($searchdefs) && !empty($searchFields)) {
160
        	$searchForm = new SearchForm($seed, $module);
161
	        $searchForm->setup($searchdefs, $searchFields, 'SearchFormGeneric.tpl');
0 ignored issues
show
The call to SearchForm::setup() has too many arguments starting with $searchdefs.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
162
	        $searchForm->populateFromArray($current_query_by_page_array, 'advanced');
163
	        $where_clauses_arr = $searchForm->generateSearchWhere(true, $module);
164
	        if (count($where_clauses_arr) > 0 ) {
165
	            $where_clauses = '('. implode(' ) AND ( ', $where_clauses_arr) . ')';
166
	        }
167
        }
168
        
169
        $query = $seed->create_new_list_query($order_by, $where_clauses);
170
		$result = $GLOBALS['db']->query($query,true);
171
		$uids = array();
172
		while($val = $GLOBALS['db']->fetchByAssoc($result,false))
173
		{
174
			array_push($uids, $val['id']);
175
		}
176
		$_REQUEST['subpanel_id'] = $uids;
177
 	}
178
179
 	if($bean_name == 'Team'){
180
 		$subpanel_id = $_REQUEST['subpanel_id'];
181
 		if(is_array($subpanel_id)){
182
 			foreach($subpanel_id as $id){
183
 				$focus->add_user_to_team($id);
184
 			}
185
 		}
186
 		else{
187
 			$focus->add_user_to_team($subpanel_id);
188
 		}
189
 	} else{
190
 		//find request paramters with with prefix of REL_ATTRIBUTE_
191
 		//convert them into an array of name value pairs add pass them as
192
 		//parameters to the add metod.
193
 		$add_values =array();
194
 		foreach ($_REQUEST as $key=>$value) {
195
 			if (strpos($key,"REL_ATTRIBUTE_") !== false) {
196
 				$add_values[substr($key,14)]=$value;
197
 			}
198
 		}
199
		$relName = $_REQUEST['subpanel_field_name'];
200
 		$focus->load_relationship($relName);
201
 		$focus->$relName->add($_REQUEST['subpanel_id'],$add_values);
202
        $focus->save();
203
 	}
204
}
205
206
if ($refreshsubpanel) {
207
	//refresh contents of the sub-panel.
208
	$GLOBALS['log']->debug("Location: index.php?sugar_body_only=1&module=".$_REQUEST['module']."&subpanel=".$_REQUEST['subpanel_module_name']."&action=SubPanelViewer&inline=1&record=".$_REQUEST['record']);
209
	if( empty($_REQUEST['refresh_page']) || $_REQUEST['refresh_page'] != 1){
210
		$inline = isset($_REQUEST['inline'])?$_REQUEST['inline']: $inline;
211
		header("Location: index.php?sugar_body_only=1&module=".$_REQUEST['module']."&subpanel=".$_REQUEST['subpanel_module_name']."&action=SubPanelViewer&inline=$inline&record=".$_REQUEST['record']);
212
	}
213
	exit;
214
}
215