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/questions/classes/ElggQuestion.php (1 issue)

Labels
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
class ElggQuestion extends ElggObject {
4
	
5
	const SUBTYPE = 'question';
6
	
7
	/**
8
	 * (non-PHPdoc)
9
	 * @see ElggObject::initializeAttributes()
10
	 */
11
	protected function initializeAttributes() {
12
		parent::initializeAttributes();
13
		
14
		$this->attributes['subtype'] = self::SUBTYPE;
15
	}
16
	
17
	/**
18
	 * (non-PHPdoc)
19
	 * @see ElggEntity::getURL()
20
	 */
21
	public function getURL() {
22
		$url = "questions/view/{$this->getGUID()}/" . elgg_get_friendly_title($this->title);
23
		
24
		return elgg_normalize_url($url);
25
	}
26
	
27
	/**
28
	 * (non-PHPdoc)
29
	 * @see ElggObject::canComment()
30
	 */
31
	public function canComment($user_guid = 0) {
32
		
33
		if ($this->comments_enabled === 'off') {
0 ignored issues
show
The property comments_enabled does not seem to exist. Did you mean enabled?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
34
			return false;
35
		}
36
		
37
		return parent::canComment($user_guid);
38
	}
39
	
40
	/**
41
	 * Get the answers on this question
42
	 *
43
	 * @param array $options accepts all elgg_get_entities options
44
	 *
45
	 * @return false|int|ElggAnswer[]
46
	 */
47
	public function getAnswers(array $options = array()) {
48
		$defaults = [
49
			'order_by' => 'time_created asc',
50
		];
51
		
52
		$overrides = [
53
			'type' => 'object',
54
			'subtype' => 'answer',
55
			'container_guid' => $this->getGUID(),
56
		];
57
		
58
		$options = array_merge($defaults, $options, $overrides);
59
		
60
		return elgg_get_entities($options);
61
	}
62
	
63
	/**
64
	 * List the answers on this question
65
	 *
66
	 * @param array $options accepts all elgg_list_entities options
67
	 *
68
	 * @return string
69
	 */
70
	public function listAnswers(array $options = []) {
71
		return elgg_list_entities($options, [$this, 'getAnswers']);
72
	}
73
	
74
	/**
75
	 * Get the answer that was marked as the correct answer.
76
	 *
77
	 * @return fasle|ElggAnswer
78
	 */
79
	public function getMarkedAnswer() {
80
		$result = false;
81
		
82
		$options = [
83
			'type' => 'object',
84
			'subtype' => ElggAnswer::SUBTYPE,
85
			'limit' => 1,
86
			'container_guid' => $this->getGUID(),
87
			'metadata_name_value_pairs' => array(
88
				'name' => 'correct_answer',
89
				'value' => true
90
			)
91
		];
92
		
93
		$answers = elgg_get_entities_from_metadata($options);
94
		if (!empty($answers)) {
95
			$result = $answers[0];
96
		}
97
		
98
		return $result;
99
	}
100
	
101
	/**
102
	 * Helper function to close a question from further answers.
103
	 *
104
	 * @return void
105
	 */
106
	public function close() {
107
		$this->status = 'closed';
108
	}
109
	
110
	/**
111
	 * Reopen the question for more answers.
112
	 *
113
	 * @return void
114
	 */
115
	public function reopen() {
116
		$this->status = 'open';
117
	}
118
	
119
	/**
120
	 * Get the current status of the question.
121
	 *
122
	 * This can be
123
	 * - 'open'
124
	 * - 'closed'
125
	 *
126
	 * @return string the current status
127
	 */
128
	public function getStatus() {
129
		$result = 'open';
130
		
131
		// do we even support status
132
		if (questions_close_on_marked_answer()) {
133
			// make sure the status is correct
134
			switch ($this->status) {
135
				case 'open':
136
					// is it still open, so no marked answer
137
					if ($this->getMarkedAnswer()) {
138
						$result = 'closed';
139
					}
140
					break;
141
				case 'closed':
142
					$result = 'closed';
143
					// is it still open, so no marked answer
144
					if (!$this->getMarkedAnswer()) {
145
						$result = 'open';
146
					}
147
					break;
148
				default:
149
					// no setting yet
150
					if ($this->getMarkedAnswer()) {
151
						$result = 'closed';
152
					}
153
					break;
154
			}
155
		}
156
		
157
		return $result;
158
	}
159
}
160