This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | require_once('include/nusoap/nusoap.php'); |
||
41 | require_once('ModuleInstall/PackageManager/PackageManagerDownloader.php'); |
||
42 | |||
43 | define("HTTPS_URL", "https://depot.sugarcrm.com/depot/SugarDepotSoap.php"); |
||
44 | define("ACTIVE_STATUS", "ACTIVE"); |
||
45 | |||
46 | class PackageManagerComm{ |
||
47 | /** |
||
48 | * Initialize the soap client and store in the $GLOBALS object for use |
||
49 | * |
||
50 | * @param login designates whether we want to try to login after we initialize or not |
||
51 | */ |
||
52 | function initialize($login = true){ |
||
53 | if(empty($GLOBALS['SugarDepot'])){ |
||
54 | $GLOBALS['log']->debug('USING HTTPS TO CONNECT TO HEARTBEAT'); |
||
55 | $soap_client = new nusoapclient(HTTPS_URL, false); |
||
0 ignored issues
–
show
|
|||
56 | $ping = $soap_client->call('sugarPing', array()); |
||
57 | $GLOBALS['SugarDepot'] = $soap_client; |
||
58 | } |
||
59 | //if we do not have a session, then try to login |
||
60 | if($login && empty($_SESSION['SugarDepotSessionID'])){ |
||
61 | PackageManagerComm::login(); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Check for errors in the response or error_str |
||
67 | */ |
||
68 | function errorCheck(){ |
||
69 | if(!empty($GLOBALS['SugarDepot']->error_str)){ |
||
70 | $GLOBALS['log']->fatal($GLOBALS['SugarDepot']->error_str); |
||
71 | $GLOBALS['log']->fatal($GLOBALS['SugarDepot']->response); |
||
72 | } |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Set the credentials for use during login |
||
77 | * |
||
78 | * @param username Mambo username |
||
79 | * @param password Mambo password |
||
80 | * @param download_key User's download key |
||
81 | */ |
||
82 | function setCredentials($username, $password, $download_key){ |
||
83 | $_SESSION['SugarDepotUsername'] = $username; |
||
84 | $_SESSION['SugarDepotPassword'] = $password; |
||
85 | $_SESSION['SugarDepotDownloadKey'] = $download_key; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Clears out the session so we can reauthenticate. |
||
90 | */ |
||
91 | function clearSession(){ |
||
92 | $_SESSION['SugarDepotSessionID'] = null; |
||
93 | unset($_SESSION['SugarDepotSessionID']); |
||
94 | } |
||
95 | ///////////////////////////////////////////////////////// |
||
96 | ////////// BEGIN: Base Functions for Communicating with the depot |
||
97 | /** |
||
98 | * Login to the depot |
||
99 | * |
||
100 | * @return true if successful, false otherwise |
||
101 | */ |
||
102 | function login($terms_checked = true){ |
||
103 | if(empty($_SESSION['SugarDepotSessionID'])){ |
||
104 | global $license; |
||
105 | $GLOBALS['log']->debug("Begin SugarDepot Login"); |
||
106 | PackageManagerComm::initialize(false); |
||
107 | require('sugar_version.php'); |
||
108 | require('config.php'); |
||
109 | $credentials = PackageManager::getCredentials(); |
||
110 | if(empty($license))loadLicense(); |
||
111 | $info = sugarEncode('2813', serialize(getSystemInfo(true))); |
||
112 | $pm = new PackageManager(); |
||
113 | $installed = $pm->buildInstalledReleases(); |
||
114 | $installed = base64_encode(serialize($installed)); |
||
115 | $params = array('installed_modules' => $installed, 'terms_checked' => $terms_checked, 'system_name' => $credentials['system_name']); |
||
116 | $terms_version = (!empty($_SESSION['SugarDepot_TermsVersion']) ? $_SESSION['SugarDepot_TermsVersion'] : ''); |
||
117 | if(!empty($terms_version)) |
||
118 | $params['terms_version'] = $terms_version; |
||
119 | |||
120 | $result = $GLOBALS['SugarDepot']->call('depotLogin', array(array('user_name' => $credentials['username'], 'password' => $credentials['password']),'info'=>$info, 'params' => $params)); |
||
121 | PackageManagerComm::errorCheck(); |
||
122 | if(!is_array($result)) |
||
123 | $_SESSION['SugarDepotSessionID'] = $result; |
||
124 | $GLOBALS['log']->debug("End SugarDepot Login"); |
||
125 | return $result; |
||
126 | } |
||
127 | else |
||
128 | return $_SESSION['SugarDepotSessionID']; |
||
129 | } |
||
130 | |||
131 | /** |
||
132 | * Logout from the depot |
||
133 | */ |
||
134 | function logout(){ |
||
135 | PackageManagerComm::initialize(); |
||
136 | $result = $GLOBALS['SugarDepot']->call('depotLogout', array('session_id' => $_SESSION['SugarDepotSessionID'])); |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * Get all promotions from the depot |
||
141 | */ |
||
142 | function getPromotion(){ |
||
143 | PackageManagerComm::initialize(); |
||
144 | //check for fault first and then return |
||
145 | $name_value_list = $GLOBALS['SugarDepot']->call('depotGetPromotion', array('session_id' => $_SESSION['SugarDepotSessionID'])); |
||
146 | return $name_value_list; |
||
147 | } |
||
148 | |||
149 | /** |
||
150 | * A generic function which given a category_id some filter will |
||
151 | * return an object which contains categories and packages |
||
152 | * |
||
153 | * @param category_id the category_id to fetch |
||
154 | * @param filter a filter which will limit theh number of results returned |
||
155 | * @return categories_and_packages |
||
156 | * @see categories_and_packages |
||
157 | */ |
||
158 | function getCategoryPackages($category_id, $filter = array()){ |
||
159 | PackageManagerComm::initialize(); |
||
160 | //check for fault |
||
161 | return $GLOBALS['SugarDepot']->call('depotGetCategoriesPackages', array('session_id' => $_SESSION['SugarDepotSessionID'], 'category_id' => $category_id, 'filter' => $filter)); |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * Return a list of child categories to the parent specified in category_id |
||
166 | * |
||
167 | * @param category_id the parent category_id |
||
168 | * @param filter a filter which will limit theh number of results returned |
||
169 | * @return categories_and_packages |
||
170 | * @see categories_and_packages |
||
171 | */ |
||
172 | function getCategories($category_id, $filter = array()){ |
||
173 | PackageManagerComm::initialize(); |
||
174 | //check for fault |
||
175 | return $GLOBALS['SugarDepot']->call('depotGetCategories', array('session_id' => $_SESSION['SugarDepotSessionID'], 'category_id' => $category_id, 'filter' => $filter)); |
||
176 | } |
||
177 | |||
178 | /** |
||
179 | * Return a list of packages which belong to the parent category_id |
||
180 | * |
||
181 | * @param category_id the category_id to fetch |
||
182 | * @param filter a filter which will limit theh number of results returned |
||
183 | * @return packages |
||
184 | * @see packages |
||
185 | */ |
||
186 | function getPackages($category_id, $filter = array()){ |
||
187 | PackageManagerComm::initialize(); |
||
188 | //check for fault |
||
189 | return $GLOBALS['SugarDepot']->call('depotGetPackages', array('session_id' => $_SESSION['SugarDepotSessionID'], 'category_id' => $category_id, 'filter' => $filter)); |
||
190 | } |
||
191 | |||
192 | /** |
||
193 | * Return a list of releases belong to a package |
||
194 | * |
||
195 | * @param category_id the category_id to fetch |
||
196 | * @param package_id the package id which the release belongs to |
||
197 | * @return packages |
||
198 | * @see packages |
||
199 | */ |
||
200 | function getReleases($category_id, $package_id, $filter = array()){ |
||
201 | PackageManagerComm::initialize(); |
||
202 | //check for fault |
||
203 | return $GLOBALS['SugarDepot']->call('depotGetReleases', array('session_id' => $_SESSION['SugarDepotSessionID'], 'category_id' => $category_id, 'package_id' => $package_id, 'filter' => $filter)); |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * Download a given release |
||
208 | * |
||
209 | * @param category_id the category_id to fetch |
||
210 | * @param package_id the package id which the release belongs to |
||
211 | * @param release_id the release we want to download |
||
212 | * @return download |
||
213 | * @see download |
||
214 | */ |
||
215 | function download($category_id, $package_id, $release_id){ |
||
216 | PackageManagerComm::initialize(); |
||
217 | //check for fault |
||
218 | return $GLOBALS['SugarDepot']->call('depotDownloadRelease', array('session_id' => $_SESSION['SugarDepotSessionID'], 'category_id' => $category_id, 'package_id' => $package_id, 'release_id' => $release_id)); |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * Add a requested download to the queue |
||
223 | * |
||
224 | * @param category_id the category_id to fetch |
||
225 | * @param package_id the package id which the release belongs to |
||
226 | * @param release_id the release we want to download |
||
227 | * @return the filename to download |
||
228 | */ |
||
229 | function addDownload($category_id, $package_id, $release_id){ |
||
230 | PackageManagerComm::initialize(); |
||
231 | //check for fault |
||
232 | return $GLOBALS['SugarDepot']->call('depotAddDownload', array('session_id' => $_SESSION['SugarDepotSessionID'], 'category_id' => $category_id, 'package_id' => $package_id, 'release_id' => $release_id, 'download_key' => '123')); |
||
233 | } |
||
234 | |||
235 | /** |
||
236 | * Call the PackageManagerDownloader function which uses curl in order to download the specified file |
||
237 | * |
||
238 | * @param filename the file to download |
||
239 | * @return path to downloaded file |
||
240 | */ |
||
241 | static public function performDownload($filename){ |
||
0 ignored issues
–
show
|
|||
242 | PackageManagerComm::initialize(); |
||
243 | //check for fault |
||
244 | $GLOBALS['log']->debug("Performing download from depot: Session ID: ".$_SESSION['SugarDepotSessionID']." Filename: ".$filename); |
||
245 | return PackageManagerDownloader::download($_SESSION['SugarDepotSessionID'], $filename); |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | * Retrieve documentation for the given release or package |
||
250 | * |
||
251 | * @param package_id the specified package to retrieve documentation |
||
252 | * @param release_id the specified release to retrieve documentation |
||
253 | * |
||
254 | * @return documents |
||
255 | */ |
||
256 | function getDocumentation($package_id, $release_id){ |
||
257 | PackageManagerComm::initialize(); |
||
258 | //check for fault |
||
259 | return $GLOBALS['SugarDepot']->call('depotGetDocumentation', array('session_id' => $_SESSION['SugarDepotSessionID'], 'package_id' => $package_id, 'release_id' => $release_id)); |
||
260 | } |
||
261 | |||
262 | function getTermsAndConditions(){ |
||
263 | PackageManagerComm::initialize(false); |
||
264 | return $GLOBALS['SugarDepot']->call('depotTermsAndConditions',array()); |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * Log that the user has clicked on a document |
||
269 | * |
||
270 | * @param document_id the document the user has clicked on |
||
271 | */ |
||
272 | function downloadedDocumentation($document_id){ |
||
273 | PackageManagerComm::initialize(); |
||
274 | //check for fault |
||
275 | $GLOBALS['log']->debug("Logging Document: ".$document_id); |
||
276 | $GLOBALS['SugarDepot']->call('depotDownloadedDocumentation', array('session_id' => $_SESSION['SugarDepotSessionID'], 'document_id' => $document_id)); |
||
277 | } |
||
278 | |||
279 | /** |
||
280 | * Send the list of installed objects, could be patches, or modules, .. to the depot and allow the depot to send back |
||
281 | * a list of corresponding updates |
||
282 | * |
||
283 | * @param objects_to_check an array of name_value_lists which contain the appropriate values |
||
284 | * which will allow the depot to check for updates |
||
285 | * |
||
286 | * @return array of name_value_lists of corresponding updates |
||
287 | */ |
||
288 | function checkForUpdates($objects_to_check){ |
||
289 | PackageManagerComm::initialize(); |
||
290 | //check for fault |
||
291 | return $GLOBALS['SugarDepot']->call('depotCheckForUpdates', array('session_id' => $_SESSION['SugarDepotSessionID'], 'objects' => $objects_to_check)); |
||
292 | } |
||
293 | /** |
||
294 | * Ping the server to determine if we have established proper communication |
||
295 | * |
||
296 | * @return true if we can communicate with the server and false otherwise |
||
297 | */ |
||
298 | function isAlive(){ |
||
299 | PackageManagerComm::initialize(false); |
||
300 | |||
301 | $status = $GLOBALS['SugarDepot']->call('sugarPing', array()); |
||
302 | if(empty($status) || $GLOBALS['SugarDepot']->getError() || $status != ACTIVE_STATUS){ |
||
303 | return false; |
||
304 | }else{ |
||
305 | return true; |
||
306 | } |
||
307 | } |
||
308 | ////////// END: Base Functions for Communicating with the depot |
||
309 | //////////////////////////////////////////////////////// |
||
310 | } |
||
311 | |||
312 | ?> |
||
313 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.