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/ViewInfoCache.php (2 issues)

Languages
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
 * @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;
23
24
use OC\Files\View;
25
use OCP\Files\NotFoundException;
26
27
class ViewInfoCache {
28
29
	/** @var array */
30
	protected $cachePath;
31
	/** @var array */
32
	protected $cacheId;
33
34
	/** @var \OC\Files\View */
35
	protected $view;
36
37
	/**
38
	 * @param View $view
39
	 */
40 28
	public function __construct(View $view) {
41 28
		$this->view = $view;
42 28
	}
43
44
	/**
45
	 * @param string $user
46
	 * @param string $path
47
	 * @return array
48
	 */
49 8
	public function getInfoByPath($user, $path) {
50 8
		if (isset($this->cachePath[$user][$path])) {
51 2
			return $this->cachePath[$user][$path];
52
		}
53
54 7
		return $this->findInfoByPath($user, $path);
55
	}
56
57
	/**
58
	 * @param string $user
59
	 * @param int $fileId
60
	 * @param string $path
61
	 * @return array
62
	 */
63 5
	public function getInfoById($user, $fileId, $path) {
64 5
		if (isset($this->cacheId[$user][$fileId])) {
65 2
			$cache = $this->cacheId[$user][$fileId];
66 2
			if ($cache['path'] === null) {
67 1
				$cache['path'] = $path;
68
			}
69 2
			return $cache;
70
		}
71
72 3
		return $this->findInfoById($user, $fileId, $path);
73
	}
74
75
	/**
76
	 * @param string $user
77
	 * @param string $path
78
	 * @return array
79
	 */
80 7
	protected function findInfoByPath($user, $path) {
81 7
		$this->view->chroot('/' . $user . '/files');
82
83 7
		$exists = $this->view->file_exists($path);
84
85 7
		$this->cachePath[$user][$path] = [
86 7
			'path'		=> $path,
87 7
			'exists'	=> $exists,
88 7
			'is_dir'	=> $exists ? $this->view->is_dir($path) : false,
89 7
			'view'		=> '',
90
		];
91
92 7
		return $this->cachePath[$user][$path];
93
	}
94
95
	/**
96
	 * @param string $user
97
	 * @param int $fileId
98
	 * @param string $filePath
99
	 * @return array
100
	 */
101 5
	protected function findInfoById($user, $fileId, $filePath) {
102 5
		$this->view->chroot('/' . $user . '/files');
103
104
		$cache = [
105 5
			'path'		=> $filePath,
106
			'exists'	=> false,
107
			'is_dir'	=> false,
108 5
			'view'		=> '',
109
		];
110
111 5
		$notFound = false;
112
		try {
113 5
			$path = $this->view->getPath($fileId);
114
115 2
			$cache['path'] = $path;
116 2
			$cache['is_dir'] = $this->view->is_dir($path);
117 2
			$cache['exists'] = true;
118 3
		} catch (NotFoundException $e) {
0 ignored issues
show
The class OCP\Files\NotFoundException 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...
119
			// The file was not found in the normal view, maybe it is in
120
			// the trashbin?
121 3
			$this->view->chroot('/' . $user . '/files_trashbin');
122
123
			try {
124 3
				$path = $this->view->getPath($fileId);
125
126
				$cache = [
127 2
					'path'		=> \substr($path, \strlen('/files')),
128
					'exists'	=> true,
129 2
					'is_dir'	=> $this->view->is_dir($path),
130 2
					'view'		=> 'trashbin',
131
				];
132 1
			} catch (NotFoundException $e) {
0 ignored issues
show
The class OCP\Files\NotFoundException 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...
133 1
				$notFound = true;
134
			}
135
		}
136
137 5
		$this->cacheId[$user][$fileId] = $cache;
138 5
		if ($notFound) {
139 1
			$this->cacheId[$user][$fileId]['path'] = null;
140
		}
141
142 5
		return $cache;
143
	}
144
}
145