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/utils/db_utils.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
 * 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
41
42
43
/**
44
 * @deprecated use DBManager::convert() instead.
45
 */
46
function db_convert($string, $type, $additional_parameters=array(),$additional_parameters_oracle_only=array())
47
	{
48 49
    return $GLOBALS['db']->convert($string, $type, $additional_parameters, $additional_parameters_oracle_only);
49
            }
50
51
/**
52
 * @deprecated use DBManager::concat() instead.
53
 */
54
function db_concat($table, $fields)
55
	{
56 2
    return $GLOBALS['db']->concat($table, $fields);
57
}
58
59
/**
60
 * @deprecated use DBManager::fromConvert() instead.
61
 */
62
function from_db_convert($string, $type)
63
	{
64 1
    return $GLOBALS['db']->fromConvert($string, $type);
65
	}
66
67
$toHTML = array(
68
	'"' => '&quot;',
69
	'<' => '&lt;',
70
	'>' => '&gt;',
71
	"'" => '&#039;',
72
);
73
$GLOBALS['toHTML_keys'] = array_keys($toHTML);
74
$GLOBALS['toHTML_values'] = array_values($toHTML);
75
$GLOBALS['toHTML_keys_set'] = implode("", $GLOBALS['toHTML_keys']);
76
/**
77
 * Replaces specific characters with their HTML entity values
78
 * @param string $string String to check/replace
79
 * @param bool $encode Default true
80
 * @return string
81
 *
82
 * @todo Make this utilize the external caching mechanism after re-testing (see
83
 *       log on r25320).
84
 *
85
 * Bug 49489 - removed caching of to_html strings as it was consuming memory and
86
 * never releasing it
87
 */
88
function to_html($string, $encode=true){
89 229
	if (empty($string)) {
90 181
		return $string;
91
	}
92
93 214
	global $toHTML;
94
95 214
	if($encode && is_string($string)){
96
		/*
97
		 * cn: bug 13376 - handle ampersands separately
98
		 * credit: ashimamura via bug portal
99
		 */
100
		//$string = str_replace("&", "&amp;", $string);
101
102 214
        if(is_array($toHTML))
103
        { // cn: causing errors in i18n test suite ($toHTML is non-array)
104 214
            $string = str_ireplace($GLOBALS['toHTML_keys'],$GLOBALS['toHTML_values'],$string);
105
		}
106
	}
107
108 214
    return $string;
109
}
110
111
112
/**
113
 * Replaces specific HTML entity values with the true characters
114
 * @param string $string String to check/replace
115
 * @param bool $encode Default true
116
 * @return string
117
 */
118
function from_html($string, $encode=true) {
119 232
    if (!is_string($string) || !$encode) {
120 154
        return $string;
121
    }
122
123 209
	global $toHTML;
124 209
    static $toHTML_values = null;
125 209
    static $toHTML_keys = null;
126 209
    static $cache = array();
127 209
    if (!empty($toHTML) && is_array($toHTML) && (!isset($toHTML_values) || !empty($GLOBALS['from_html_cache_clear']))) {
128 1
        $toHTML_values = array_values($toHTML);
129 1
        $toHTML_keys = array_keys($toHTML);
130
    }
131
132
    // Bug 36261 - Decode &amp; so we can handle double encoded entities
133 209
	$string = str_ireplace("&amp;", "&", $string);
134
135 209
    if (!isset($cache[$string])) {
136 99
        $cache[$string] = str_ireplace($toHTML_values, $toHTML_keys, $string);
137
    }
138 209
    return $cache[$string];
139
}
140
141
/*
142
 * Return a version of $proposed that can be used as a column name in any of our supported databases
143
 * Practically this means no longer than 25 characters as the smallest identifier length for our supported DBs is 30 chars for Oracle plus we add on at least four characters in some places (for indices for example)
144
 * @param string $name Proposed name for the column
145
 * @param string $ensureUnique
146
 * @param int $maxlen Deprecated and ignored
0 ignored issues
show
There is no parameter named $maxlen. Did you maybe mean $maxLen?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
147
 * @return string Valid column name trimmed to right length and with invalid characters removed
148
 */
149
function getValidDBName ($name, $ensureUnique = false, $maxLen = 30)
150
{
151 1
    return DBManagerFactory::getInstance()->getValidDBName($name, $ensureUnique);
152
}
153
154
155
/**
156
 * isValidDBName
157
 *
158
 * Utility to perform the check during install to ensure a database name entered by the user
159
 * is valid based on the type of database server
160
 * @param string $name Proposed name for the DB
161
 * @param string $dbType Type of database server
162
 * @return bool true or false based on the validity of the DB name
163
 */
164
function isValidDBName($name, $dbType)
165
{
166 1
    $db = DBManagerFactory::getTypeInstance($dbType);
167 1
    return $db->isDatabaseNameValid($name);
168
}
169