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/Controller/CardApiController.php (5 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) 2018 Ryan Fletcher <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2019, Alexandru Puiu ([email protected])
6
 *
7
 * @author Ryan Fletcher <[email protected]>
8
 *
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 *  This program is free software: you can redistribute it and/or modify
12
 *  it under the terms of the GNU Affero General Public License as
13
 *  published by the Free Software Foundation, either version 3 of the
14
 *  License, or (at your option) any later version.
15
 *
16
 *  This program is distributed in the hope that it will be useful,
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 *  GNU Affero General Public License for more details.
20
 *
21
 *  You should have received a copy of the GNU Affero General Public License
22
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
 namespace OCA\Deck\Controller;
27
28
 use OCP\AppFramework\ApiController;
29
 use OCP\AppFramework\Http;
30
 use OCP\AppFramework\Http\DataResponse;
31
 use OCP\IRequest;
32
 use OCA\Deck\Service\CardService;
33
34
 /**
35
 * Class BoardApiController
36
 *
37
 * @package OCA\Deck\Controller
38
 */
39
class CardApiController extends ApiController {
40
	private $cardService;
41
	private $userId;
42
43
	/**
44
	 * @param string $appName
45
	 * @param IRequest $request
46
	 * @param CardService $cardService
47
	 * @param $userId
48
	 */
49
	public function __construct($appName, IRequest $request, CardService $cardService, $userId) {
50
		parent::__construct($appName, $request);
51
		$this->cardService = $cardService;
52
		$this->userId = $userId;
53
	}
54
55
	/**
56
	 * @NoAdminRequired
57
	 * @CORS
58
	 * @NoCSRFRequired
59
	 *
60
	 * Get a specific card.
61
	 */
62
	public function get() {
63
		$card = $this->cardService->find($this->request->getParam('cardId'));
64
		return new DataResponse($card, HTTP::STATUS_OK);
65
	}
66
67
	/**
68
	 * @NoAdminRequired
69
	 * @CORS
70
	 * @NoCSRFRequired
71
	 *
72
	 * @params $title
73
	 * @params $type
74
	 * @params $order
75
	 * @params $description
76
	 *
77
	 * Get a specific card.
78
	 */
79
	public function create($title, $type = 'plain', $order = 999, $description = '') {
80
		$card = $this->cardService->create($title, $this->request->getParam('stackId'), $type, $order, $this->userId, $description);
81
		return new DataResponse($card, HTTP::STATUS_OK);
82
	}
83
84
	/**
85
	 * @NoAdminRequired
86
	 * @CORS
87
	 * @NoCSRFRequired
88
	 *
89
	 *
90
	 * Update a card
91
	 */
92
	public function update($title, $type, $order = 0, $description = '', $owner, $duedate = null, $archived = null) {
93
		$card = $this->cardService->update($this->request->getParam('cardId'), $title, $this->request->getParam('stackId'), $type, $order, $description, $owner, $duedate, 0, $archived);
94
		return new DataResponse($card, HTTP::STATUS_OK);
95
	}
96
97
	/**
98
	 * @NoAdminRequired
99
	 * @CORS
100
	 * @NoCSRFRequired
101
	 *
102
	 * Delete a specific card.
103
	 */
104
	public function delete() {
105
		$card = $this->cardService->delete($this->request->getParam('cardId'));
106
		return new DataResponse($card, HTTP::STATUS_OK);
107
	}
108
109
	/**
110
	 * @NoAdminRequired
111
	 * @CORS
112
	 * @NoCSRFRequired
113
	 *
114
	 * Assign a label to a card.
115
	 */
116
	public function assignLabel($labelId) {
117
		$card = $this->cardService->assignLabel($this->request->getParam('cardId'), $labelId);
0 ignored issues
show
Are you sure the assignment to $card is correct as $this->cardService->assi...am('cardId'), $labelId) (which targets OCA\Deck\Service\CardService::assignLabel()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
118
		return new DataResponse($card, HTTP::STATUS_OK);
0 ignored issues
show
$card is of type null, but the function expects a array|object.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
119
	}
120
121
	/**
122
	 * @NoAdminRequired
123
	 * @CORS
124
	 * @NoCSRFRequired
125
	 *
126
	 * Assign a label to a card.
127
	 */
128
	public function removeLabel($labelId) {
129
		$card = $this->cardService->removeLabel($this->request->getParam('cardId'), $labelId);
0 ignored issues
show
Are you sure the assignment to $card is correct as $this->cardService->remo...am('cardId'), $labelId) (which targets OCA\Deck\Service\CardService::removeLabel()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
130
		return new DataResponse($card, HTTP::STATUS_OK);
0 ignored issues
show
$card is of type null, but the function expects a array|object.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
131
	}
132
133
	/**
134
	 * @NoAdminRequired
135
	 * @CORS
136
	 * @NoCSRFRequired
137
	 *
138
	 * Unassign a user from a card
139
	 */
140
	public function unassignUser($userId) {
141
		$card = $this->cardService->unassignUser($this->request->getParam('cardId'), $userId);
142
		return new DataResponse($card, HTTP::STATUS_OK);
143
	}
144
145
	/**
146
	 * @NoAdminRequired
147
	 * @CORS
148
	 * @NoCSRFRequired
149
	 *
150
	 * Assign a user to a card
151
	 */
152
	public function assignUser($userId) {
153
		$card = $this->cardService->assignUser($this->request->getParam('cardId'), $userId);;
154
		return new DataResponse($card, HTTP::STATUS_OK);
0 ignored issues
show
It seems like $card defined by $this->cardService->assi...ram('cardId'), $userId) on line 153 can be null; however, OCP\AppFramework\Http\DataResponse::__construct() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
155
	}
156
157
	/**
158
	 * @NoAdminRequired
159
	 * @CORS
160
	 * @NoCSRFRequired
161
	 *
162
	 * Reorder cards
163
	 */
164
	public function reorder($stackId, $order) {
165
		$card = $this->cardService->reorder($this->request->getParam('cardId'), $stackId, $order);
166
		return new DataResponse($card, HTTP::STATUS_OK);
167
	}
168
}
169