Issues (75)

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/locationcontroller.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
 * ownCloud - maps
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the COPYING file.
7
 *
8
 * @author Sander Brand <[email protected]>
9
 * @copyright Sander Brand 2014
10
 */
11
12
namespace OCA\Maps\Controller;
13
14
use OCA\Maps\Db\Device;
15
use OCA\Maps\Db\DeviceMapper;
16
use OCA\Maps\Db\Location;
17
use OCA\Maps\Db\LocationMapper;
18
use \OCP\IRequest;
19
use \OCP\AppFramework\Http\JSONResponse;
20
use \OCP\AppFramework\ApiController;
21
22
23
class LocationController extends ApiController {
24
25
	private $userId;
26
	private $locationMapper;
27
	private $deviceMapper;
28
29
	public function __construct($appName, IRequest $request, LocationMapper $locationMapper, DeviceMapper $deviceMapper, $userId) {
30
		parent::__construct($appName, $request);
31
		$this->locationMapper = $locationMapper;
32
		$this->deviceMapper = $deviceMapper;
33
		$this->userId = $userId;
34
	}
35
36
	/**
37
	 * @NoAdminRequired
38
	 *
39
	 * @param $lat int
40
	 * @param $lon int
41
	 * @param $timestamp string
42
	 * @param $hdop string
43
	 * @param $altitude int
44
	 * @param $speed int
45
	 * @param $hash string
46
	 * @return JSONResponse
47
	 */
48
	public function update($lat, $lon, $timestamp, $hdop, $altitude, $speed, $hash) {
49
50
		$location = new Location();
51
		$location->lat = $lat;
52
		$location->lng = $lon;
53
		if((string)(float)$timestamp === $timestamp) {
54
			if(strtotime(date('d-m-Y H:i:s',$timestamp)) === (int)$timestamp) {
55
				$location->timestamp = (int)$timestamp;
56
			} elseif(strtotime(date('d-m-Y H:i:s',$timestamp/1000)) === (int)floor($timestamp/1000)) {
57
				$location->timestamp = (int)floor($timestamp/1000);
58
			}
59
		} else {
60
			$location->timestamp = strtotime($timestamp);
61
		}
62
		$location->hdop = $hdop;
63
		$location->altitude = $altitude;
64
		$location->speed = $speed;
65
		$location->deviceHash = $hash;
66
67
		/* Only save location if hash exists in db */
68
		try {
69
			$this->deviceMapper->findByHash($hash);
70
			return new JSONResponse($this->locationMapper->insert($location));
71
		} catch(\OCP\AppFramework\Db\DoesNotExistException $e) {
0 ignored issues
show
The class OCP\AppFramework\Db\DoesNotExistException 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...
72
			return new JSONResponse([
73
				'error' => $e->getMessage()
74
			]);
75
		}
76
	}
77
78
	/**
79
	 * @NoAdminRequired
80
	 *
81
	 * @param $name string
82
	 * @return JSONResponse
83
	 */
84
	public function addDevice($name){
85
		$device = new Device();
86
		$device->name = $name;
87
		$device->hash = uniqid();
88
		$device->created = time();
89
		$device->userId = $this->userId;
90
91
		/* @var $device Device */
92
		$device = $this->deviceMapper->insert($device);
93
94
		$response = array('id'=> $device->getId(),'hash'=>$device->hash);
95
		return new JSONResponse($response);
96
	}
97
98
	/**
99
	 * @NoAdminRequired
100
	 *
101
	 * @return JSONResponse
102
	 */
103
	public function loadDevices(){
104
		$response = $this->deviceMapper->findAll($this->userId);
105
		return new JSONResponse($response);
106
	}
107
108
	/**
109
	 * @NoAdminRequired
110
	 *
111
	 * @param $devices string comma separated list of device ids
112
	 * @param $from string
113
	 * @param $till string
114
	 * @param $limit int
115
	 * @return JSONResponse
116
	 */
117
	public function loadLocations($devices, $from, $till, $limit){
118
		$deviceIds = explode(',',$devices);
119
		$from = ($from) ? strtotime($from) : null;
120
		$till = ($till !== '') ? strtotime($till) : strtotime('now');
121
		$limit = ($limit !== '') ? (int) $limit : 2000;
122
		$response = array();
123
		foreach($deviceIds as $deviceId){
124
			$hash = $this->deviceMapper->findById($deviceId)->hash;
125
			$response[$deviceId] = $this->locationMapper->findBetween($hash, $from, $till, $limit);
126
		}
127
		return new JSONResponse($response);
128
	}
129
130
	/**
131
	 * @NoAdminRequired
132
	 *
133
	 * @param $deviceId string
134
	 * @return JSONResponse
135
	 */
136
	public function removeDevice($deviceId){
137
		/* @var $device Device */
138
		$device = $this->deviceMapper->findById($deviceId);
139
		if($device->userId == $this->userId) {
140
			$this->deviceMapper->delete($device);
141
		}
142
		return new JSONResponse();
143
	}
144
145
}
146