Issues (2473)

Branch: master

Security Analysis    no vulnerabilities found

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.

mod/tasks/lib/tasks.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
 * Pages function library
4
 */
5
6
/**
7
 * Prepare the add/edit form variables
8
 *
9
 * @param ElggObject $task
10
 * @return array
11
 */
12
function tasks_prepare_form_vars($task = null, $parent_guid = 0) {
13
14
	// input names => defaults
15
	$values = array(
16
		'title' => '',
17
		'description' => '',
18
		
19
		
20
		// FXN - Ajout des champs spécifiques, serait mieux autre part en fait
21
		'start_date' => '',
22
		'end_date' => '',
23
		'task_type' => '',
24
		'status' => '',
25
		'assigned_to' => '',
26
		'percent_done' => '',
27
		'work_remaining' => '',
28
		
29
		'access_id' => ACCESS_DEFAULT,
30
		'write_access_id' => ACCESS_DEFAULT,
31
		'tags' => '',
32
		'container_guid' => elgg_get_page_owner_guid(),
33
		'guid' => null,
34
		'entity' => $task,
35
		'parent_guid' => $parent_guid,
36
	);
37
38
	if ($task) {
39
		foreach (array_keys($values) as $field) {
40
			if (isset($task->$field)) {
41
				$values[$field] = $task->$field;
42
			}
43
		}
44
	}
45
46
	if (elgg_is_sticky_form('task')) {
47
		$sticky_values = elgg_get_sticky_values('task');
48
		foreach ($sticky_values as $key => $value) {
49
			$values[$key] = $value;
50
		}
51
	}
52
53
	elgg_clear_sticky_form('task');
54
55
	return $values;
56
}
57
58
/**
59
 * Recurses the task tree and adds the breadcrumbs for all ancestors
60
 *
61
 * @param ElggObject $task Page entity
62
 */
63 View Code Duplication
function tasks_prepare_parent_breadcrumbs($task) {
64
	if ($task && $task->parent_guid) {
65
		$parents = array();
66
		$parent = get_entity($task->parent_guid);
67
		while ($parent) {
68
			array_push($parents, $parent);
69
			$parent = get_entity($parent->parent_guid);
70
		}
71
		while ($parents) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $parents of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
72
			$parent = array_pop($parents);
73
			elgg_push_breadcrumb($parent->title, $parent->getURL());
74
		}
75
	}
76
}
77
78
/**
79
 * Register the navigation menu
80
 *
81
 * @param ElggEntity $container Container entity for the tasks
82
 */
