Issues (221)

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/AppInfo/Application.php (2 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
 * @copyright Copyright (c) 2016 Julius Härtl <[email protected]>
4
 *
5
 * @author Julius Härtl <[email protected]>
6
 *
7
 * @license GNU AGPL version 3 or any later version
8
 *
9
 *  This program is free software: you can redistribute it and/or modify
10
 *  it under the terms of the GNU Affero General Public License as
11
 *  published by the Free Software Foundation, either version 3 of the
12
 *  License, or (at your option) any later version.
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
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
namespace OCA\Deck\AppInfo;
25
26
use Exception;
27
use InvalidArgumentException;
28
use OC_Util;
29
use OCA\Deck\Activity\CommentEventHandler;
30
use OCA\Deck\Capabilities;
31
use OCA\Deck\Collaboration\Resources\ResourceProvider;
32
use OCA\Deck\Collaboration\Resources\ResourceProviderCard;
33
use OCA\Deck\Db\Acl;
34
use OCA\Deck\Db\AclMapper;
35
use OCA\Deck\Db\AssignedUsersMapper;
36
use OCA\Deck\Db\CardMapper;
37
use OCA\Deck\Middleware\DefaultBoardMiddleware;
38
use OCA\Deck\Middleware\ExceptionMiddleware;
39
use OCA\Deck\Notification\Notifier;
40
use OCA\Deck\Service\FullTextSearchService;
41
use OCA\Deck\Service\PermissionService;
42
use OCP\AppFramework\App;
43
use OCP\Collaboration\Resources\IManager;
44
use OCP\Collaboration\Resources\IProviderManager;
45
use OCP\Comments\CommentsEntityEvent;
46
use OCP\FullTextSearch\IFullTextSearchManager;
47
use OCP\IGroup;
48
use OCP\IServerContainer;
49
use OCP\IUser;
50
use OCP\IUserManager;
51
use OCP\IURLGenerator;
52
use OCP\Util;
53
use Symfony\Component\EventDispatcher\GenericEvent;
54
55
class Application extends App {
56
57
	public const APP_ID = 'deck';
58
59
	/** @var IServerContainer */
60
	private $server;
61
62
	/** @var FullTextSearchService */
63
	private $fullTextSearchService;
64
65
	/** @var IFullTextSearchManager */
66
	private $fullTextSearchManager;
67
68
	public function __construct(array $urlParams = array()) {
69
		parent::__construct('deck', $urlParams);
70
71
		$container = $this->getContainer();
72
		$server = $this->getContainer()->getServer();
73
74
		$this->server = $server;
75
76
		$container->registerCapability(Capabilities::class);
77
		$container->registerMiddleWare(ExceptionMiddleware::class);
78
		$container->registerMiddleWare(DefaultBoardMiddleware::class);
79
80
		$container->registerService('databaseType', static function() use ($server) {
81
			return $server->getConfig()->getSystemValue('dbtype', 'sqlite');
82
		});
83
		$container->registerService('database4ByteSupport', static function() use ($server) {
84
			return $server->getDatabaseConnection()->supports4ByteText();
85
		});
86
	}
87
88
	public function register(): void {
89
		$this->registerNavigationEntry();
90
		$this->registerUserGroupHooks();
91
		$this->registerNotifications();
92
		$this->registerCommentsEntity();
93
		$this->registerFullTextSearch();
94
		$this->registerCollaborationResources();
95
	}
96
97
	public function registerNavigationEntry(): void {
98
		$container = $this->getContainer();
99
		$this->server->getNavigationManager()->add(static function() use ($container) {
100
			$urlGenerator = $container->query(IURLGenerator::class);
101
			return [
102
				'id' => 'deck',
103
				'order' => 10,
104
				'href' => $urlGenerator->linkToRoute('deck.page.index'),
105
				'icon' => $urlGenerator->imagePath('deck', 'deck.svg'),
106
				'name' => 'Deck',
107
			];
108
		});
109
	}
110
111
	private function registerUserGroupHooks(): void {
112
		$container = $this->getContainer();
113
		// Delete user/group acl entries when they get deleted
114
		/** @var IUserManager $userManager */
115
		$userManager = $this->server->getUserManager();
116
		$userManager->listen('\OC\User', 'postDelete', static function(IUser $user) use ($container) {
0 ignored issues
show
The method listen() does not seem to exist on object<OCP\IUserManager>.

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...
117
			// delete existing acl entries for deleted user
118
			/** @var AclMapper $aclMapper */
119
			$aclMapper = $container->query(AclMapper::class);
120
			$acls = $aclMapper->findByParticipant(Acl::PERMISSION_TYPE_USER, $user->getUID());
121
			foreach ($acls as $acl) {
122
				$aclMapper->delete($acl);
123
			}
124
			// delete existing user assignments
125
			$assignmentMapper = $container->query(AssignedUsersMapper::class);
126
			$assignments = $assignmentMapper->findByUserId($user->getUID());
127
			foreach ($assignments as $assignment) {
128
				$assignmentMapper->delete($assignment);
129
			}
130
		});
131
132
		/** @var IUserManager $userManager */
133
		$groupManager = $this->server->getGroupManager();
134
		$groupManager->listen('\OC\Group', 'postDelete', static function(IGroup $group) use ($container) {
0 ignored issues
show
The method listen() does not seem to exist on object<OCP\IGroupManager>.

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...
135
			/** @var AclMapper $aclMapper */
136
			$aclMapper = $container->query(AclMapper::class);
137
			$aclMapper->findByParticipant(Acl::PERMISSION_TYPE_GROUP, $group->getGID());
138
			$acls = $aclMapper->findByParticipant(Acl::PERMISSION_TYPE_GROUP, $group->getGID());
139
			foreach ($acls as $acl) {
140
				$aclMapper->delete($acl);
141
			}
142
		});
143
	}
144
145
	public function registerNotifications(): void {
146
		$notificationManager = $this->server->getNotificationManager();
147
		$notificationManager->registerNotifierService(Notifier::class);
148
	}
149
150
	public function registerCommentsEntity(): void {
151
		$this->server->getEventDispatcher()->addListener(CommentsEntityEvent::EVENT_ENTITY, function(CommentsEntityEvent $event) {
152
			$event->addEntityCollection('deckCard', function($name) {
153
				/** @var CardMapper */
154
				$cardMapper = $this->getContainer()->query(CardMapper::class);
155
				$permissionService = $this->getContainer()->query(PermissionService::class);
156
157
				try {
158
					return $permissionService->checkPermission($cardMapper, (int) $name, Acl::PERMISSION_READ);
159
				} catch (\Exception $e) {
160
					return false;
161
				}
162
			});
163
		});
164
		$this->registerCommentsEventHandler();
165
	}
166
167
	/**
168
	 */
169
	protected function registerCommentsEventHandler(): void {
170
		$this->server->getCommentsManager()->registerEventHandler(function () {
171
			return $this->getContainer()->query(CommentEventHandler::class);
172
		});
173
	}
174
175
	protected function registerCollaborationResources(): void {
176
		$version = OC_Util::getVersion()[0];
177
		if ($version < 16) {
178
			return;
179
		}
180
181
		/**
182
		 * Register Collaboration ResourceProvider
183
		 *
184
		 * @Todo: Remove if min-version is 18
185
		 */
186
		if ($version < 18) {
187
			/** @var IManager $resourceManager */
188
			$resourceManager = $this->getContainer()->query(IManager::class);
189
		} else {
190
			/** @var IProviderManager $resourceManager */
191
			$resourceManager = $this->getContainer()->query(IProviderManager::class);
192
		}
193
		$resourceManager->registerResourceProvider(ResourceProvider::class);
194
		$resourceManager->registerResourceProvider(ResourceProviderCard::class);
195
196
		$this->server->getEventDispatcher()->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', static function () {
197
			Util::addScript('deck', 'collections');
198
		});
199
	}
