Issues (158)

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.

controller/appcontroller.php (1 issue)

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
 * Copyright (c) 2014, Tobia De Koninck hey--at--ledfan.be
4
 * This file is licensed under the AGPL version 3 or later.
5
 * See the COPYING file.
6
 */
7
8
namespace OCA\Chat\Controller;
9
10
use \OCP\AppFramework\Controller;
11
use \OCP\IRequest;
12
use \OCP\AppFramework\Http\JSONResponse;
13
use \OCP\AppFramework\Http\TemplateResponse;
14
use \OCA\Chat\App\Chat;
15
use \OCP\Contacts\IManager;
16
use \OCP\IConfig;
17
use \OCA\Chat\OCH\Commands\Greet;
18
19
class AppController extends Controller {
20
21
	/**
22
	 * @var Chat OCA\Chat\App\Chat;
23
	 */
24
	private $app;
25
26
	/**
27
	 * @var \OCP\IConfig
28
	 */
29
	private $config;
30
31
	/**
32
	 * @var \OCP\Contacts\IManager
33
	 */
34
	private $cm;
35
36
	/**
37
	 * @var \OCA\Chat\OCH\Commands\Greet
38
	 */
39
	private $greet;
40
41
	public function __construct(
42
		$appName,
43
		IRequest $request,
44
		Chat $app,
45
		IManager $cm,
46
		IConfig $config,
47
		Greet $greet
48
	){
49
		parent::__construct($appName, $request);
50
		$this->app = $app;
51
		$this->cm = $cm;
52
		$this->config = $config;
53
		$this->greet = $greet;
54
	}
55
56
	/**
57
	 * @NoCSRFRequired
58
	 * @NoAdminRequired
59
	 * @return TemplateResponse
60
	 */
61
	public function index() {
62
		session_write_close();
63
		$this->greet->setRequestData(array(
64
			"timestamp" => time(),
65
			"user" => $this->app->getCurrentUser(),
66
		));
67
		$sessionId = $this->greet->execute();
68
		$contacts = $this->app->getContacts();
69
		$backends = $this->app->getBackends();
70
		$backendsToArray = array();
71
		foreach($backends as $backend){
72
			$backendsToArray[$backend->getId()] = $backend->toArray();
73
		}
74
		$initConvs = $this->app->getInitConvs();
75
		$params = array(
76
			"initvar" => json_encode(array(
77
				"contacts" => $contacts['contacts'],
78
				"contactsList" => $contacts['contactsList'],
79
				"contactsObj" => $contacts['contactsObj'],
80
				"backends" => $backendsToArray,
81
				"initConvs" => $initConvs,
82
				"sessionId" => $sessionId['session_id'],
83
				"avatars_enabled" => $this->config->getSystemValue('enable_avatars', true)
84
			)),
85
 		);
86
		return new TemplateResponse($this->appName, 'main', $params);
87
	}
88
89
	/**
90
	 * @NoAdminRequired
91
	 * @return JSONResponse
92
	 */
93
	public function contacts(){
94
		session_write_close();
95
		return new JSONResponse($this->app->getContacts());
96
	}
97
98
	/**
99
	 * @NoAdminRequired
100
	 * @return JSONResponse
101
	 */
102
	public function addContact($contacts){
103
104
		$addressbooks = $this->cm->getAddressBooks();
105
		$key = array_search('Contacts', $addressbooks);
106
107
		// Create contacts
108
		$ids = array();
109
		foreach ($contacts as $contact){
110
			$r = $this->cm->createOrUpdate($contact, $key);
111
			$ids[] = $r->getId();
112
		}
113
114
		// Return just created contacts as contacts which can be used by the Chat app
115
		$contacts =  $this->app->getContacts();
116
		$newContacts = array();
117
		foreach ($ids as $id){
118
			$newContacts[$id] = $contacts['contactsObj'][$id];
119
		}
120
121
		return $newContacts;
122
	}
123
124
	/**
125
	 * @NoAdminRequired
126
	 * @return JSONResponse
127
	 */
128
	public function removeContact($contacts){
129
		// Create contacts
130
		$ids = array();
0 ignored issues
show
$ids is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
131
		foreach ($contacts as $contact){
132
			$this->cm->delete($contact, 'local:1');
133
		}
134
135
	}
136
137
138
	/**
139
	 * @NoAdminRequired
140
	 * @return JSONResponse
141
	 */
142
	public function initVar(){
143
		session_write_close();
144
		$this->greet->setRequestData(array(
145
			"timestamp" => time(),
146
			"user" => $this->app->getCurrentUser(),
147
		));
148
		$sessionId = $this->greet->execute();
149
150
		$contacts = $this->app->getContacts();
151
		$backends = $this->app->getBackends();
152
		$backendsToArray = array();
153
		foreach($backends as $backend){
154
			$backendsToArray[$backend->getId()] = $backend->toArray();
155
		}
156
		$initConvs = $this->app->getInitConvs();
157
		return array(
158
			"contacts" => $contacts['contacts'],
159
			"contactsList" => $contacts['contactsList'],
160
			"contactsObj" => $contacts['contactsObj'],
161
			"backends" => $backendsToArray,
162
			"initConvs" => $initConvs,
163
			"sessionId" => $sessionId['session_id'],
164
			"avatars_enabled" => $this->config->getSystemValue('enable_avatars', true)
165
		);
166
	}
167
168
}
169