83
function tasks_register_navigation_tree($container) {
84
	if (!$container) {
85
		return;
86
	}
87
88
	$top_tasks = elgg_get_entities(array(
89
		'type' => 'object',
90
		'subtype' => 'task_top',
91
		'container_guid' => $container->getGUID(),
92
		'limit' => false
93
	));
94
95
	if ($top_tasks) {
96 View Code Duplication
		foreach ($top_tasks as $task) {
97
			elgg_register_menu_item('tasks_nav', array(
98
				'name' => $task->getGUID(),
99
				'text' => $task->title,
100
				'href' => $task->getURL(),
101
			));
102
	
103
			$stack = array();
104
			array_push($stack, $task);
105
			while (count($stack) > 0) {
106
				$parent = array_pop($stack);
107
				$children = elgg_get_entities_from_metadata(array(
108
					'type' => 'object',
109
					'subtype' => 'task',
110
					'limit' => false,
111
					'metadata_name_value_pairs' => array(
112
						'name' => 'parent_guid',
113
						'value' => $parent->getGUID()
114
					)
115
				));
116
				
117
				if ($children) {
118
					foreach ($children as $child) {
119
						elgg_register_menu_item('tasks_nav', array(
120
							'name' => $child->getGUID(),
121
							'text' => $child->title,
122
							'href' => $child->getURL(),
123
							'parent_name' => $parent->getGUID(),
124
						));
125
						array_push($stack, $child);
126
					}
127
				}
128
			}
129
		}
130
	}
131
}
132
133
134
function tasks_get_json($options) {
135
136
	$entities_options = array(
137
			'type' 			=> 'object',
138
			'subtype' 		=> 'task_top',
139
			'limit' 		=> false,
140
			'metadata_name_value_pairs_operator' => 'OR',
141
			'joins' => array(),
142
			'wheres' => array(),
143
			'order_by_metadata' => array("name" => 'start_date', "direction" => 'ASC', "as" => "text")
144
		);
145
		
146
	$oEntity = get_entity($options['owner']);
147
	
148
	if (elgg_instanceof($oEntity , 'group')){
149
		$entities_options['container_guid'] = $options['owner'];
150
	}elseif($options["owner"] && $options['filter'] == 'mine'){
151
		$entities_options['owner_guid'] = $options['owner'];
152
		$entities_options['container_guid'] = $options['owner'];
153
	}elseif($options["owner"] && $options['filter'] == 'friends' ){
154
		$friends = get_user_friends($options["owner"], "", 999999, 0);
155
		$friendguids = array();
156
		foreach ($friends as $friend) {
157
             $friendguids[] = $friend->getGUID();
158
        }
159
		$entities_options['owner_guid'] = $friendguids;
160
	}
161
162 View Code Duplication
	if(!empty($options['start_date'])) {
163
		$entities_options['metadata_name_value_pairs'][] = array('name' => 'start_date', 'value' => $options['start_date'], 'operand' => '>=');
164
	}
165
	
166 View Code Duplication
	if(!empty($options['end_date'])) {
167
		$entities_options['metadata_name_value_pairs'][] = array('name' => 'end_date', 'value' => $options['end_date'], 'operand' => '<=');
168
	}
169
170
	$tasks = elgg_get_entities_from_metadata($entities_options);
171
	$result = array();
172
	foreach($tasks as $task){
173
	
174
		$oname 	= $task->getOwnerEntity()->name;
175
		$mine 	= $task->getOwnerGUID() == elgg_get_logged_in_user_entity()->guid; 
176
		$friend = $task->getOwnerEntity()->isFriendsWith(elgg_get_logged_in_user_entity()->guid);
177
		$group	= elgg_instanceof($task->getContainerEntity(), 'group');
178
		$tag_string = '';
179
		if (is_array($task->tags)) {
180
			$tags = array();
181
182
			foreach ($task->tags as $tag) {
183
				if (is_string($tag)) {
184
					$tags[] = $tag;
185
				} else {
186
					$tags[] = $tag->value;
187
				}
188
			}
189
190
			$tag_string = implode(", ", $tags);
191
		}
192
	
193
		$result[] = array(
194
			"id"=>$task->guid,
195
			"container_guid"=>$task->getContainerGUID(),
196
			"parent_guid"=>$task->parent_guid,
197
			
198
			'title' => $task->title,
199
			'start' => $task->start_date,
200
			'end' => $task->end_date,
201
202
			'description' => $task->description,
203
			'task_type' => $task->task_type,
204
			'status' => $task->status,
205
			'assigned_to' => $task->assigned_to,
206
			'percent_done' => $task->percent_done,
207
			'work_remaining' => $task->work_remaining,
208
			
209
			'tags' => $tag_string,
210
			'access_id' => $task->access_id,
211
			'write_access_id' => $task->write_access_id,
212
			
213
			"oname" => $oname,
214
			
215
			"color" => ($group ? 'DarkSlateBlue' : ( $friend ? 'HotPink' : ($mine ? 'DarkGreen' : ''))),
216
			"url"	=> elgg_get_site_url().'tasks/view/'.$task->guid,
217
			"editable" => $task->canEdit() ? 'true' : 'false',
218
219
			
220
		);
221
	}
222
	die(json_encode($result));	
223
}
224