Issues (10)

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/Service/SettingsService.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
/**
3
 * Nextcloud - Tasks
4
 *
5
 * @author Raimund Schlüßler
6
 * @copyright 2018 Raimund Schlüßler <[email protected]>
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
10
 * License as published by the Free Software Foundation; either
11
 * version 3 of the License, or any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public
19
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
23
namespace OCA\Tasks\Service;
24
25
use OCP\App\IAppManager;
26
use OCP\IConfig;
27
28
class SettingsService {
29
30
	/**
31
	 * @var ?string
32
	 */
33
	private $userId;
34
35
	/**
36
	 * @var IConfig
37
	 */
38
	private $config;
39
40
	/**
41
	 * @var string
42
	 */
43
	private $appName;
44
45
	/**
46
	 * @var IAppManager
47
	 */
48
	private $appManager;
49
50
	/**
51
	 * @param string $userId
52
	 * @param IConfig $settings
0 ignored issues
show
There is no parameter named $settings. 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...
53
	 * @param string $appName
54
	 */
55
	public function __construct(?string $userId, IConfig $config, string $appName, IAppManager $appManager) {
56
		$this->userId = $userId;
57
		$this->config = $config;
58
		$this->appName = $appName;
59
		$this->appManager = $appManager;
60
	}
61
62
	/**
63
	 * Get the current settings
64
	 *
65
	 * @return array
66
	 */
67
	public function get():array {
68
		$defaultCalendarId = (string)$this->config->getUserValue($this->userId, $this->appName, 'various_defaultCalendarId');
69
		$showHidden = (bool)$this->config->getUserValue($this->userId, $this->appName, 'various_showHidden', false);
70
		$sortOrder = (string)$this->config->getUserValue($this->userId, $this->appName, 'various_sortOrder', 'default');
71
		$sortDirection = (bool)$this->config->getUserValue($this->userId, $this->appName, 'various_sortDirection', false);
72
		$allDay = (bool)$this->config->getUserValue($this->userId, $this->appName, 'various_allDay', false);
73
		$initialRoute = (string)$this->config->getUserValue($this->userId, $this->appName, 'various_initialRoute', '/collections/all');
74
75
		$calendarEnabled = $this->appManager->isEnabledForUser('calendar');
76
		$defaultInitialView = $this->config->getAppValue('calendar', 'currentView', 'dayGridMonth');
77
		$calendarView = $this->getView($this->config->getUserValue($this->userId, 'calendar', 'currentView', $defaultInitialView));
78
		$defaultShowTasks = $this->config->getAppValue('calendar', 'showTasks', 'yes');
79
		$showTasks = $this->config->getUserValue($this->userId, 'calendar', 'showTasks', $defaultShowTasks) === 'yes';
80
81
		return [
82
			'defaultCalendarId' => $defaultCalendarId,
83
			'showHidden' => $showHidden,
84
			'sortOrder' => $sortOrder,
85
			'sortDirection' => $sortDirection,
86
			'allDay' => $allDay,
87
			'initialRoute' => $initialRoute,
88
			'calendarEnabled' => $calendarEnabled,
89
			'showTasks' => $showTasks,
90
			'calendarView' => $calendarView
91
		];
92
	}
93
94
	/**
95
	 * Set setting of type to new value
96
	 *
97
	 * @param $setting
98
	 * @param $value
99
	 * @return bool
100
	 */
101
	public function set($setting, $value):bool {
102
		$this->config->setUserValue($this->userId, $this->appName, 'various_'.$setting, $value);
103
		return true;
104
	}
105
106
	/**
107
	 * Makes sure we don't use the old views anymore
108
	 *
109
	 * @param string $view
110
	 * @return string
111
	 */
112
	private function getView(string $view): string {
113
		switch ($view) {
114
			case 'agendaDay':
115
				return 'timeGridDay';
116
117
			case 'agendaWeek':
118
				return 'timeGridWeek';
119
120
			case 'month':
121
				return 'dayGridMonth';
122
123
			default:
124
				return $view;
125
		}
126
	}
127
}
128