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/end.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
3
if (!defined('sugarEntry') || !sugarEntry) {
4
    die('Not A Valid Entry Point');
5
}
6
/*********************************************************************************
7
 * SugarCRM Community Edition is a customer relationship management program developed by
8
 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
9
 *
10
 * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
11
 * Copyright (C) 2011 - 2016 Salesagility Ltd.
12
 *
13
 * This program is free software; you can redistribute it and/or modify it under
14
 * the terms of the GNU Affero General Public License version 3 as published by the
15
 * Free Software Foundation with the addition of the following permission added
16
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
17
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
18
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
19
 *
20
 * This program is distributed in the hope that it will be useful, but WITHOUT
21
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
23
 * details.
24
 *
25
 * You should have received a copy of the GNU Affero General Public License along with
26
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
27
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28
 * 02110-1301 USA.
29
 *
30
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
31
 * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].
32
 *
33
 * The interactive user interfaces in modified source and object code versions
34
 * of this program must display Appropriate Legal Notices, as required under
35
 * Section 5 of the GNU Affero General Public License version 3.
36
 *
37
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
38
 * these Appropriate Legal Notices must retain the display of the "Powered by
39
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
40
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
41
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
42
 ********************************************************************************/
43
44
/*********************************************************************************
45
 * Description:
46
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
47
 * Reserved. Contributor(s): ______________________________________..
48
 * *******************************************************************************/
