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/Documents/views/view.extdoc.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
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
4
/*********************************************************************************
5
 * SugarCRM Community Edition is a customer relationship management program developed by
6
 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
7
8
 * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
9
 * Copyright (C) 2011 - 2014 Salesagility Ltd.
10
 *
11
 * This program is free software; you can redistribute it and/or modify it under
12
 * the terms of the GNU Affero General Public License version 3 as published by the
13
 * Free Software Foundation with the addition of the following permission added
14
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
15
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
16
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
17
 *
18
 * This program is distributed in the hope that it will be useful, but WITHOUT
19
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
21
 * details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License along with
24
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
25
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26
 * 02110-1301 USA.
27
 *
28
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
29
 * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].
30
 *
31
 * The interactive user interfaces in modified source and object code versions
32
 * of this program must display Appropriate Legal Notices, as required under
33
 * Section 5 of the GNU Affero General Public License version 3.
34
 *
35
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
36
 * these Appropriate Legal Notices must retain the display of the "Powered by
37
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
38
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
39
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
40
 ********************************************************************************/
41
42
43
require_once('include/Sugar_Smarty.php');
44
require_once('include/externalAPI/ExternalAPIFactory.php');
45
46
47
class DocumentsViewExtdoc extends SugarView
48
{
49
    var $options = array('show_header' => false, 'show_title' => false, 'show_subpanels' => false, 'show_search' => true, 'show_footer' => false, 'show_javascript' => false, 'view_print' => false,);
50
51
    public function init($bean, $view_object_map) {
52
        $this->seed = $bean;
53
    }
54
55
 	public function display(){
56
57
        global $mod_strings;
58
59
        if ( isset($_REQUEST['name_basic']) ) {
60
            $file_search = trim($_REQUEST['name_basic']);
61
        } else {
62
            $file_search = '';
63
        }
64
        
65
        if ( !isset($_REQUEST['apiName']) ) {
66
            $apiName = 'IBMSmartCloud';
67
        } else {
68
            $tmpApi = ExternalAPIFactory::loadAPI($_REQUEST['apiName'],true);
69
            if ( $tmpApi === false )
70
            {
71
                $GLOBALS['log']->error(string_format($mod_strings['ERR_INVALID_EXTERNAL_API_ACCESS'], array($_REQUEST['apiName'])));
72
                return;
73
            }
74
            $apiName = $_REQUEST['apiName'];
75
        }
76
77
        // See if we are running as a popup window
78
        if ( isset($_REQUEST['isPopup']) && $_REQUEST['isPopup'] == 1 && !empty($_REQUEST['elemBaseName']) ) {
79
            $isPopup = true;
80
        } else {
81
            $isPopup = false;
82
        }
83
84
         // bug50952 - must actually make sure we can log in, not just that we've got a EAPM record
85
         // getLoginInfo only checks to see if user has logged in correctly ONCE to ExternalAPI
86
         // Need to manually attempt to fetch the EAPM record, we don't want to give them the signup screen when they just have a deactivated account.
87
         $eapmBean = EAPM::getLoginInfo($apiName,true);
88
         $api = ExternalAPIFactory::loadAPI($apiName,true);
89
         $validSession = true;
90
91
         if(!empty($eapmBean))
92
         {
93
             try {
94
               $api->loadEAPM($eapmBean);
95
               // $api->checkLogin() does the same thing as quickCheckLogin plus actually makes sure the user CAN log in to the API currently
96
               $loginCheck = $api->checkLogin($eapmBean);
97
               if(isset($loginCheck['success']) && !$loginCheck['success'])
98
               {
99
                   $validSession = false;
100
               }
101
             } catch(Exception $ex) {
102
               $validSession = false;
103
               $GLOBALS['log']->error(string_format($mod_strings['ERR_INVALID_EXTERNAL_API_LOGIN'], array($apiName)));
104
             }
105
         }
106
107
         if (!$validSession || empty($eapmBean))
108
         {
109
             // Bug #49987 : Documents view.extdoc.php doesn't allow custom override
110
             $tpl_file = get_custom_file_if_exists('include/externalAPI/'.$apiName.'/'.$apiName.'Signup.'.$GLOBALS['current_language'].'.tpl');
111
112
             if (file_exists($tpl_file))
113
             {
114
                 $smarty = new Sugar_Smarty();
115
                 echo $smarty->fetch($tpl_file);
116
             } else  {
117
                 $output = string_format(translate('LBL_ERR_FAILED_QUICKCHECK','EAPM'), array($apiName));
118
                 $output .= '<form method="POST" target="_EAPM_CHECK" action="index.php">';
119
                 $output .= '<input type="hidden" name="module" value="EAPM">';
120
                 $output .= '<input type="hidden" name="action" value="Save">';
121
                 $output .= '<input type="hidden" name="record" value="'.$eapmBean->id.'">';
122
                 $output .= '<input type="hidden" name="active" value="1">';
123
                 $output .= '<input type="hidden" name="closeWhenDone" value="1">';
124
                 $output .= '<input type="hidden" name="refreshParentWindow" value="1">';
125
126
                 $output .= '<br><input type="submit" value="'.$GLOBALS['app_strings']['LBL_EMAIL_OK'].'">&nbsp;';
127
                 $output .= '<input type="button" onclick="lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" value="'.$GLOBALS['app_strings']['LBL_CANCEL_BUTTON_LABEL'].'">';
128
                 $output .= '</form>';
129
                 echo $output;
130
             }
131
132
             return;
133
         }
134
135
        $searchDataLower = $api->searchDoc($file_search,true);
0 ignored issues
show
The method searchDoc() does not seem to exist on object<ExternalAPIBase>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
136
137
        // In order to emulate the list views for the SugarFields, I need to uppercase all of the key names.
138
        $searchData = array();
139
140
        if ( is_array($searchDataLower) ) {
141
            foreach ( $searchDataLower as $row ) {
142
                $newRow = array();
143
                foreach ( $row as $key => $value ) {
144
                    $newRow[strtoupper($key)] = $value;
145
                }
146
                
147
                if ( $isPopup ) {
148
                    // We are running as a popup window, we need to replace the direct url with some javascript
149
                    $newRow['DOC_URL'] = "javascript:window.opener.SUGAR.field.file.populateFromPopup('".addslashes($_REQUEST['elemBaseName'])."','".addslashes($newRow['ID'])."','".addslashes($newRow['NAME'])."','".addslashes($newRow['URL'])."','".addslashes($newRow['URL'])."'); window.close();";
150
                }else{
151
                    $newRow['DOC_URL'] = $newRow['URL'];
152
                }
153
                $searchData[] = $newRow;
154
            }
155
        }
156
157
        $displayColumns = array(
158
            'NAME' => array(
159
                'label' => 'LBL_LIST_EXT_DOCUMENT_NAME',
160
                'type' => 'varchar',
161
                'link' => true,
162
                ),
163
            'DATE_MODIFIED' => array(
164
                'label' => 'LBL_DATE',
165
                'type' => 'date',
166
                ),
167
        );
168
169
        $ss = new Sugar_Smarty();
170
        $ss->assign('searchFieldLabel',translate('LBL_SEARCH_EXTERNAL_DOCUMENT','Documents'));
171
        $ss->assign('displayedNote',translate('LBL_EXTERNAL_DOCUMENT_NOTE','Documents'));
172
        $ss->assign('APP',$GLOBALS['app_strings']);
173
        $ss->assign('MOD',$GLOBALS['mod_strings']);
174
        $ss->assign('data', $searchData);
175
        $ss->assign('displayColumns',$displayColumns);
176
        $ss->assign('imgPath',SugarThemeRegistry::current()->getImageURL($apiName.'_image_inline.png'));
177
178
        if ( $isPopup ) { 
179
            $ss->assign('linkTarget','');
180
            $ss->assign('isPopup',1);
181
            $ss->assign('elemBaseName',$_REQUEST['elemBaseName']);
182
        } else {
183
            $ss->assign('linkTarget','_new');
184
            $ss->assign('isPopup',0);
185
            $ss->assign('elemBaseName','');
186
        }
187
        $ss->assign('apiName',$apiName);
188
        $ss->assign('DCSEARCH',$file_search);
189
190
        if ( $isPopup ) {
191
            // Need the popup header... I feel so dirty.
192
            ob_start();
193
            echo('<div class="dccontent">');
194
            insert_popup_header($GLOBALS['theme'], false);
195
            $output_html = ob_get_contents();
196
            ob_end_clean();
197
            
198
            $output_html .= get_form_header(translate('LBL_SEARCH_FORM_TITLE','Documents'), '', false);
199
            
200
            echo($output_html);
201
        }
202
203
        $ss->display('modules/Documents/tpls/view.extdoc.tpl');
204
        
205
        if ( $isPopup ) {
206
            // Close the dccontent div
207
            echo('</div>');
208
        }
209
 	}
210
}
211