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/gc_autosubscribegroup/start.php (7 issues)

Labels

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
/**
4
 * Elgg autosubscribegroup plugin
5
 * Allows admins to select groups for new users to automatically join
6
 *
7
 * @package autosubscribegroups
8
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
9
 * @author RONNEL Jérémy
10
 * @author Mark Wooff <[email protected]>
11
 * @copyright (c) Elbee 2008
12
 * @link /www.notredeco.com
13
 *
14
 * for Elgg 1.9 onwards by iionly ([email protected])
15
 */
16
17
/**
18
 * Init
19
 */
20
elgg_register_event_handler('init', 'system', 'gc_autosubscribegroup_init');
21
22
function gc_autosubscribegroup_init() {
23
	// Listen to user registration
24
	elgg_register_event_handler('create', 'user', 'gc_autosubscribegroup_join', 502);
25
	elgg_register_event_handler('create', 'group', 'gc_autosubscribegroup_create', 502);
26
27
	elgg_register_ajax_view("organization_form/form");
28
}
29
30
/**
31
 * Autosubscribe new users upon registration
32
 * Autosubscribe new users by organization upon registration
33
 */
34
function gc_autosubscribegroup_join($event, $object_type, $object) {
35
	if( ($object instanceof ElggUser) && ($event == 'create') && ($object_type == 'user') ){
36
		//retrieve group ids from plugin
37
		$autogroups = elgg_get_plugin_setting('autogroups', 'gc_autosubscribegroup');
38
		$autogroups = split(',', $autogroups);
39
40
		//for each group id
41 View Code Duplication
		foreach($autogroups as $group){
42
			$ia = elgg_set_ignore_access(true);
43
			$groupEnt = get_entity($group);
44
			elgg_set_ignore_access($ia);
45
			//if group exists, submit to group
46
			if( $groupEnt ){
47
				//join group succeed?
48
				if( $groupEnt->join($object) ){
49
					add_entity_relationship($object->guid, 'cp_subscribed_to_email', $groupEnt->guid);
50
					add_entity_relationship($object->guid, 'cp_subscribed_to_site_mail', $groupEnt->guid);
51
52
					// Remove any invite or join request flags
53
					elgg_delete_metadata(array('guid' => $object->guid, 'metadata_name' => 'group_invite', 'metadata_value' => $groupEnt->guid, 'limit' => false));
54
					elgg_delete_metadata(array('guid' => $object->guid, 'metadata_name' => 'group_join_request', 'metadata_value' => $groupEnt->guid, 'limit' => false));
55
				}
56
			}
57
		}
58
59
		//retrieve group ids from plugin
60
		$organizationgroups = elgg_get_plugin_setting('organizationgroups', 'gc_autosubscribegroup');
61
		$organizationgroups = json_decode($organizationgroups, true);
62
63
		$meta_fields = array('user_type', 'federal', 'institution', 'university', 'college', 'provincial', 'ministry', 'municipal', 'international', 'ngo', 'community', 'business', 'media', 'retired', 'other');
64
		foreach($meta_fields as $field){
65
			$$field = get_input($field);
66
		}
67
68
		//for each group id
69
		foreach($organizationgroups as $group => $organizations){
70
			$ia = elgg_set_ignore_access(true);
71
			$groupEnt = get_entity($group);
72
			elgg_set_ignore_access($ia);
73
74
			foreach($organizations as $value){
75
				$match = false;
76
				$user_type2 = $institution2 = $organization2 = "";
77
				if( is_array($value) ){
78
					$user_type2 = array_keys($value)[0];
79
					$organization2 = array_values($value)[0];
80
				}
81 View Code Duplication
				if( is_array($organization2) ){
82
					$temp = $organization2;
83
					$institution2 = array_keys($temp)[0];
84
					$organization2 = array_values($temp)[0];
85
				}
86
				
87
				if( $user_type == $user_type2 ){
0 ignored issues
show
The variable $user_type does not exist. Did you mean $user_type2?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
88
					if( empty(trim($organization2)) ){
89
						$match = true;
90
					} else if( $$user_type == trim($organization2) ){
0 ignored issues
show
The variable $user_type does not exist. Did you mean $user_type2?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
91
						$match = true;
92
					} else if( $institution == $institution2 ){
0 ignored issues
show
The variable $institution does not exist. Did you mean $institution2?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
93
						if($university == $organization2 || $college == $organization2){
0 ignored issues
show
The variable $university does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $college does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
94
							$match = true;
95
						}
96
					} else if( $provincial == $institution2 ){
0 ignored issues
show
The variable $provincial does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
97
						if($ministry == $organization2){
0 ignored issues
show
The variable $ministry does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
98
							$match = true;
99
						}
100
					}
101
					if( $match ){
102
						if( $groupEnt ){
103
							//join group succeed?
104
							if( $groupEnt->join($object) ){
105
								add_entity_relationship($object->guid, 'cp_subscribed_to_email', $groupEnt->guid);
106
								add_entity_relationship($object->guid, 'cp_subscribed_to_site_mail', $groupEnt->guid);
107
108
								// Remove any invite or join request flags
109
								elgg_delete_metadata(array('guid' => $object->guid, 'metadata_name' => 'group_invite', 'metadata_value' => $groupEnt->guid, 'limit' => false));
110
								elgg_delete_metadata(array('guid' => $object->guid, 'metadata_name' => 'group_join_request', 'metadata_value' => $groupEnt->guid, 'limit' => false));
111
							}
112
						}
113
					}
114
				}
115
			}
116
		}
117
	}
118
}
119
120
/**
121
 * Autosubscribe group admins upon group creation
122
 */
123
function gc_autosubscribegroup_create($event, $object_type, $object) {
124
	if( ($object instanceof ElggGroup) && ($event == 'create') && ($object_type == 'group') ){
125
		//retrieve group ids from plugin
126
		$groups = elgg_get_plugin_setting('admingroups', 'gc_autosubscribegroup');
127
		$groups = split(',', $groups);
128
129
		//for each group id
130 View Code Duplication
		foreach($groups as $groupId){
131
			$ia = elgg_set_ignore_access(true);
132
			$groupEnt = get_entity($groupId);
133
			elgg_set_ignore_access($ia);
134
			$userEnt = get_user($object->owner_guid);
135
			//if group exists, submit to group
136
			if( $groupEnt ){
137
				//join group succeed?
138
				if( $groupEnt->join($userEnt) ){
139
					add_entity_relationship($userEnt->guid, 'cp_subscribed_to_email', $groupEnt->guid);
140
					add_entity_relationship($userEnt->guid, 'cp_subscribed_to_site_mail', $groupEnt->guid);
141
142
					// Remove any invite or join request flags
143
					elgg_delete_metadata(array('guid' => $userEnt->guid, 'metadata_name' => 'group_invite', 'metadata_value' => $groupEnt->guid, 'limit' => false));
144
					elgg_delete_metadata(array('guid' => $userEnt->guid, 'metadata_name' => 'group_join_request', 'metadata_value' => $groupEnt->guid, 'limit' => false));
145
				}
146
			}
147
		}
148
	}
149
}
150