49
logThis('[At end.php]');
50
global $unzip_dir;
51
global $path;
52
global $sugar_config;
53
54
if ($unzip_dir == null) {
55
    $unzip_dir = isset($_SESSION['unzip_dir']) ? $_SESSION['unzip_dir'] : null;
56
}
57
//First repair the databse to ensure it is up to date with the new vardefs/tabledefs
58
logThis('About to repair the database.', $path);
59
//Use Repair and rebuild to update the database.
60
global $dictionary, $beanFiles;
61
62
require_once 'modules/Trackers/TrackerManager.php';
63
$trackerManager = TrackerManager::getInstance();
64
$trackerManager->pause();
65
$trackerManager->unsetMonitors();
66
67
require_once 'modules/Administration/QuickRepairAndRebuild.php';
68
$rac = new RepairAndClear();
69
$rac->clearVardefs();
70
$rac->rebuildExtensions();
71
//bug: 44431 - defensive check to ensure the method exists since upgrades to 6.2.0 may not have this method define yet.
72
if (method_exists($rac, 'clearExternalAPICache')) {
73
    $rac->clearExternalAPICache();
74
}
75
76
$repairedTables = array();
77
78
foreach ($beanFiles as $bean => $file) {
79
    if (file_exists($file)) {
80
        require_once $file;
81
        unset($GLOBALS['dictionary'][$bean]);
82
        $focus = new $bean ();
83
        if (($focus instanceof SugarBean)) {
84
            if (!isset($repairedTables[$focus->table_name])) {
85
                $sql = $GLOBALS['db']->repairTable($focus, true);
86
                if (trim($sql) != '') {
87
                    logThis('Running sql:'.$sql, $path);
88
                }
89
                $repairedTables[$focus->table_name] = true;
90
            }
91
92
            //Check to see if we need to create the audit table
93
            if ($focus->is_AuditEnabled() && !$focus->db->tableExists($focus->get_audit_table_name())) {
94
                logThis('Creating audit table:'.$focus->get_audit_table_name(), $path);
95
                $focus->create_audit_table();
96
            }
97
        }
98
    }
99
}
100
101
// add suite version into upgrade pack!
102
if (isset($repairedTables['reminders']) && $repairedTables['reminders'] && isset($_SESSION['suitecrm_version_before_upgrade']) && version_compare($_SESSION['suitecrm_version_before_upgrade'], Reminder::UPGRADE_VERSION, '<')) {
103
    Reminder::upgrade();
104
    unset($_SESSION['suitecrm_version_before_upgrade']);
105
}
106
107
$olddictionary = $dictionary;
108
109
unset($dictionary);
110
include 'modules/TableDictionary.php';
111
foreach ($dictionary as $meta) {
112
    $tablename = $meta['table'];
113
    if (isset($repairedTables[$tablename])) {
114
        continue;
115
    }
116
    $fielddefs = $meta['fields'];
117
    $indices = $meta['indices'];
118
    $sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
119
    if (trim($sql) != '') {
120
        logThis('Running sql:'.$sql, $path);
121
    }
122
    $repairedTables[$tablename] = true;
123
}
124
125
$dictionary = $olddictionary;
126
127
logThis('database repaired', $path);
128
129
$ce_to_pro_ent = isset($_SESSION['upgrade_from_flavor']) && ($_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarPro' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarEnt' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarCorp' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarUlt');
130
131
logThis(' Start Rebuilding the config file again', $path);
132
133
//check and set the logger before rebuilding config
134
if (!isset($sugar_config['logger'])) {
135
    $sugar_config['logger'] = array(
136
        'level' => 'fatal',
137
        'file' => array(
138
                'ext' => '.log',
139
                'name' => 'suitecrm',
140
                'dateFormat' => '%c',
141
                'maxSize' => '10MB',
142
                'maxLogs' => 10,
143
                'suffix' => '', // bug51583, change default suffix to blank for backwards comptability
144
            ),
145
    );
146
}
147
//for upgraded version, set default lead conversion activity option to 'copy'
148
if (!isset($sugar_config['lead_conv_activity_opt'])) {
149
    $sugar_config['lead_conv_activity_opt'] = 'copy';
150
}
151
152
if (!rebuildConfigFile($sugar_config, $sugar_version)) {
153
    logThis('*** WARNING: could not write config.php!', $path);
154
}
155
logThis(' Finish Rebuilding the config file again', $path);
156
157
set_upgrade_progress('end', 'in_progress');
158
159
if (isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])) {
160
    if (version_compare($_SESSION['current_db_version'], $_SESSION['target_db_version'], '!=')) {
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
161
    }
162
163
    //keeping separate. making easily visible and readable
164
    if (version_compare($_SESSION['current_db_version'], $_SESSION['target_db_version'], '=')) {
165
        $_REQUEST['upgradeWizard'] = true;
166
        ob_start();
167
        include 'modules/ACL/install_actions.php';
168
        include_once 'include/Smarty/internals/core.write_file.php';
169
        ob_end_clean();
170
        $db = &DBManagerFactory::getInstance();
171
        if ($ce_to_pro_ent) {
172
            //Also set license information
173
            $admin = new Administration();
174
            $category = 'license';
175
            $value = '0';
176
            $admin->saveSetting($category, 'users', $value);
177
            $key = array('num_lic_oc', 'key', 'expire_date');
178
            $value = '';
179
            foreach ($key as $k) {
180
                $admin->saveSetting($category, $k, $value);
181
            }
182
        }
183
    }
184
}
185
186
// Mark the instance as having gone thru the admin wizard
187
$admin = new Administration();
188
$admin->saveSetting('system', 'adminwizard', 1);
189
190
//Upgrade connectors
191
logThis('Begin upgrade_connectors', $path);
192
upgrade_connectors();
193
logThis('End upgrade_connectors', $path);
194
195
//Unlink files that have been removed
196
if (function_exists('unlinkUpgradeFiles')) {
197
    unlinkUpgradeFiles($_SESSION['current_db_version']);
198
}
199
200
if (function_exists('rebuildSprites') && function_exists('imagecreatetruecolor')) {
201
    if (!empty($sugar_config['use_sprites']) && $sugar_config['use_sprites']) {
202
        rebuildSprites(true);
203
    }
204
}
205
206
//Run repairUpgradeHistoryTable
207
if (version_compare($_SESSION['current_db_version'], '6.5.0', '<') && function_exists('repairUpgradeHistoryTable')) {
208
    repairUpgradeHistoryTable();
209
}
210
211
require_once 'modules/Administration/upgrade_custom_relationships.php';
212
upgrade_custom_relationships();
213
214
require_once 'modules/UpgradeWizard/uw_utils.php';
215
216
set_upgrade_progress('end', 'done');
217
218
logThis('Cleaning up the session.  Goodbye.');
219
unlinkUWTempFiles();
220
logThis('Cleaning up the session.  Goodbye.');
221
resetUwSession();
222
// flag to say upgrade has completed
223
$_SESSION['upgrade_complete'] = true;
224
225
//Clear any third party caches
226
sugar_cache_reset_full();
227
228
//add the clean vardefs here
229
VardefManager::clearVardef();
230
231
require_once 'include/TemplateHandler/TemplateHandler.php';
232
TemplateHandler::clearAll();
233
234
//also add the cache cleaning here.
235
if (function_exists('deleteCache')) {
236
    deleteCache();
237
}
238
239
global $mod_strings;
240
global $current_language;
241
242
if (!isset($current_language) || ($current_language == null)) {
243
    $current_language = 'en_us';
244
}
245
if (isset($GLOBALS['current_language']) && ($GLOBALS['current_language'] != null)) {
246
    $current_language = $GLOBALS['current_language'];
247
}
248
$mod_strings = return_module_language($current_language, 'UpgradeWizard');
249
$stop = false;
250
251
$httpHost = $_SERVER['HTTP_HOST'];  // cn: 8472 - HTTP_HOST includes port in some cases
252
if ($colon = strpos($httpHost, ':')) {
253
    $httpHost = substr($httpHost, 0, $colon);
254
}
255
$parsedSiteUrl = parse_url($sugar_config['site_url']);
256
$host = ($parsedSiteUrl['host'] != $httpHost) ? $httpHost : $parsedSiteUrl['host'];
257
258
// aw: 9747 - use SERVER_PORT for users who don't plug in the site_url at install correctly
259
if ($_SERVER['SERVER_PORT'] != 80) {
260
    $port = ':'.$_SERVER['SERVER_PORT'];
261
} elseif (isset($parsedSiteUrl['port']) && $parsedSiteUrl['port'] != 80) {
262
    $port = ':'.$parsedSiteUrl['port'];
263
} else {
264
    $port = '';
265
}
266
$path = $parsedSiteUrl['path'];
267
$cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}/index.php";
268
269
/*ob_start();
270
check_now(get_sugarbeat());
271
ob_end_clean();*/
272
273
$uwMain = <<<eoq
274
<table cellpadding="3" cellspacing="0" border="0">
275
276
	<tr>
