Issues (19)

Security Analysis    no request data  

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.

src/Assignees.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
namespace ST;
4
5
use ParserOutput;
6
use SMW\ApplicationFactory;
7
use SMW\DIWikiPage;
8
use SMWDataItem;
9
use User;
10
use WikiPage;
11
12
/** @todo: rename TaskDiff something similar */
13
class Assignees {
14
15
	private $taskAssignees;
16
	private $taskStatus;
17
18
	/**
19
	 * Previously this was SemanticTasksMailer::findOldValues
20
	 *
21
	 * @param WikiPage $article
22
	 * @return bool
23
	 */
24
	public function saveAssignees( WikiPage &$article ) {
25
		$this->taskAssignees = $this->getCurrentAssignees( $article, null );
26
		$this->taskStatus = $this->getCurrentStatus( $article, null );
27
		return true;
28
	}
29
30
	public function getSavedStatus() {
31
		return $this->taskStatus;
32
	}
33
34
	public function getSavedAssignees() {
35
		return $this->taskAssignees;
36
	}
37
38
	/**
39
	 * @param WikiPage $article
40
	 * @param $revision
41
	 * @return array
42
	 */
43
	public function getCurrentAssignees( WikiPage &$article, $revision ) {
44
		global $stgPropertyAssignedTo;
45
		return $this->getProperties( $stgPropertyAssignedTo, $article, $revision );
46
	}
47
48
	public function getCurrentCarbonCopy( WikiPage &$article, $revision ) {
49
		global $stgPropertyCarbonCopy;
50
		return $this->getProperties( $stgPropertyCarbonCopy, $article, $revision );
51
	}
52
53
	/**
54
	 * @param WikiPage $article
55
	 * @param $revision
56
	 * @return string
57
	 */
58
	public function getCurrentStatus( WikiPage &$article, $revision ) {
59
		global $stgPropertyStatus;
60
		$status = $this->getProperties( $stgPropertyStatus, $article, $revision );
61
		$statusString = '';
62
		if ( count( $status ) > 0 ) {
63
			$statusString = $status[0];
64
		}
65
		return $statusString;
66
	}
67
68
	/**
69
	 * @param WikiPage $article
70
	 * @param $revision
71
	 * @return array
72
	 */
73
	public function getNewAssignees( WikiPage &$article, $revision ) {
74
		return array_diff( $this->getCurrentAssignees( $article, $revision ), $this->taskAssignees );
75
	}
76
77
	/**
78
	 * @param WikiPage $article
79
	 * @param $revision
80
	 * @return array
81
	 */
82
	public function getRemovedAssignees( WikiPage &$article, $revision ) {
83
		return array_diff( $this->taskAssignees, $this->getCurrentAssignees( $article, $revision ) );
84
	}
85
86
	/**
87
	 * Returns an array of assignees based on $query_word
88
	 *
89
	 * @param WikiPage $article
90
	 * @return array
91
	 */
92
	public function getGroupAssignees( WikiPage &$article ) {
93
		global $stgPropertyAssignedToGroup;
94
		global $stgPropertyHasAssignee;
95
96
		$query_word = $stgPropertyAssignedToGroup;
97
		$title_text = $article->getTitle()->getFullText();
98
99
		// Array of assignees to return
100
		$assignee_arr = array();
101
102
		// get the result of the query "[[$title]][[$query_word::+]]"
103
		$properties_to_display = array( $query_word );
104
		$results = Query::getQueryResults( "[[$title_text]][[$query_word::+]]", $properties_to_display,
105
			false );
106
107
		$group_assignees = null;
108
		// In theory, there is only one row
109
		while ( $row = $results->getNext() ) {
110
			$group_assignees = $row[0];
111
		}
112
113
		// If not any row, do nothing
114
		if ( !empty( $group_assignees ) ) {
115
			while ( $group_assignee = $group_assignees->getNextObject() ) {
116
				$group_assignee = $group_assignee->getTitle();
117
				$group_name = $group_assignee->getText();
118
				$query_word = $stgPropertyHasAssignee;
119
				$properties_to_display = array( $query_word );
120
				$results = Query::getQueryResults( "[[$group_name]][[$query_word::+]]", $properties_to_display,
121
					false );
122
123
				$task_assignees = null;
124
				// In theory, there is only one row
125
				while ( $row = $results->getNext() ) {
126
					$task_assignees = $row[0];
127
				}
128
129
				if ( !empty( $task_assignees ) ) {
130
					while ( $task_assignee = $task_assignees->getNextObject() ) {
131
						$assignee_name = $task_assignee->getTitle();
132
						$assignee_name = $assignee_name->getText();
133
						/** @todo Create User object */
134
						$assignee_name = explode( ":", $assignee_name );
135
						$assignee_name = $assignee_name[0];
136
137
						array_push( $assignee_arr, $assignee_name );
138
					}
139
				}
140
			}
141
		}
142
143
		return $assignee_arr;
144
	}
145
146
	/**
147
	 * Get the email addresses of all the assignees
148
	 *
149
	 * @param array $assignees
150
	 * @return array
151
	 */
152
	static public function getAssigneeAddresses( array $assignees ) {
153
		$assignee_arr = array();
154
		foreach ( $assignees as $assignee_name ) {
155
			$assignee = User::newFromName( $assignee_name );
156
			// if assignee is the current user, do nothing
157
			# if ( $assignee->getID() != $user->getID() ) {
158
			if (!$assignee) {
159
				continue;
160
			}
161
			$assignee_mail = new \MailAddress( $assignee->getEmail(), $assignee_name );
162
			array_push( $assignee_arr, $assignee_mail );
163
			# }
164
		}
165
166
		return $assignee_arr;
167
	}
168
169
	/**
170
	 * Returns an array of properties based on $query_word
171
	 *
172
	 * @param string $propertyString The property that designate the users to notify.
173
	 * @param WikiPage $article
174
	 * @param $revision
175
	 * @return array
176
	 */
177
	private function getProperties( $propertyString, $article, $revision ) {
178
		$smwFactory = ApplicationFactory::getInstance();
179
		$mwCollaboratorFactory = $smwFactory->newMwCollaboratorFactory();
180
		if ($revision === null) {
181
			$revision = $article->getRevision();
182
		}
183
		if ($revision === null) {
184
			return [];
185
		}
186
		if ( version_compare( SMW_VERSION, '3.1', '<' ) ) {
187
			$editInfo = $mwCollaboratorFactory->newEditInfoProvider(
188
				$article,
189
				$revision,
190
				null
191
			);
192
		} else {
193
			$editInfo = $mwCollaboratorFactory->newEditInfo(
194
				$article,
195
				$revision,
196
				null
197
			);
198
		}
199
		$editInfo->fetchEditInfo();
200
		$parserOutput = $editInfo->getOutput();
201
202
		if ( !$parserOutput instanceof ParserOutput ) {
0 ignored issues
show
The class ParserOutput does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
203
			return [];
204
		}
205
206
		$propertyStringUnderscores = str_replace( ' ', '_', $propertyString );
207
		$property = new \SMW\DIProperty( $propertyStringUnderscores, false );
208
209
		/** @var $semanticData \SMW\SemanticData */
210
		$semanticData = $parserOutput->getExtensionData( 'smwdata' );
211
		if ( $semanticData === null ) {
212
			return [];
213
		}
214
		$propValues = $semanticData->getPropertyValues( $property );
215
		$valueList = array_map(function( SMWDataItem $propVal ) {
216
			if ($propVal instanceof DIWikiPage) {
217
				return $propVal->getTitle()->getText();
218
			}
219
			return $propVal;
220
		}, $propValues);
221
222
		return $valueList;
223
	}
224
}
225
226