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/Collaboration/Resources/ResourceProvider.php (2 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
 * @copyright Copyright (c) 2019 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\Collaboration\Resources;
25
26
27
use OCA\Deck\Db\Acl;
28
use OCA\Deck\Db\Board;
29
use OCA\Deck\Db\BoardMapper;
30
use OCA\Deck\Service\PermissionService;
31
use OCP\AppFramework\Db\DoesNotExistException;
32
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
33
use OCP\AppFramework\QueryException;
34
use OCP\Collaboration\Resources\IManager;
35
use OCP\Collaboration\Resources\IProvider;
36
use OCP\Collaboration\Resources\IResource;
37
use OCP\Collaboration\Resources\ResourceException;
38
use OCP\IUser;
39
40
class ResourceProvider implements IProvider {
41
42
	const RESOURCE_TYPE = 'deck';
43
44
	private $boardMapper;
45
	private $permissionService;
46
47
	/** @var array */
48
	protected $nodes = [];
49
50
	public function __construct(BoardMapper $boardMapper, PermissionService $permissionService) {
51
		$this->boardMapper = $boardMapper;
52
		$this->permissionService = $permissionService;
53
	}
54
55
	/**
56
	 * Get the type of a resource
57
	 *
58
	 * @param IResource $resource
0 ignored issues
show
There is no parameter named $resource. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
59
	 * @return string
60
	 * @since 15.0.0
61
	 */
62
	public function getType(): string {
63
		return self::RESOURCE_TYPE;
64
	}
65
66
	/**
67
	 * Get the rich object data of a resource
68
	 *
69
	 * @param IResource $resource
70
	 * @return array
71
	 * @throws \OCP\AppFramework\Db\DoesNotExistException
72
	 * @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException
73
	 * @since 16.0.0
74
	 */
75
	public function getResourceRichObject(IResource $resource): array {
76
		$board = $this->getBoard($resource);
77
		$link = \OC::$server->getURLGenerator()->linkToRoute('deck.page.index') . '#!/board/' . $resource->getId();
78
79
		return [
80
			'type' => self::RESOURCE_TYPE,
81
			'id' => $resource->getId(),
82
			'name' => $board->getTitle(),
83
			'link' => $link,
84
			'iconUrl' => \OC::$server->getURLGenerator()->imagePath('deck', 'deck-dark.svg')
85
		];
86
87
	}
88
89
	/**
90
	 * Can a user/guest access the collection
91
	 *
92
	 * @param IResource $resource
93
	 * @param IUser|null $user
94
	 * @return bool
95
	 * @since 16.0.0
96
	 */
97
	public function canAccessResource(IResource $resource, ?IUser $user): bool {
98
		if ($resource->getType() !== self::RESOURCE_TYPE || !$user instanceof IUser) {
99
			return false;
100
		}
101
		$board = $this->getBoard($resource);
102
		if ($board === null) {
103
			return false;
104
		}
105
		if ($board->getOwner() === $user->getUID()) {
106
			return true;
107
		}
108
		return $this->permissionService->userCan($board->getAcl(), Acl::PERMISSION_READ, $user->getUID());
109
	}
110
111
	private function getBoard(IResource $resource) {
112
		try {
113
			return $this->boardMapper->find($resource->getId(), false, true);
114
		} catch (DoesNotExistException $e) {
115
		} catch (MultipleObjectsReturnedException $e) {
116
			return null;
117
		}
118
	}
119
120
	public function invalidateAccessCache($boardId = null) {
121
		try {
122
			/** @var IManager $resourceManager */
123
			$resourceManager = \OC::$server->query(IManager::class);
124
		} catch (QueryException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
125
		}
126
		if ($boardId !== null) {
127
			$resource = $resourceManager->getResourceForUser(self::RESOURCE_TYPE, (string)$boardId, null);
128
			$resourceManager->invalidateAccessCacheForResource($resource);
129
		} else {
130
			$resourceManager->invalidateAccessCacheForProvider($this);
131
		}
132
	}
133
}
134