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/SugarTinyMCE.php (5 issues)

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:
44
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc. All Rights
45
 * Reserved. Contributor(s): ______________________________________..
46
 *********************************************************************************/
47
48
49
/**
50
 * PHP wrapper class for Javascript driven TinyMCE WYSIWYG HTML editor
51
 */
52
class SugarTinyMCE {
53
	var $jsroot = "include/javascript/tiny_mce/";
54
	var $customConfigFile = 'custom/include/tinyButtonConfig.php';
55
	var $customDefaultConfigFile = 'custom/include/tinyMCEDefaultConfig.php';
56
	var $buttonConfigs = array(
57
			'default' => array(
58
						'buttonConfig' => "code,help,separator,bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,
59
	                     					justifyfull,separator,forecolor,backcolor,separator,styleselect,formatselect,fontselect,fontsizeselect,",
60
	                    'buttonConfig2' => "cut,copy,paste,pastetext,pasteword,selectall,separator,search,replace,separator,bullist,numlist,separator,outdent,
61
	                     					indent,separator,ltr,rtl,separator,undo,redo,separator, link,unlink,anchor,image,separator,sub,sup,separator,charmap,
62
	                     					visualaid",
63
	                    'buttonConfig3' => "tablecontrols,separator,advhr,hr,removeformat,separator,insertdate,inserttime,separator,preview"),
64
	        'email_compose' => array(
65
						'buttonConfig' => "code,help,separator,bold,italic,underline,strikethrough,separator,bullist,numlist,separator,justifyleft,justifycenter,justifyright,
66
	                     					justifyfull,separator,link,unlink,separator,forecolor,backcolor,separator,styleselect,formatselect,fontselect,fontsizeselect,",
67
	                    'buttonConfig2' => "",
68
	                    'buttonConfig3' => ""),
69
	        'email_compose_light' => array(
70
						'buttonConfig' => "code,separator,bold,italic,underline,strikethrough,separator,bullist,numlist,separator,justifyleft,justifycenter,justifyright,
71
	                     					justifyfull,separator,link,unlink,separator,forecolor,backcolor,separator,formatselect,fontselect,fontsizeselect,",
72
	                    'buttonConfig2' => "",
73
	                    'buttonConfig3' => ""),
74
	);
75
76
	var $pluginsConfig = array(
77
	    'email_compose_light' => 'insertdatetime,paste,directionality,safari',
78
        'email_compose' => 'advhr,insertdatetime,table,preview,paste,searchreplace,directionality,fullpage',
79
	);
80
81
	var $defaultConfig = array(
82
	    'convert_urls' => false,
83
        'valid_children' => '+body[style]',
84
	    'height' => 300,
85
		'width'	=> '100%',
86
		'theme'	=> 'advanced',
87
		'theme_advanced_toolbar_align' => "left",
88
		'theme_advanced_toolbar_location'	=> "top",
89
		'theme_advanced_buttons1'	=> "",
90
		'theme_advanced_buttons2'	=> "",
91
		'theme_advanced_buttons3'	=> "",
92
		'strict_loading_mode'	=> true,
93
		'mode'	=> 'exact',
94
		'language' => 'en',
95
	    'plugins' => 'advhr,insertdatetime,table,preview,paste,searchreplace,directionality',
96
		'elements'	=> '',
97
        'extended_valid_elements' => 'style[dir|lang|media|title|type],hr[class|width|size|noshade],@[class|style]',
98
        'content_css' => 'include/javascript/tiny_mce/themes/advanced/skins/default/content.css',
99
100
	);
101
102
103
	/**
104
	 * Sole constructor
105
	 */
106
	function __construct() {
107
108
		$this->overloadButtonConfigs();
109
		$this->overloadDefaultConfigs();
110
	}
111
112
	/**
113
	 * Returns the Javascript necessary to initialize a TinyMCE instance for a given <textarea> or <div>
114
	 * @param string target Comma delimited list of DOM ID's, <textarea id='someTarget'>
115
	 * @return string
116
	 */
117
	function getInstance($targets = "", $type = 'default') {
118
		global $json;
119
120
		if(empty($json)) {
121
			$json = getJSONobj();
122
		}
123
124
		$config = $this->defaultConfig;
125
		//include tinymce lang file
126
        $lang = substr($GLOBALS['current_language'], 0, 2);
127
        if(file_exists('include/javascript/tiny_mce/langs/'.$lang.'.js'))
128
        {
129
			$config['language'] = $lang;
130
        }
131
		$config['directionality'] = SugarThemeRegistry::current()->directionality;
132
		$config['elements'] = $targets;
133
		$config['theme_advanced_buttons1'] = $this->buttonConfigs[$type]['buttonConfig'];
134
		$config['theme_advanced_buttons2'] = $this->buttonConfigs[$type]['buttonConfig2'];
135
		$config['theme_advanced_buttons3'] = $this->buttonConfigs[$type]['buttonConfig3'];
136
137
		$jsConfig = $json->encode($config);
138
139
		$instantiateCall = '';
140
		if (!empty($targets)) {
141
			$exTargets = explode(",", $targets);
142
			foreach($exTargets as $instance) {
0 ignored issues
show
This foreach statement is empty and can be removed.

This check looks for foreach loops 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.

Consider removing the loop.

Loading history...
143
				//$instantiateCall .= "tinyMCE.execCommand('mceAddControl', false, document.getElementById('{$instance}'));\n";
144
			}
145
		}
146
		$path = getJSPath('include/javascript/tiny_mce/tiny_mce.js');
0 ignored issues
show
Are you sure the assignment to $path is correct as getJSPath('include/javas.../tiny_mce/tiny_mce.js') (which targets getJSPath()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
147
		$ret =<<<eoq
148
<script type="text/javascript" language="Javascript" src="$path"></script>
149
150
<script type="text/javascript" language="Javascript">
151
<!--
152
if (!SUGAR.util.isTouchScreen()) {
153
    tinyMCE.init({$jsConfig});
154
	{$instantiateCall}
155
}
156
else {
157
eoq;
158
$exTargets = explode(",", $targets);
159
foreach($exTargets as $instance) {
160
$ret .=<<<eoq
161
    document.getElementById('$instance').style.width = '100%';
162
    document.getElementById('$instance').style.height = '100px';
163
eoq;
164
}
165
$ret .=<<<eoq
166
}
167
-->
168
</script>
169
170
eoq;
171
		return $ret;
172
	}
173
174
    function getConfig($type = 'default') {
175
        global $json;
176
177
        if(empty($json)) {
178
            $json = getJSONobj();
179
        }
180
181
        $config = $this->defaultConfig;
182
        //include tinymce lang file
183
        $lang = substr($GLOBALS['current_language'], 0, 2);
184
        if(file_exists('include/javascript/tiny_mce/langs/'.$lang.'.js'))
185
			$config['language'] = $lang;
186
		$config['theme_advanced_buttons1'] = $this->buttonConfigs[$type]['buttonConfig'];
187
       	$config['theme_advanced_buttons2'] = $this->buttonConfigs[$type]['buttonConfig2'];
188
        $config['theme_advanced_buttons3'] = $this->buttonConfigs[$type]['buttonConfig3'];
189
190
        if(isset($this->pluginsConfig[$type]))
191
            $config['plugins'] = $this->pluginsConfig[$type];
192
193
        $jsConfig = $json->encode($config);
194
        return "var tinyConfig = ".$jsConfig.";";
195
196
    }
197
198
    /**
199
     * This function takes in html code that has been produced (and somewhat mauled) by TinyMCE
200
     * and returns a cleaned copy of it.
201
     *
202
     * @param $html
203
     * @return $html with all the tinyMCE specific html removed
0 ignored issues
show
The doc-type $html could not be parsed: Unknown type name "$html" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
204
     */
205
    function cleanEncodedMCEHtml($html) {
206
    	$html = str_replace("mce:script", "script", $html);
207
    	$html = str_replace("mce_src=", "src=", $html);
208
    	$html = str_replace("mce_href=", "href=", $html);
209
    	return $html;
210
    }
211
212
    /**
213
     * Reload the default button configs by allowing admins to specify
214
     * which tinyMCE buttons will be displayed in a separate config file.
215
     *
216
     */
217
    private function overloadButtonConfigs()
218
    {
219
        if( file_exists( $this->customConfigFile ) )
220
        {
221
            require_once($this->customConfigFile);
222
223
            if(!isset($buttonConfigs))
0 ignored issues
show
The variable $buttonConfigs 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...
224
                return;
225
226
            foreach ($buttonConfigs as $k => $v)
227
            {
228
                if( isset($this->buttonConfigs[$k]) )
229
                    $this->buttonConfigs[$k] = $v;
230
            }
231
        }
232
    }
233
234
    /**
235
     * Reload the default tinyMCE config, preserving our default extended
236
     * allowable tag set.
237
     *
238
     */
239
    private function overloadDefaultConfigs()
240
    {
241
        if( file_exists( $this->customDefaultConfigFile ) )
242
        {
243
            require_once($this->customDefaultConfigFile);
244
245
            if(!isset($defaultConfig))
0 ignored issues
show
The variable $defaultConfig 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...
246
                return;
247
248
            foreach ($defaultConfig as $k => $v)
249
            {
250
                if( isset($this->defaultConfig[$k]) ){
251
252
                	if($k == "extended_valid_elements"){
253
                		$this->defaultConfig[$k] .= "," . $v;
254
                	}
255
                	else{
256
                		$this->defaultConfig[$k] = $v;
257
                	}
258
                }
259
            }
260
        }
261
    }
262
263
} // end class def
264