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.

engine/lib/statistics.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
 * Elgg statistics library.
4
 *
5
 * This file contains a number of functions for obtaining statistics about the running system.
6
 * These statistics are mainly used by the administration pages, and is also where the basic
7
 * views for statistics are added.
8
 *
9
 * @package Elgg.Core
10
 * @subpackage Statistics
11
 */
12
13
/**
14
 * Return an array reporting the number of various entities in the system.
15
 *
16
 * @param int $owner_guid Optional owner of the statistics
17
 *
18
 * @return array
19
 */
20
function get_entity_statistics($owner_guid = 0) {
21
22
	$owner_guid = (int) $owner_guid;
23
	$entity_stats = array();
24
25
	$grouped_entities = elgg_get_entities(array(
26
		'selects' => array('COUNT(*) as cnt'),
27
		'owner_guids' => ($owner_guid) ? : ELGG_ENTITIES_ANY_VALUE,
28
		'group_by' => 'e.type, e.subtype',
29
		'limit' => 0,
30
		'order_by' => 'cnt DESC',
31
	));
32
	
33
	if (!empty($grouped_entities)) {
34
		foreach ($grouped_entities as $entity) {
35
			$type = $entity->getType();
36
			if (!isset($entity_stats[$type]) || !is_array($entity_stats[$type])) {
37
				$entity_stats[$type] = array();
38
			}
39
			$subtype = $entity->getSubtype();
40
			if (!$subtype) {
41
				$subtype = '__base__';
42
			}
43
			$entity_stats[$type][$subtype] = $entity->getVolatileData('select:cnt');
44
		}
45
	}
46
47
	return $entity_stats;
48
}
49
50
/**
51
 * Return the number of users registered in the system.
52
 *
53
 * @param bool $show_deactivated Count not enabled users?
54
 *
55
 * @return int
56
 */
57
function get_number_users($show_deactivated = false) {
58
	global $CONFIG;
59
60
	$access = "";
61
62
	if (!$show_deactivated) {
63
		$access = "and " . _elgg_get_access_where_sql(array('table_alias' => ''));
64
	}
65
66
	$query = "SELECT count(*) as count
67
		from {$CONFIG->dbprefix}entities where type='user' $access";
68
69
	$result = get_data_row($query);
70
71
	if ($result) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $result 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
		return $result->count;
73
	}
74
75
	return false;
76
}
77
78
/**
79
 * Render a list of currently online users
80
 *
81
 * @tip This also support options from elgg_list_entities().
82
 *
83
 * @param array $options Options array with keys:
84
 *
85
 *    seconds (int) => Number of seconds (default 600 = 10min)
86
 *
87
 * @return string
88
 */
89
function get_online_users(array $options = array()) {
90
	$options = array_merge(array(
91
		'seconds' => 600,
92
	), $options);
93
94
	return elgg_list_entities($options, 'find_active_users');
95
}
96
97
/**
98
 * Initialise the statistics admin page.
99
 *
100
 * @return void
101
 * @access private
102
 */
103
function statistics_init() {
104
	elgg_extend_view('core/settings/statistics', 'core/settings/statistics/online');
105
	elgg_extend_view('core/settings/statistics', 'core/settings/statistics/numentities');
106
}
107
108
return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
109
	$events->registerHandler('init', 'system', 'statistics_init');
110
};
111