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/ModuleBuilder/views/view.labels.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
/*********************************************************************************
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
 * Created on Jul 24, 2007
42
 *
43
 * To change the template for this generated file go to
44
 * Window - Preferences - PHPeclipse - PHP - Code Templates
45
 */
46
require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
47
require_once('modules/ModuleBuilder/views/view.modulefields.php');
48
class ViewLabels extends ViewModulefields
49
{
50
    /**
51
	 * @see SugarView::_getModuleTitleParams()
52
	 */
53
	protected function _getModuleTitleParams($browserTitle = false)
54
	{
55
	    global $mod_strings;
56
57
    	return array(
58
    	   translate('LBL_MODULE_NAME','Administration'),
59
    	   ModuleBuilderController::getModuleTitle(),
60
    	   );
61
    }
62
63
 	//STUDIO LABELS ONLY//
64
 	//TODO Bundle Studio and ModuleBuilder label handling to increase maintainability.
65
 	function display()
66
 	{
67
		$editModule = $_REQUEST['view_module'];
68
		$allLabels = (!empty($_REQUEST['labels']) && $_REQUEST['labels']== 'all');
69
70
 		if (!isset($_REQUEST['MB']))
71
		{
72
		    global $app_list_strings;
73
		    $moduleNames = array_change_key_case($app_list_strings['moduleList']);
74
		    $translatedEditModule = $moduleNames[strtolower($editModule)];
75
		}
76
		$selected_lang = (!empty($_REQUEST['selected_lang'])? $_REQUEST['selected_lang']:$_SESSION['authenticated_user_language']);
77
		if(empty($selected_lang)){
78
		    $selected_lang = $GLOBALS['sugar_config']['default_language'];
79
		}
80
81
		$smarty = new Sugar_Smarty();
82
		global $mod_strings;
83
        $smarty->assign('mod_strings', $mod_strings);
84
		$smarty->assign('available_languages',get_languages());
85
86
87
        $objectName = BeanFactory::getObjectName($editModule);
88
        VardefManager::loadVardef($editModule, $objectName);
89
        global $dictionary;
90
        $vnames = array();
91
		//jchi 24557 . We should list all the lables in viewdefs(list,detail,edit,quickcreate) that the user can edit them.
92
		require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php' ;
93
        $parser = new ListLayoutMetaDataParser ( MB_LISTVIEW, $editModule ) ;
94
        foreach ( $parser->getLayout() as $key => $def )
95
        {
96
        	if(isset($def['label']) ) {
97
               $vnames[$def['label']] = $def['label'];
98
        	}
99
        }
100
101
       require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
102
        $variableMap = $this->getVariableMap($editModule);
103
        foreach($variableMap as $key => $value){
104
        	$gridLayoutMetaDataParserTemp = new GridLayoutMetaDataParser ( $value, $editModule) ;
105
        	foreach ( $gridLayoutMetaDataParserTemp->getLayout() as $panel)
106
	        {
107
	                foreach ( $panel as $row )
108
	                {
109
	                    foreach ( $row as $fieldArray )
110
	                    { // fieldArray is an array('name'=>name,'label'=>label)
111
	                        if (isset ( $fieldArray [ 'label' ] ))
112
	                        {
113
	                            $vnames[$fieldArray [ 'label' ] ] = $fieldArray [ 'label' ] ;
114
	                        }
115
	                    }
116
	                }
117
	        }
118
        }
119
        //end
120
121
        //Get Subpanel Labels:
122
        require_once ('include/SubPanel/SubPanel.php') ;
123
        $subList =  SubPanel::getModuleSubpanels ( $editModule );
124
        foreach($subList as $subpanel => $titleLabel) {
125
        	$vnames[$titleLabel] = $titleLabel;
126
        }
127
128
        foreach($dictionary[$objectName]['fields'] as $name=>$def) {
129
        	if(isset($def['vname'])) {
130
               $vnames[$def['vname']] = $def['vname'];
131
        	}
132
		}
133
 	    $formatted_mod_strings = array();
134
135
 	    //we shouldn't set the $refresh=true here, or will lost template language mod_strings.
136
 	    //return_module_language($selected_lang, $editModule,false) : the mod_strings will be included from cache files here.
137
        foreach(return_module_language($selected_lang, $editModule,false) as $name=>$label) {
0 ignored issues
show
The expression return_module_language($...ng, $editModule, false) of type array|null is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
138
        		//#25294
139
        	 	if($allLabels || isset($vnames[$name]) || preg_match( '/lbl_city|lbl_country|lbl_billing_address|lbl_alt_address|lbl_shipping_address|lbl_postal_code|lbl_state$/si' , $name)) {
140
                    $formatted_mod_strings[$name] = htmlentities($label, ENT_QUOTES, 'UTF-8');
141
        	 	}
142
        }
143
        //Grab everything from the custom files
144
        $mod_bak = $mod_strings;
145
        $files = array(
146
            "custom/modules/$editModule/language/$selected_lang.lang.php",
147
            "custom/modules/$editModule/Ext/Language/$selected_lang.lang.ext.php"
148
        );
149
        foreach($files as $langfile){
150
        	$mod_strings = array();
151
        	if (is_file($langfile))
152
        	{
153
        	   include($langfile);
154
        	   foreach($mod_strings as $key => $label)
155
        	   {
156
                    $formatted_mod_strings[$key] = htmlentities($label, ENT_QUOTES, 'UTF-8');
157
        	   }
158
        	}
159
        }
160
        $mod_strings = $mod_bak;
161
        ksort($formatted_mod_strings);
162
		$smarty->assign('MOD', $formatted_mod_strings);
163
		$smarty->assign('view_module', $editModule);
164
		$smarty->assign('APP', $GLOBALS['app_strings']);
165
		$smarty->assign('selected_lang', $selected_lang);
166
		$smarty->assign('defaultHelp', 'labelsBtn');
167
		$smarty->assign('assistant', array('key'=>'labels', 'group'=>'module'));
168
		$smarty->assign('labels_choice', $mod_strings['labelTypes']);
169
		$smarty->assign('labels_current', $allLabels?"all":"");
170
171
		$ajax = new AjaxCompose();
172
		$ajax->addCrumb($mod_strings['LBL_STUDIO'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
173
		$ajax->addCrumb($translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module='.$editModule.'")');
174
		$ajax->addCrumb($mod_strings['LBL_LABELS'], '');
175
176
 		$html = $smarty->fetch('modules/ModuleBuilder/tpls/labels.tpl');
177
 		$ajax->addSection('center', $GLOBALS['mod_strings']['LBL_SECTION_EDLABELS'], $html);
178
 		echo $ajax->getJavascript();
179
 	}
180
    
181
    // fixing bug #39749: Quick Create in Studio
182
    function getVariableMap($module)
183
    {
184
        $variableMap = array(MB_EDITVIEW => 'EditView', 
185
                             MB_DETAILVIEW => 'DetailView', 
186
                             MB_QUICKCREATE => 'QuickCreate');
187
        
188
        $hideQuickCreateForModules = array('KBDocuments',
189
                                           'ProjectTask',
190
                                           'Campaigns',
191
                                           'Quotes',
192
                                           'ProductTemplates');
193
        
194
        if(in_array($module, $hideQuickCreateForModules))
195
        {
196
            if(isset($variableMap['quickcreate']))
197
            {
198
                unset($variableMap['quickcreate']);
199
            }
200
        }
201
        
202
        if($module == 'KBDocuments')
203
        {
204
            $variableMap  = array();
205
        }
206
        
207
        return $variableMap;
208
    }
209
}
210