Issues (81)

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/Feed.php (1 issue)

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
 * @author Joas Schilling <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2016, ownCloud, Inc.
6
 * @license AGPL-3.0
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
22
namespace OCA\Activity\Controller;
23
24
use OCA\Activity\Data;
25
use OCA\Activity\GroupHelper;
26
use OCA\Activity\PlainTextParser;
27
use OCA\Activity\UserSettings;
28
use OCP\Activity\IManager;
29
use OCP\AppFramework\Controller;
30
use OCP\AppFramework\Http\TemplateResponse;
31
use OCP\IConfig;
32
use OCP\IL10N;
33
use OCP\IRequest;
34
use OCP\IURLGenerator;
35
use OCP\L10N\IFactory;
36
use OCP\Util;
37
38
class Feed extends Controller {
39
	const DEFAULT_PAGE_SIZE = 30;
40
41
	/** @var \OCA\Activity\Data */
42
	protected $data;
43
44
	/** @var \OCA\Activity\GroupHelper */
45
	protected $helper;
46
47
	/** @var \OCA\Activity\UserSettings */
48
	protected $settings;
49
50
	/** @var IURLGenerator */
51
	protected $urlGenerator;
52
53
	/** @var IManager */
54
	protected $activityManager;
55
56
	/** @var IConfig */
57
	protected $config;
58
59
	/** @var IFactory */
60
	protected $l10nFactory;
61
62
	/** @var IL10N */
63
	protected $l;
64
65
	/** @var string */
66
	protected $user;
67
68
	/** @var string */
69
	protected $tokenUser;
70
71
	/**
72
	 * constructor of the controller
73
	 *
74
	 * @param string $appName
75
	 * @param IRequest $request
76
	 * @param Data $data
77
	 * @param GroupHelper $helper
78
	 * @param UserSettings $settings
79
	 * @param IURLGenerator $urlGenerator
80
	 * @param IManager $activityManager
81
	 * @param IFactory $l10nFactory
82
	 * @param IConfig $config
83
	 * @param string $user
84
	 */
85 5 View Code Duplication
	public function __construct($appName,
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
86
								IRequest $request,
87
								Data $data,
88
								GroupHelper $helper,
89
								UserSettings $settings,
90
								IURLGenerator $urlGenerator,
91
								IManager $activityManager,
92
								IFactory $l10nFactory,
93
								IConfig $config,
94
								$user) {
95 5
		parent::__construct($appName, $request);
96 5
		$this->data = $data;
97 5
		$this->helper = $helper;
98 5
		$this->settings = $settings;
99 5
		$this->urlGenerator = $urlGenerator;
100 5
		$this->activityManager = $activityManager;
101 5
		$this->l10nFactory = $l10nFactory;
102 5
		$this->config = $config;
103 5
		$this->user = $user;
104 5
	}
105
106
	/**
107
	 * @PublicPage
108
	 * @NoCSRFRequired
109
	 *
110
	 * @return TemplateResponse
111
	 */
112 4
	public function show() {
113
		try {
114 4
			$user = $this->activityManager->getCurrentUserId();
115
116 2
			$userLang = $this->config->getUserValue($user, 'core', 'lang');
117
118
			// Overwrite user and language in the helper
119 2
			$this->l = $this->l10nFactory->get('activity', $userLang);
120 2
			$parser = new PlainTextParser($this->l);
121 2
			$this->helper->setL10n($this->l);
122 2
			$this->helper->setUser($user);
123
124 2
			$description = (string) $this->l->t('Personal activity feed for %s', $user);
125 2
			$response = $this->data->get($this->helper, $this->settings, $user, 0, self::DEFAULT_PAGE_SIZE, 'desc', 'all');
126 2
			$data = $response['data'];
127
128 2
			$activities = [];
129 2
			foreach ($data as $activity) {
130
				$activity['subject_prepared'] = $parser->parseMessage($activity['subject_prepared']);
131
				$activity['message_prepared'] = $parser->parseMessage($activity['message_prepared']);
132 2
				$activities[] = $activity;
133
			}
134 2
		} catch (\UnexpectedValueException $e) {
135 2
			$this->l = $this->l10nFactory->get('activity');
136 2
			$description = (string) $this->l->t('Your feed URL is invalid');
137
138
			$activities = [
139
				[
140 2
					'activity_id'	=> -1,
141 2
					'timestamp'		=> \time(),
142
					'subject'		=> true,
143 2
					'subject_prepared'	=> $description,
144
				]
145
			];
146
		}
147
148 4
		$response = new TemplateResponse('activity', 'rss', [
149 4
			'rssLang'		=> $this->l->getLanguageCode(),
150 4
			'rssLink'		=> $this->urlGenerator->linkToRouteAbsolute('activity.Feed.show'),
151 4
			'rssPubDate'	=> \date('r'),
152 4
			'description'	=> $description,
153 4
			'activities'	=> $activities,
154 4
		], '');
155
156 4
		if ($this->request->getHeader('accept') !== null && \stristr($this->request->getHeader('accept'), 'application/rss+xml')) {
157 2
			$response->addHeader('Content-Type', 'application/rss+xml');
158
		} else {
159 2
			$response->addHeader('Content-Type', 'text/xml; charset=UTF-8');
160
		}
161
162 4
		return $response;
163
	}
164
}
165