Issues (78)

Security Analysis    no request data  

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.

lib/controller/folderscontroller.php (5 issues)

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
3
/**
4
 * @author Christoph Wurst <[email protected]>
5
 * @author Thomas Imbreckx <[email protected]>
6
 * @author Thomas Müller <[email protected]>
7
 *
8
 * Mail
9
 *
10
 * This code is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License, version 3,
12
 * as published by the Free Software Foundation.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License, version 3,
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
21
 *
22
 */
23
24
namespace OCA\Mail\Controller;
25
26
use OCP\IRequest;
27
use OCA\Mail\Service\AccountService;
28
use OCP\AppFramework\Controller;
29
use OCP\AppFramework\Db\DoesNotExistException;
30
use OCP\AppFramework\Http\JSONResponse;
31
use OCP\AppFramework\Http;
32
33
class FoldersController extends Controller {
34
35
	/** @var AccountService */
36
	private $accountService;
37
38
	/**
39
	 * @var string
40
	 */
41
	private $currentUserId;
42
43
	/**
44
	 * @param string $appName
45
	 * @param IRequest $request
46
	 * @param AccountService $accountService
47
	 * @param $UserId
48
	 */
49 11
	public function __construct($appName, IRequest $request, AccountService $accountService, $UserId) {
50 11
		parent::__construct($appName, $request);
51 11
		$this->accountService = $accountService;
52 11
		$this->currentUserId = $UserId;
53 11
	}
54
55
	/**
56
	 * @NoAdminRequired
57
	 * @NoCSRFRequired
58
	 * @param int $accountId
59
	 */
60 2
	public function index($accountId) {
61 2
		$account = $this->accountService->find($this->currentUserId, $accountId);
62 2
		$json = $account->getListArray();
63
64 2
		$folders = array_filter($json['folders'], function($folder){
65 1
			return is_null($folder['parent']);
66 2
		});
67 2
		foreach($json['folders'] as $folder) {
68 1
			if (is_null($folder['parent'])) {
69 1
				continue;
70
			}
71
			$parentId = $folder['parent'];
72
			foreach($folders as &$parent) {
73
				if($parent['id'] === $parentId) {
74
					if (!isset($parent['folders'])) {
75
						$parent['folders'] = [];
76
					}
77
					$parent['folders'][] = $folder;
78
					break;
79
				}
80
			}
81 2
		}
82
83 2
		$json['folders'] = array_values($folders);
84 2
		return new JSONResponse($json);
85
	}
86
87
	/**
88
	 * @NoAdminRequired
89
	 * @NoCSRFRequired
90
	 */
91 1
	public function show() {
92 1
		$response = new JSONResponse();
93 1
		$response->setStatus(Http::STATUS_NOT_IMPLEMENTED);
94 1
		return $response;
95
	}
96
97
	/**
98
	 * @NoAdminRequired
99
	 */
100 1
	public function update() {
101 1
		$response = new JSONResponse();
102 1
		$response->setStatus(Http::STATUS_NOT_IMPLEMENTED);
103 1
		return $response;
104
	}
105
106
	/**
107
	 * @NoAdminRequired
108
	 * @param int $accountId
109
	 * @param string $folderId
110
	 * @return JSONResponse
111
	 */
112 2
	public function destroy($accountId, $folderId) {
113
		try {
114 2
			$account = $this->accountService->find($this->currentUserId, $accountId);
115 1
			$imap = $account->getImapConnection();
116 1
			$imap->deleteMailbox($folderId);
117
118 1
			return new JSONResponse();
119 1
		} catch (DoesNotExistException $e) {
0 ignored issues
show
The class OCP\AppFramework\Db\DoesNotExistException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
120 1
			return new JSONResponse(null, 404);
121
		}
122
	}
123
124
	/**
125
	 * @NoAdminRequired
126
	 * @param int $accountId
127
	 * @param string $mailbox
128
	 */
129 2
	public function create($accountId, $mailbox) {
130
		try {
131 2
			$account = $this->accountService->find($this->currentUserId, $accountId);
132 2
			$imap = $account->getImapConnection();
133
134
			// TODO: read http://tools.ietf.org/html/rfc6154
135 2
			$imap->createMailbox($mailbox);
136
137 1
			return new JSONResponse([
138
				'data' => [
139
					'id' => $mailbox
140 1
				]
141 1
				], Http::STATUS_CREATED);
142 1
		} catch (\Horde_Imap_Client_Exception $e) {
0 ignored issues
show
The class Horde_Imap_Client_Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
143 1
			$response = new JSONResponse();
144 1
			$response->setStatus(Http::STATUS_INTERNAL_SERVER_ERROR);
145 1
			return $response;
146
		} catch (DoesNotExistException $e) {
0 ignored issues
show
The class OCP\AppFramework\Db\DoesNotExistException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
147
			return new JSONResponse();
148
		}
149
	}
150
151
	/**
152
	 * @NoAdminRequired
153
	 * @param $accountId
154
	 * @param $folders
155
	 * @return JSONResponse
156
	 */
157
	public function detectChanges($accountId, $folders) {
158
		try {
159
			$query = [];
160
			foreach($folders as $folder) {
161
				$folderId = base64_decode($folder['id']);
162
				$parts = explode('/', $folderId);
163
				if (count($parts) > 1 && $parts[1] === 'FLAGGED') {
164
					continue;
165
				}
166
				if (isset($folder['error'])) {
167
					continue;
168
				}
169
				$query[$folderId] = $folder;
170
			}
171
			$account = $this->accountService->find($this->currentUserId, $accountId);
172
			$mailBoxes = $account->getChangedMailboxes($query);
173
174
			return new JSONResponse($mailBoxes);
175
		} catch (\Horde_Imap_Client_Exception $e) {
0 ignored issues
show
The class Horde_Imap_Client_Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
176
			$response = new JSONResponse();
177
			$response->setStatus(Http::STATUS_INTERNAL_SERVER_ERROR);
178
			return $response;
179
		} catch (DoesNotExistException $e) {
0 ignored issues
show
The class OCP\AppFramework\Db\DoesNotExistException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
180
			return new JSONResponse();
181
		}
182
	}
183
}
184