200
201
	public function registerFullTextSearch(): void {
202
		if (Util::getVersion()[0] < 16) {
203
			return;
204
		}
205
206
		$c = $this->getContainer();
207
		try {
208
			$this->fullTextSearchService = $c->query(FullTextSearchService::class);
209
			$this->fullTextSearchManager = $c->query(IFullTextSearchManager::class);
210
		} catch (Exception $e) {
211
			return;
212
		}
213
214
		if (!$this->fullTextSearchManager->isAvailable()) {
215
			return;
216
		}
217
218
		$eventDispatcher = $this->server->getEventDispatcher();
219
		$eventDispatcher->addListener(
220
			'\OCA\Deck\Card::onCreate', function(GenericEvent $e) {
221
			$this->fullTextSearchService->onCardCreated($e);
222
		}
223
		);
224
		$eventDispatcher->addListener(
225
			'\OCA\Deck\Card::onUpdate', function(GenericEvent $e) {
226
			$this->fullTextSearchService->onCardUpdated($e);
227
		}
228
		);
229
		$eventDispatcher->addListener(
230
			'\OCA\Deck\Card::onDelete', function(GenericEvent $e) {
231
			$this->fullTextSearchService->onCardDeleted($e);
232
		}
233
		);
234
		$eventDispatcher->addListener(
235
			'\OCA\Deck\Board::onShareNew', function(GenericEvent $e) {
236
			$this->fullTextSearchService->onBoardShares($e);
237
		}
238
		);
239
		$eventDispatcher->addListener(
240
			'\OCA\Deck\Board::onShareEdit', function(GenericEvent $e) {
241
			$this->fullTextSearchService->onBoardShares($e);
242
		}
243
		);
244
		$eventDispatcher->addListener(
245
			'\OCA\Deck\Board::onShareDelete', function(GenericEvent $e) {
246
			$this->fullTextSearchService->onBoardShares($e);
247
		}
248
		);
249
	}
250
251
}
252