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/logrotate/start.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 log rotator.
4
 *
5
 * @package ElggLogRotate
6
 */
7
8
elgg_register_event_handler('init', 'system', 'logrotate_init');
9
10
function logrotate_init() {
11
	$period = elgg_get_plugin_setting('period', 'logrotate');
12
	$delete = elgg_get_plugin_setting('delete', 'logrotate');
13
	switch ($period) {
14
		case 'weekly':
15
		case 'monthly' :
16
		case 'yearly' :
17
			break;
18
		default:
19
			$period = 'monthly';
20
	}
21
22
	// Register cron hook for archival of logs
23
	elgg_register_plugin_hook_handler('cron', $period, 'logrotate_archive_cron');
24
25
	if ($delete != 'never') {
26
		// Register cron hook for deletion of selected archived logs
27
		elgg_register_plugin_hook_handler('cron', $delete, 'logrotate_delete_cron');
28
	}
29
}
30
31
/**
32
 * Trigger the log rotation.
33
 */
34 View Code Duplication
function logrotate_archive_cron($hook, $entity_type, $returnvalue, $params) {
35
	$resulttext = elgg_echo("logrotate:logrotated");
36
37
	$day = 86400;
38
39
	$offset = 0;
40
	$period = elgg_get_plugin_setting('period', 'logrotate');
41
	switch ($period) {
42
		case 'weekly':
43
			$offset = $day * 7;
44
			break;
45
		case 'yearly':
46
			$offset = $day * 365;
47
			break;
48
		case 'monthly':
49
		default:
50
			// assume 28 days even if a month is longer. Won't cause data loss.
51
			$offset = $day * 28;
52
	}
53
54
	if (!archive_log($offset)) {
55
		$resulttext = elgg_echo("logrotate:lognotrotated");
56
	}
57
58
	return $returnvalue . $resulttext;
59
}
60
61
/**
62
 * Trigger the log deletion.
63
 */
64 View Code Duplication
function logrotate_delete_cron($hook, $entity_type, $returnvalue, $params) {
65
	$resulttext = elgg_echo("logrotate:logdeleted");
66
67
	$day = 86400;
68
69
	$offset = 0;
70
	$period = elgg_get_plugin_setting('delete', 'logrotate');
71
	switch ($period) {
72
		case 'weekly':
73
			$offset = $day * 7;
74
			break;
75
		case 'yearly':
76
			$offset = $day * 365;
77
			break;
78
		case 'monthly':
79
		default:
80
			// assume 28 days even if a month is longer. Won't cause data loss.
81
			$offset = $day * 28;
82
	}
83
84
	if (!log_browser_delete_log($offset)) {
85
		$resulttext = elgg_echo("logrotate:lognotdeleted");
86
	}
87
88
	return $returnvalue . $resulttext;
89
}
90
91
/**
92
 * This function deletes archived copies of the system logs that are older than specified.
93
 *
94
 * @param int $time_of_delete An offset in seconds from now to delete log tables
95
 * @return bool Were any log tables deleted
96
 */
97
function log_browser_delete_log($time_of_delete) {
98
	global $CONFIG;
99
100
	$cutoff = time() - (int)$time_of_delete;
101
102
	$deleted_tables = false;
103
	$results = get_data("SHOW TABLES like '{$CONFIG->dbprefix}system_log_%'");
104
	if ($results) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $results 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...
105
		foreach ($results as $result) {
106
			$data = (array)$result;
107
			$table_name = array_shift($data);
108
			// extract log table rotation time
109
			$log_time = str_replace("{$CONFIG->dbprefix}system_log_", '', $table_name);
110
			if ($log_time < $cutoff) {
111
				if (delete_data("DROP TABLE $table_name") !== false) {
112
					// delete_data returns 0 when dropping a table (false for failure)
113
					$deleted_tables = true;
114
				} else {
115
					elgg_log("Failed to delete the log table $table_name", 'ERROR');
116
				}
117
			}
118
		}
119
	}
120
121
	return $deleted_tables;
122
}
123