Issues (159)

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/BackgroundJob/RemoteActivity.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) 2017 Joas Schilling <[email protected]>
4
 *
5
 * @license GNU AGPL version 3 or any later version
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as
9
 * published by the Free Software Foundation, either version 3 of the
10
 * License, or (at your option) any later version.
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
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 */
21
22
namespace OCA\Activity\BackgroundJob;
23
24
use GuzzleHttp\Exception\ClientException;
25
use OC\BackgroundJob\QueuedJob;
26
use OCA\Activity\Extension\Files;
27
use OCP\Federation\ICloudId;
28
use OCP\Federation\ICloudIdManager;
29
use OCP\Http\Client\IClientService;
30
31
class RemoteActivity extends QueuedJob {
32
33
	/** @var IClientService */
34
	protected $clientService;
35
36
	/** @var ICloudIdManager */
37
	protected $cloudIdManager;
38
39
	public function __construct(IClientService $clientService, ICloudIdManager $cloudIdManager) {
40
		$this->clientService = $clientService;
41
		$this->cloudIdManager = $cloudIdManager;
42
	}
43
44
	protected function run($arguments) {
45
		call_user_func_array([$this, 'sendActivity'], $arguments);
46
	}
47
48
	protected function sendActivity($target, $token, $path, $internalType, $time, $actor, $secondPath = '') {
49
		$client = $this->clientService->newClient();
50
51
		$cloudId = $this->cloudIdManager->resolveCloudId($target);
52
		$type = $this->translateType($internalType, $secondPath);
53
54
		$fields = [
55
			'@context' => 'https://www.w3.org/ns/activitystreams',
56
			'to' => [
57
				'type' => 'Person',
58
				'name' => $cloudId->getUser(),
59
			],
60
			'actor' => [
61
				'type' => 'Person',
62
				'name' => $actor,
63
			],
64
			'type' => $type,
65
			'updated' => date(\DateTime::W3C, $time),
66
		];
67
68
		if ($type === 'Move') {
69
			$fields['target'] = [
70
				'type' => 'Document',
71
				'name' => $path,
72
			];
73
			$fields['origin'] = [
74
				'type' => 'Document',
75
				'name' => $secondPath,
76
			];
77
		} else {
78
			$fields['object'] = [
79
				'type' => 'Document',
80
				'name' => $path,
81
			];
82
		}
83
84
		try {
85
			$client->post(
86
				$this->getServerURL($cloudId, $token), [
87
					'body' => $fields,
88
					'timeout' => 10,
89
					'connect_timeout' => 10,
90
				]
91
			);
92
		} catch (ClientException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
The class GuzzleHttp\Exception\ClientException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
93
		}
94
	}
95
96
	/**
97
	 * @param ICloudId $cloudId
98
	 * @param string $token
99
	 * @return string
100
	 */
101
	protected function getServerURL(ICloudId $cloudId, $token) {
102
		$remote = $cloudId->getRemote();
103
		if (strpos($remote, 'http') !== 0) {
104
			$remote = 'https://' . $remote;
105
		}
106
107
		return rtrim($remote, '/') . '/ocs/v2.php/apps/activity/api/v2/remote/' . $token;
108
	}
109
110
	/**
111
	 * @param string $internalType
112
	 * @param string $secondPath
113
	 * @return string
114
	 */
115
	protected function translateType($internalType, $secondPath) {
116
		switch ($internalType) {
117
			case Files::TYPE_SHARE_CREATED:
118
			case Files::TYPE_SHARE_RESTORED:
119
				return 'Create';
120
			case Files::TYPE_SHARE_CHANGED:
121
				if ($secondPath !== '') {
122
					return 'Move';
123
				}
124
				return 'Update';
125
			case Files::TYPE_SHARE_DELETED:
126
				return 'Delete';
127
		}
128
		return '';
129
	}
130
}
131