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/resource/ResourceManager.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
/*********************************************************************************
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
 * ResourceManager.php
43
 * This class is responsible for resource management of SQL queries, file usage, etc.
44
 */
45
class ResourceManager {
0 ignored issues
show
Since you have declared the constructor as private, maybe you should also declare the class as final.
Loading history...
46
47
private static $instance;
48
private $_observers = array();
49
50
/**
51
 * The constructor; declared as private
52
 */
53 1
private function __construct() {
54
55 1
}
56
57
/**
58
 * getInstance
59
 * Singleton method to return static instance of ResourceManager
60
 * @return The static singleton ResourceManager instance
61
 */
62 1
static public function getInstance(){
0 ignored issues
show
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
63 1
    if (!isset(self::$instance)) {
64 1
        self::$instance = new ResourceManager();
65
    } // if
66 1
    return self::$instance;
67
}
68
69
/**
70
 * setup
71
 * Handles determining the appropriate setup based on client type.
72
 * It will create a SoapResourceObserver instance if the $module parameter is set to
73
 * 'Soap'; otherwise, it will try to create a WebResourceObserver instance.
74
 * @param $module The module value used to create the corresponding observer
75
 * @return boolean value indicating whether or not an observer was successfully setup
76
 */
77 1
public function setup($module) {
78
	//Check if config.php exists
79 1
	if(!file_exists('config.php') || empty($module)) {
80 1
	   return false;
81
	}
82
83 1
    if($module == 'Soap') {
84
      require_once('include/resource/Observers/SoapResourceObserver.php');
85
      $observer = new SoapResourceObserver('Soap');
86
    } elseif(defined('SUITE_PHPUNIT_RUNNER')) {
87 1
        return;
88
    }else{
89
      require_once('include/resource/Observers/WebResourceObserver.php');
90
      $observer = new WebResourceObserver($module);
91
    }
92
93
	//Load config
94
	if(!empty($observer->module)) {
95
		$limit = 0;
96
97
		if(isset($GLOBALS['sugar_config']['resource_management'])) {
98
			   $res = $GLOBALS['sugar_config']['resource_management'];
99
			if(!empty($res['special_query_modules']) &&
100
			   in_array($observer->module, $res['special_query_modules']) &&
101
			   !empty($res['special_query_limit']) &&
102
			   is_int($res['special_query_limit']) &&
103
			   $res['special_query_limit'] > 0) {
104
			   $limit = $res['special_query_limit'];
105
			} else if(!empty($res['default_limit']) && is_int($res['default_limit']) && $res['default_limit'] > 0) {
106
			   $limit = $res['default_limit'];
107
			}
108
		} //if
109
110
		if($limit) {
111
112
		   $db = DBManagerFactory::getInstance();
113
		   $db->setQueryLimit($limit);
114
		   $observer->setLimit($limit);
115
		   $this->_observers[] = $observer;
116
		}
117
		return true;
118
	}
119
120
	return false;
121
}
122
123
/**
124
 * notifyObservers
125
 * This method notifies the registered observers with the provided message.
126
 * @param $msg Message from language file to notify observers with
127
 */
128
public function notifyObservers($msg) {
129
130
	if(empty($this->_observers)) {
131
	   return;
132
	}
133
134
    //Notify observers limit has been reached
135
    if(empty($GLOBALS['app_strings'])) {
136
       $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
137
    }
138
    $limitMsg = $GLOBALS['app_strings'][$msg];
139
    foreach( $this->_observers as $observer) {
140
	    $limit = $observer->limit;
141
	    $module = $observer->module;
142
	    eval("\$limitMsg = \"$limitMsg\";");
0 ignored issues
show
It is generally not recommended to use eval unless absolutely required.

On one hand, eval might be exploited by malicious users if they somehow manage to inject dynamic content. On the other hand, with the emergence of faster PHP runtimes like the HHVM, eval prevents some optimization that they perform.

Loading history...
143
	    $GLOBALS['log']->fatal($limitMsg);
144
	    $observer->notify($limitMsg);
145
    }
146
}
147
148
149
/*
150
 * getObservers
151
 * Returns the observer instances that have been setup for the ResourceManager instance
152
 * @return Array of ResourceObserver(s)
153
 */
154
function getObservers() {
155
    return $this->_observers;
156
}
157
158
}
159
?>