diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-09-11 14:14:02 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2014-09-17 13:17:52 +0200 |
commit | 6d3757f8648cb94b2ba04c6a5bfbc9dd1493103b (patch) | |
tree | 0cef084c3140b52a4ced70acc6ede3eb52cf33ab /lib/private/request.php | |
parent | 45b17207ccf03703d4d6c3925f5405f52579aee5 (diff) | |
download | nextcloud-server-6d3757f8648cb94b2ba04c6a5bfbc9dd1493103b.tar.gz nextcloud-server-6d3757f8648cb94b2ba04c6a5bfbc9dd1493103b.zip |
Do not show exception to the end-user
Log the error instead of potentially leaking sensitive information
Diffstat (limited to 'lib/private/request.php')
-rwxr-xr-x | lib/private/request.php | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/private/request.php b/lib/private/request.php index b063c1f5967..fa446837a97 100755 --- a/lib/private/request.php +++ b/lib/private/request.php @@ -14,6 +14,7 @@ class OC_Request { const USER_AGENT_FREEBOX = '#^Mozilla/5\.0$#'; const REGEX_LOCALHOST = '/^(127\.0\.0\.1|localhost)(:[0-9]+|)$/'; + static protected $reqId; /** * Returns the remote address, if the connection came from a trusted proxy and `forwarded_for_headers` has been configured @@ -22,7 +23,7 @@ class OC_Request { * @return string IP address */ public static function getRemoteAddress() { - $remoteAddress = $_SERVER['REMOTE_ADDR']; + $remoteAddress = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $trustedProxies = \OC::$server->getConfig()->getSystemValue('trusted_proxies', array()); if(is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) { @@ -44,6 +45,17 @@ class OC_Request { } /** + * Returns an ID for the request, value is not guaranteed to be unique and is mostly meant for logging + * @return string + */ + public static function getRequestID() { + if(self::$reqId === null) { + self::$reqId = hash('md5', microtime().\OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(20)); + } + return self::$reqId; + } + + /** * Check overwrite condition * @param string $type * @return bool |