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/Bugs/Bug.php (2 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
/*********************************************************************************
42
43
 * Description:  TODO: To be written.
44
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
45
 * All Rights Reserved.
46
 * Contributor(s): ______________________________________..
47
 ********************************************************************************/
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Bug is used to store customer information.
64
class Bug extends SugarBean {
65
        var $field_name_map = array();
66
	// Stored fields
67
	var $id;
68
	var $date_entered;
69
	var $date_modified;
70
	var $modified_user_id;
71
	var $assigned_user_id;
72
	var $bug_number;
73
	var $description;
74
	var $name;
75
	var $status;
76
	var $priority;
77
78
	// These are related
79
	var $resolution;
80
	var $found_in_release;
81
	var $release_name;
82
	var $fixed_in_release_name;
83
	var $created_by;
84
	var $created_by_name;
85
	var $modified_by_name;
86
	var $account_id;
87
	var $contact_id;
88
	var $case_id;
89
	var $task_id;
90
	var $note_id;
91
	var $meeting_id;
92
	var $call_id;
93
	var $email_id;
94
	var $assigned_user_name;
95
	var $type;
96
97
	//BEGIN Additional fields being added to Bugs
98
99
	var $fixed_in_release;
100
	var $work_log;
101
	var $source;
102
	var $product_category;
103
	//END Additional fields being added to Bugs
104
105
	var $module_dir = 'Bugs';
106
	var $table_name = "bugs";
107
	var $rel_account_table = "accounts_bugs";
108
	var $rel_contact_table = "contacts_bugs";
109
	var $rel_case_table = "cases_bugs";
110
    var $importable = true;
111
	var $object_name = "Bug";
112
113
	// This is used to retrieve related fields from form posts.
114
	var $additional_column_fields = Array('assigned_user_name', 'assigned_user_id', 'case_id', 'account_id', 'contact_id', 'task_id', 'note_id', 'meeting_id', 'call_id', 'email_id');
115
116
	var $relationship_fields = Array('case_id'=>'cases', 'account_id' => 'accounts', 'contact_id'=>'contacts',
117
									'task_id'=>'tasks', 'note_id'=>'notes', 'meeting_id'=>'meetings',
118
									'call_id'=>'calls', 'email_id'=>'emails');
119
120 21
    public function __construct() {
121 21
		parent::__construct();
122
123
124 21
		$this->setupCustomFields('Bugs');
125
126 21
		foreach ($this->field_defs as $field)
127
                {
128 21
                        $this->field_name_map[$field['name']] = $field;
129
                }
130
131 21
	}
132
133
	/**
134
	 * @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
135
	 */
136
	public function Bug(){
137
		$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
138
		if(isset($GLOBALS['log'])) {
139
			$GLOBALS['log']->deprecated($deprecatedMessage);
140
		}
141
		else {
142
			trigger_error($deprecatedMessage, E_USER_DEPRECATED);
143
		}
144
		self::__construct();
145
	}
146
147
	var $new_schema = true;
148
149
150
151
152
153 2
	function get_summary_text()
154
	{
155 2
		return "$this->name";
156
	}
157
158 1
	function create_list_query($order_by, $where, $show_deleted = 0)
159
	{
160
		// Fill in the assigned_user_name
161
//		$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
162
163 1
        $custom_join = $this->getCustomJoin();
164
165 1
                $query = "SELECT ";
166
167
		$query .= "
168
                               bugs.*
169
170 1
                                ,users.user_name as assigned_user_name, releases.id release_id, releases.name release_name";
171 1
        $query .= $custom_join['select'];
172 1
                                $query .= " FROM bugs ";
173
174
175
		$query .= "				LEFT JOIN releases ON bugs.found_in_release=releases.id
176
								LEFT JOIN users
177 1
                                ON bugs.assigned_user_id=users.id";
178 1
                                $query .= "  ";
179 1
        $query .= $custom_join['join'];
180 1
            $where_auto = '1=1';
181 1
			if($show_deleted == 0){
182 1
            	$where_auto = " $this->table_name.deleted=0 ";
183
			}else if($show_deleted == 1){
184
				$where_auto = " $this->table_name.deleted=1 ";
185
			}
186
187
188 1
		if($where != "")
189 1
			$query .= "where $where AND ".$where_auto;
190
		else
191 1
			$query .= "where ".$where_auto;
192 1
		if(substr_count($order_by, '.') > 0){
193 1
			$query .= " ORDER BY $order_by";
194
		}
195 1
		else if($order_by != "")
196
			$query .= " ORDER BY $order_by";
197
		else
198 1
			$query .= " ORDER BY bugs.name";
199 1
		return $query;
200
	}
201
202 1
        function create_export_query($order_by, $where, $relate_link_join='')
203
        {
204 1
            $custom_join = $this->getCustomJoin(true, true, $where);
205 1
            $custom_join['join'] .= $relate_link_join;
206
                $query = "SELECT
207
                                bugs.*,
208
                                r1.name found_in_release_name,
209
                                r2.name fixed_in_release_name,
210 1
                                users.user_name assigned_user_name";
211 1
            $query .=  $custom_join['select'];
212 1
                                $query .= " FROM bugs ";
213
		$query .= "				LEFT JOIN releases r1 ON bugs.found_in_release = r1.id
214
								LEFT JOIN releases r2 ON bugs.fixed_in_release = r2.id
215
								LEFT JOIN users
216 1
                                ON bugs.assigned_user_id=users.id";
217 1
            $query .=  $custom_join['join'];
218 1
                                $query .= "";
219
                $where_auto = "  bugs.deleted=0
220 1
                ";
221
222 1
                if($where != "")
223 1
                        $query .= " where $where AND ".$where_auto;
224
                else
225 1
                        $query .= " where ".$where_auto;
226
227 1
                if($order_by != "")
228 1
                        $query .= " ORDER BY $order_by";
229
                else
230 1
                        $query .= " ORDER BY bugs.bug_number";
231
232 1
                return $query;
233
        }
234 1
	function fill_in_additional_list_fields()
235
	{
236 1
		parent::fill_in_additional_list_fields();
237
		// Fill in the assigned_user_name
238
		//$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
239
240
//	   $this->set_fixed_in_release();
241 1
	}
242
243 2
	function fill_in_additional_detail_fields()
244
	{
245
246
	    /*
247
		// Fill in the assigned_user_name
248
		$this->assigned_user_name = get_assigned_user_name($this->assigned_user_id);
249
        */
250 2
        parent::fill_in_additional_detail_fields();
251
		//$this->created_by_name = get_assigned_user_name($this->created_by);
252
		//$this->modified_by_name = get_assigned_user_name($this->modified_user_id);
253 2
		$this->set_release();
254 2
		$this->set_fixed_in_release();
255 2
	}
256
257
258 6
	public function set_release()
259
	{
260 6
	    static $releases;
261
262 6
	    if ( empty($this->found_in_release) ) {
263 4
	        return;
264
	    }
265 2
	    if ( isset($releases[$this->found_in_release]) ) {
266 1
	        $this->release_name = $releases[$this->found_in_release];
267 1
	        return;
268
	    }
269
270 1
		$query = "SELECT r1.name from releases r1, $this->table_name i1 where r1.id = i1.found_in_release and i1.id = '$this->id' and i1.deleted=0 and r1.deleted=0";
271 1
        $result = $this->db->query($query,true," Error filling in additional detail fields: ");
272
273
        // Get the id and the name.
274 1
        $row = $this->db->fetchByAssoc($result);
275
276 1
        if($row != null)
277
        {
278
            $this->release_name = $row['name'];
279
        }
280
        else
281
        {
282 1
            $this->release_name = '';
283
        }
284
285 1
        $releases[$this->found_in_release] = $this->release_name;
286 1
	}
287
288
289 2
	public function set_fixed_in_release()
290
	{
291 2
	    static $releases;
292
293 2
	    if ( empty($this->fixed_in_release) ) {
294 2
	        return;
295
	    }
296
	    if ( isset($releases[$this->fixed_in_release]) ) {
297
	        $this->fixed_in_release_name = $releases[$this->fixed_in_release];
298
	        return;
299
	    }
300
301
        $query = "SELECT r1.name from releases r1, $this->table_name i1 where r1.id = i1.fixed_in_release and i1.id = '$this->id' and i1.deleted=0 and r1.deleted=0";
302
        $result = $this->db->query($query,true," Error filling in additional detail fields: ");
303
304
        // Get the id and the name.
305
        $row = $this->db->fetchByAssoc($result);
306
307
308
309
        if($row != null)
310
        {
311
            $this->fixed_in_release_name = $row['name'];
312
        }
313
        else
314
        {
315
            $this->fixed_in_release_name = '';
316
        }
317
318
        $releases[$this->fixed_in_release] = $this->fixed_in_release_name;
319
320
	}
321
322
323 1
	function get_list_view_data(){
324 1
		global $current_language;
325 1
		$the_array = parent::get_list_view_data();
326 1
		$app_list_strings = return_app_list_strings_language($current_language);
327 1
		$mod_strings = return_module_language($current_language, 'Bugs');
328
329 1
		$this->set_release();
330
331
        // The new listview code only fetches columns that we're displaying and not all
332
        // the columns so we need these checks.
333 1
	   $the_array['NAME'] = (($this->name == "") ? "<em>blank</em>" : $this->name);
334 1
        $the_array['PRIORITY'] = empty($this->priority)? "" : (!isset($app_list_strings[$this->field_name_map['priority']['options']][$this->priority]) ? $this->priority : $app_list_strings[$this->field_name_map['priority']['options']][$this->priority]);
335 1
        $the_array['STATUS'] = empty($this->status)? "" : (!isset($app_list_strings[$this->field_name_map['status']['options']][$this->status]) ? $this->status : $app_list_strings[$this->field_name_map['status']['options']][$this->status]);
336 1
        $the_array['TYPE'] = empty($this->type)? "" : (!isset($app_list_strings[$this->field_name_map['type']['options']][$this->type]) ? $this->type : $app_list_strings[$this->field_name_map['type']['options']][$this->type]);
337
338 1
	   $the_array['RELEASE']= $this->release_name;
339 1
	   $the_array['BUG_NUMBER'] = $this->bug_number;
340 1
	   $the_array['ENCODED_NAME']=$this->name;
341
342 1
    	return  $the_array;
343
	}
344
345
	/**
346
		builds a generic search based on the query string using or
347
		do not include any $this-> because this is called on without having the class instantiated
348
	*/
349 1
	function build_generic_where_clause ($the_query_string) {
350 1
	$where_clauses = Array();
351 1
	$the_query_string = $this->db->quote($the_query_string);
352 1
	array_push($where_clauses, "bugs.name like '$the_query_string%'");
353 1
	if (is_numeric($the_query_string)) array_push($where_clauses, "bugs.bug_number like '$the_query_string%'");
354
355 1
	$the_where = "";
356 1
	foreach($where_clauses as $clause)
357
	{
358 1
		if($the_where != "") $the_where .= " or ";
359 1
		$the_where .= $clause;
360
	}
361
362 1
	return $the_where;
363
	}
364
365 1
	function set_notification_body($xtpl, $bug)
366
	{
367 1
		global $mod_strings, $app_list_strings;
368
369 1
		$bug->set_release();
370
371 1
		$xtpl->assign("BUG_SUBJECT", $bug->name);
372 1
		$xtpl->assign("BUG_TYPE", $app_list_strings['bug_type_dom'][$bug->type]);
373 1
		$xtpl->assign("BUG_PRIORITY", $app_list_strings['bug_priority_dom'][$bug->priority]);
374 1
		$xtpl->assign("BUG_STATUS", $app_list_strings['bug_status_dom'][$bug->status]);
375 1
		$xtpl->assign("BUG_RESOLUTION", $app_list_strings['bug_resolution_dom'][$bug->resolution]);
376 1
		$xtpl->assign("BUG_RELEASE", $bug->release_name);
377 1
		$xtpl->assign("BUG_DESCRIPTION", $bug->description);
378 1
		$xtpl->assign("BUG_WORK_LOG", $bug->work_log);
379 1
		$xtpl->assign("BUG_BUG_NUMBER", $bug->bug_number);
380 1
		return $xtpl;
381
	}
382
383 21
	function bean_implements($interface){
384
		switch($interface){
385 21
			case 'ACL':return true;
0 ignored issues
show
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
Terminating statement must be on a line by itself

As per the PSR-2 coding standard, the break (or other terminating) statement must be on a line of its own.

switch ($expr) {
     case "A":
         doSomething();
         break; //wrong
     case "B":
         doSomething();
         break; //right
     case "C:":
         doSomething();
         return true; //right
 }

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
386
		}
387 2
		return false;
388
	}
389
390 1
	function save($check_notify = FALSE){
391 1
		return parent::save($check_notify);
392
	}
393
}
394
395 1
function getReleaseDropDown(){
396 1
	static $releases = null;
397 1
	if(!$releases){
398 1
		$seedRelease = new Release();
399 1
		$releases = $seedRelease->get_releases(TRUE, "Active");
400
	}
401 1
	return $releases;
402
}
403
?>