Issues (493)

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.

lib/sabre/exceptionloggerplugin.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
 * @author Morris Jobke <[email protected]>
4
 * @author Robin Appelman <[email protected]>
5
 * @author Thomas Müller <[email protected]>
6
 * @author Vincent Petry <[email protected]>
7
 *
8
 * @copyright Copyright (c) 2015, ownCloud, Inc.
9
 * @license AGPL-3.0
10
 *
11
 * This code is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License, version 3,
13
 * as published by the Free Software Foundation.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License, version 3,
21
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
22
 *
23
 */
24
25
namespace OCA\Contacts\Sabre;
26
27
use OCP\ILogger;
28
use Sabre\DAV\Exception;
29
use Sabre\HTTP\Response;
30
31
class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
32
	protected $nonFatalExceptions = array(
33
		'Sabre\DAV\Exception\NotAuthenticated' => true,
34
		// the sync client uses this to find out whether files exist,
35
		// so it is not always an error, log it as debug
36
		'Sabre\DAV\Exception\NotFound' => true,
37
		// this one mostly happens when the same file is uploaded at
38
		// exactly the same time from two clients, only one client
39
		// wins, the second one gets "Precondition failed"
40
		'Sabre\DAV\Exception\PreconditionFailed' => true,
41
		// forbidden can be expected when trying to upload to
42
		// read-only folders for example
43
		'Sabre\DAV\Exception\Forbidden' => true,
44
	);
45
46
	/** @var string */
47
	private $appName;
48
49
	/** @var ILogger */
50
	private $logger;
51
52
	/**
53
	 * @param string $loggerAppName app name to use when logging
54
	 * @param ILogger $logger
55
	 */
56
	public function __construct($loggerAppName, $logger) {
57
		$this->appName = $loggerAppName;
58
		$this->logger = $logger;
59
	}
60
61
	/**
62
	 * This initializes the plugin.
63
	 *
64
	 * This function is called by \Sabre\DAV\Server, after
65
	 * addPlugin is called.
66
	 *
67
	 * This method should set up the required event subscriptions.
68
	 *
69
	 * @param \Sabre\DAV\Server $server
70
	 * @return void
71
	 */
72
	public function initialize(\Sabre\DAV\Server $server) {
73
74
		$server->on('exception', array($this, 'logException'), 10);
75
	}
76
77
	/**
78
	 * Log exception
79
	 *
80
	 */
81
	public function logException(\Exception $ex) {
82
		$exceptionClass = get_class($ex);
83
		$level = \OCP\Util::FATAL;
84
		if (isset($this->nonFatalExceptions[$exceptionClass])) {
85
			$level = \OCP\Util::DEBUG;
86
		}
87
88
		$message = $ex->getMessage();
89
		if ($ex instanceof Exception) {
0 ignored issues
show
The class Sabre\DAV\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
90
			if (empty($message)) {
91
				$response = new Response($ex->getHTTPCode());
92
				$message = $response->getStatusText();
93
			}
94
			$message = "HTTP/1.1 {$ex->getHTTPCode()} $message";
95
		}
96
97
		$exception = [
98
			'Message' => $message,
99
			'Exception' => $exceptionClass,
100
			'Code' => $ex->getCode(),
101
			'Trace' => $ex->getTraceAsString(),
102
			'File' => $ex->getFile(),
103
			'Line' => $ex->getLine(),
104
		];
105
		$this->logger->log($level, 'Exception: ' . json_encode($exception), ['app' => $this->appName]);
106
	}
107
}
108