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/EditView/SubpanelQuickCreate.php (3 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 1
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 1
require_once('include/EditView/EditView2.php');
42
/**
43
 * Quick create form in the subpanel
44
 * @api
45
 */
46
class SubpanelQuickCreate{
47
    public $defaultProcess = true;
48
49
    /**
50
     * The view type to use
51
     *
52
     * @var string
53
     */
54
    public $viewType = 'QuickCreate';
55
56 1
    public function __construct($module, $view='QuickCreate', $proccessOverride = false)
57
    {
58 1
        $this->viewType = $view;
59
60
        //treat quickedit and quickcreate views as the same
61 1
        if($this->viewType == 'QuickEdit') {
62
            $this->viewType = 'QuickCreate';
63
        }
64
65
        // Get the viewdefs source file, called here to ensure proper viewType setting
66 1
        $source = $this->getModuleViewDefsSourceFile($module, $this->viewType);
67
68
		// locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. custom/module/editviewdefs.php 4. module/editviewdefs.php
69 1
		$base = 'modules/' . $module . '/metadata/';
70 1
		$source = 'custom/' . $base . strtolower($view) . 'defs.php';
71 1
		if (!file_exists( $source))
72
		{
73 1
			$source = $base . strtolower($view) . 'defs.php';
74 1
			if (!file_exists($source))
75
			{
76
				//if our view does not exist default to EditView
77
				$view = 'EditView';
78
				$source = 'custom/' . $base . 'editviewdefs.php';
79
				if (!file_exists($source))
80
				{
81
					$source = $base . 'editviewdefs.php';
82
				}
83
			}
84
		}
85
86 1
        $this->ev = $this->getEditView();
87 1
		$this->ev->view = $this->viewType;
88 1
		$this->ev->ss = new Sugar_Smarty();
89
		//$_REQUEST['return_action'] = 'SubPanelViewer';
90
91 1
        $class = $GLOBALS['beanList'][$module];
92 1
        $bean = new $class();
93 1
        if(!empty($_REQUEST['record'])) {
94
            $bean->retrieve($_REQUEST['record']);
95
        }
96 1
		$this->ev->setup($module, $bean, $source);
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class EditView as the method setup() does only exist in the following sub-classes of EditView: DetailView2. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
97 1
		unset($bean);
98
99
100
		// Bug 49219 - Check empty before set defaults, or the settings from viewdefs above will be overridden.
101 1
        if (!isset($this->ev->defs['templateMeta']['form']['headerTpl']))
102
        {
103 1
            $this->ev->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl';
104
        }
105
106 1
		if (!isset($this->ev->defs['templateMeta']['form']['footerTpl']))
107
        {
108 1
            $this->ev->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl';
109
        }
110
		// Comment below, breaks many out of the box viewdefs
111
		/*if (empty($this->ev->defs['templateMeta']['form']['buttons'])) $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');*/
112 1
		$this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');
113
114
        //Load the parent view class if it exists.  Check for custom file first
115 1
        loadParentView('edit');
116
117 1
		$viewEditSource = 'modules/'.$module.'/views/view.edit.php';
118 1
		if (file_exists('custom/'. $viewEditSource)) {
119
			$viewEditSource = 'custom/'. $viewEditSource;
120
		}
121
122 1
		if(file_exists($viewEditSource) && !$proccessOverride) {
123
            include($viewEditSource);
124
            $c = $module . 'ViewEdit';
125
126
            $customClass = 'Custom' . $c;
127
            if(class_exists($customClass)) {
128
                $c = $customClass;
129
            }
130
131
            if(class_exists($c)) {
132
	            $view = new $c;
133
	            if($view->useForSubpanel) {
134
	            	$this->defaultProcess = false;
135
136
	            	// Check if we should use the module's QuickCreate.tpl file.
137
	            	if($view->useModuleQuickCreateTemplate && file_exists('modules/'.$module.'/tpls/QuickCreate.tpl')) {
138
	            	   $this->ev->defs['templateMeta']['form']['headerTpl'] = 'modules/'.$module.'/tpls/QuickCreate.tpl';
139
	            	}
140
141
		            $view->ev = & $this->ev;
142
		            $view->ss = & $this->ev->ss;
143
					$class = $GLOBALS['beanList'][$module];
144
					if(!empty($GLOBALS['beanFiles'][$class])){
145
						require_once($GLOBALS['beanFiles'][$class]);
146
						$bean = new $class();
147
						$view->bean = $bean;
148
					}
149
					$this->ev->formName = 'form_Subpanel'.$this->ev->view .'_'.$module;
150
					$view->showTitle = false; // Do not show title since this is for subpanel
151
		            $view->display();
152
	            }
153
            }
154
		} //if
155
156 1
		if($this->defaultProcess && !$proccessOverride) {
157
		   $this->process($module);
158
		}
159 1
	}
160
161
	/**
162
	 * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
163
	 */
164
	public function SubpanelQuickCreate($module, $view='QuickCreate', $proccessOverride = false){
165
		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
166
		if(isset($GLOBALS['log'])) {
167
			$GLOBALS['log']->deprecated($deprecatedMessage);
168
		}
169
		else {
170
			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
171
		}
172
		self::__construct($module, $view, $proccessOverride);
173
	}
174
175
	function process($module){
176
        if($_REQUEST['target_action'] == 'QuickCreate'){
177
            $this->ev->view = 'QuickCreate';
178
        }
179
        $form_name = 'form_Subpanel'.$this->ev->view .'_'.$module;
180
        $this->ev->formName = $form_name;
181
        $this->ev->process(true, $form_name);
182
		echo $this->ev->display(false, true);
183
	}
184
185
    /**
186
     * Get EditView object
187
     * @return EditView
188
     */
189 1
    protected function getEditView()
190
    {
191 1
        return new EditView();
0 ignored issues
show
The call to EditView::__construct() misses some required arguments starting with $module.
Loading history...
Deprecated Code introduced by
The class EditView has been deprecated.

This class, trait or interface has been deprecated.

Loading history...
192
    }
193
194
195
    /**
196
     * Finds and returns the best viewdefs to use:
197
     *  1. custom/module/quickcreatedefs.php
198
     *  2. module/quickcreatedefs.php
199
     *  3. custom/module/editviewdefs.php
200
     *  4. module/editviewdefs.php
201
     *
202
     * @param $module
203
     * @param $view
204
     * @return string The path to the viewdefs file to use
205
     */
206 1
    public function getModuleViewDefsSourceFile($module, $view) {
207 1
        $base = 'modules/' . $module . '/metadata/';
208 1
		$source = 'custom/' . $base . strtolower($view) . 'defs.php';
209 1
		if (!file_exists($source)) {
210 1
			$source = $base . strtolower($view) . 'defs.php';
211 1
			if (!file_exists($source)) {
212
				//if our view does not exist default to EditView
213
				$this->viewType = 'EditView';
214
				$source = 'custom/' . $base . 'editviewdefs.php';
215
				if (!file_exists($source)) {
216
					$source = $base . 'editviewdefs.php';
217
				}
218
			}
219
		}
220
221 1
        return $source;
222
    }
223
}
224