Issues (61)

Security Analysis    not enabled

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.

controller/filescontroller.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
 * ownCloud - galleryplus
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Olivier Paroz <[email protected]>
9
 *
10
 * @copyright Olivier Paroz 2016
11
 */
12
13
namespace OCA\GalleryPlus\Controller;
14
15
use OCP\IRequest;
16
use OCP\IURLGenerator;
17
use OCP\ILogger;
18
19
use OCP\AppFramework\Controller;
20
use OCP\AppFramework\Http;
21
use OCP\AppFramework\Http\RedirectResponse;
22
23
use OCA\GalleryPlus\Http\ImageResponse;
24
use OCA\GalleryPlus\Service\SearchFolderService;
25
use OCA\GalleryPlus\Service\ConfigService;
26
use OCA\GalleryPlus\Service\SearchMediaService;
27
use OCA\GalleryPlus\Service\DownloadService;
28
use OCA\GalleryPlus\Service\ServiceException;
29
30
/**
31
 * Class FilesController
32
 *
33
 * @package OCA\GalleryPlus\Controller
34
 */
35
class FilesController extends Controller {
36
37
	use Files;
38
	use HttpError;
39
40
	/** @var IURLGenerator */
41
	private $urlGenerator;
42
43
	/**
44
	 * Constructor
45
	 *
46
	 * @param string $appName
47
	 * @param IRequest $request
48
	 * @param IURLGenerator $urlGenerator
49
	 * @param SearchFolderService $searchFolderService
50
	 * @param ConfigService $configService
51
	 * @param SearchMediaService $searchMediaService
52
	 * @param DownloadService $downloadService
53
	 * @param ILogger $logger
54
	 */
55 34 View Code Duplication
	public function __construct(
56
		$appName,
57
		IRequest $request,
58
		IURLGenerator $urlGenerator,
59
		SearchFolderService $searchFolderService,
60
		ConfigService $configService,
61
		SearchMediaService $searchMediaService,
62
		DownloadService $downloadService,
63
		ILogger $logger
64
	) {
65 34
		parent::__construct($appName, $request);
66
67 34
		$this->urlGenerator = $urlGenerator;
68 34
		$this->searchFolderService = $searchFolderService;
69 34
		$this->configService = $configService;
70 34
		$this->searchMediaService = $searchMediaService;
71 34
		$this->downloadService = $downloadService;
72 34
		$this->logger = $logger;
73 34
	}
74
75
	/**
76
	 * @NoAdminRequired
77
	 *
78
	 * Returns a list of all media files available to the authenticated user
79
	 *
80
	 *    * Authentication can be via a login/password or a token/(password)
81
	 *    * For private galleries, it returns all media files, with the full path from the root
82
	 *     folder For public galleries, the path starts from the folder the link gives access to
83
	 *     (virtual root)
84
	 *    * An exception is only caught in case something really wrong happens. As we don't test
85
	 *     files before including them in the list, we may return some bad apples
86
	 *
87
	 * @param string $location a path representing the current album in the app
88
	 * @param string $features the list of supported features
89
	 * @param string $etag the last known etag in the client
90
	 * @param string $mediatypes the list of supported media types
91
	 *
92
	 * @return array <string,array<string,string|int>>|Http\JSONResponse
0 ignored issues
show
Should the return type not be array<string,array|strin...lean>|Http\JSONResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
93
	 */
94 7
	public function getList($location, $features, $etag, $mediatypes) {
95 7
		$featuresArray = explode(';', $features);
96 7
		$mediaTypesArray = explode(';', $mediatypes);
97
		try {
98 7
			return $this->getFilesAndAlbums($location, $featuresArray, $etag, $mediaTypesArray);
99 2
		} catch (\Exception $exception) {
100 2
			return $this->jsonError($exception);
101
		}
102
	}
103
104
	/**
105
	 * @NoAdminRequired
106
	 *
107
	 * Sends the file matching the fileId
108
	 *
109
	 * @param int $fileId the ID of the file we want to download
110
	 * @param string|null $filename
111
	 *
112
	 * @return ImageResponse
113
	 */
114 9
	public function download($fileId, $filename = null) {
115
		try {
116 9
			$download = $this->getDownload($fileId, $filename);
117 2
		} catch (ServiceException $exception) {
118 2
			$code = $this->getHttpStatusCode($exception);
119 2
			$url = $this->urlGenerator->linkToRoute(
120 2
				$this->appName . '.page.error_page', ['code' => $code]
121
			);
122
123 2
			$response = new RedirectResponse($url);
124 2
			$response->addCookie('galleryErrorMessage', $exception->getMessage());
125
126 2
			return $response;
127
		}
128
129
		// That's the only exception out of all the image media types we serve
130 7
		if ($download['mimetype'] === 'image/svg+xml') {
131 2
			$download['mimetype'] = 'text/plain';
132
		}
133
134 7
		return new ImageResponse($download);
135
	}
136
137
}
138