277
		<td align="left">
278
			<p>
279
			<br>
280
			{$mod_strings['LBL_UW_END_LOGOUT_PRE2']}
281
			<br>
282
			<br>
283
            <b>{$mod_strings['LBL_UW_END_LOGOUT_PRE']}</b> {$mod_strings['LBL_UW_END_LOGOUT']}
284
			</p>
285
		</td>
286
	</tr>
287
</table>
288
289
<script>
290
 function deleteCacheAjax(){
291
	//AJAX call for checking the file size and comparing with php.ini settings.
292
	var callback = {
293
		 success:function(r) {
294
		     //alert(r.responseText);
295
		 }
296
	}
297
	postData = '&module=UpgradeWizard&action=deleteCache&to_pdf=1';
298
	YAHOO.util.Connect.asyncRequest('POST', 'index.php', callback, postData);
299
}
300
</script>
301
eoq;
302
303
$showBack = false;
304
$showCancel = false;
305
$showRecheck = false;
306
$showNext = false;
307
$showDone = true;
308
309
$stepBack = 0;
310
$stepNext = 0;
311
$stepCancel = 0;
312
$stepRecheck = 0;
313
314
$_SESSION['step'][$steps['files'][$_REQUEST['step']]] = ($stop) ? 'failed' : 'success';
315
unset($_SESSION['current_db_version']);
316
unset($_SESSION['target_db_version']);
317