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/classes/ElggXMLElement.php (8 issues)

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
 * A parser for XML that uses SimpleXMLElement
4
 *
5
 * @package    Elgg.Core
6
 * @subpackage XML
7
 */
8
class ElggXMLElement {
9
	/**
10
	 * @var SimpleXMLElement
11
	 */
12
	private $_element;
13
14
	/**
15
	 * Creates an \ElggXMLParser from a string or existing SimpleXMLElement
16
	 * 
17
	 * @param string|SimpleXMLElement $xml The XML to parse
18
	 */
19
	public function __construct($xml) {
20
		if ($xml instanceof SimpleXMLElement) {
21
			$this->_element = $xml;
22
		} else {
23
			// do not load entities
24
			$disable_load_entities = libxml_disable_entity_loader(true);
25
26
			$this->_element = new SimpleXMLElement($xml);
27
28
			libxml_disable_entity_loader($disable_load_entities);
29
		}
30
	}
31
32
	/**
33
	 * @return string The name of the element
34
	 */
35
	public function getName() {
36
		return $this->_element->getName();
37
	}
38
39
	/**
40
	 * @return string[] The attributes
41
	 */
42
	public function getAttributes() {
43
		//include namespace declarations as attributes
44
		$xmlnsRaw = $this->_element->getNamespaces();
45
		$xmlns = array();
46
		foreach ($xmlnsRaw as $key => $val) {
47
			$label = 'xmlns' . ($key ? ":$key" : $key);
48
			$xmlns[$label] = $val;
49
		}
50
		//get attributes and merge with namespaces
51
		$attrRaw = $this->_element->attributes();
52
		$attr = array();
53
		foreach ($attrRaw as $key => $val) {
54
			$attr[$key] = $val;
55
		}
56
		$attr = array_merge((array) $xmlns, (array) $attr);
57
		$result = array();
58
		foreach ($attr as $key => $val) {
59
			$result[$key] = (string) $val;
60
		}
61
		return $result;
62
	}
63
64
	/**
65
	 * @return string CData
66
	 */
67
	public function getContent() {
68
		return (string) $this->_element;
69
	}
70
71
	/**
72
	 * @return \ElggXMLElement[] Child elements
73
	 */
74
	public function getChildren() {
75
		$children = $this->_element->children();
76
		$result = array();
77
		foreach ($children as $val) {
78
			$result[] = new \ElggXMLElement($val);
79
		}
80
81
		return $result;
82
	}
83
84
	/**
85
	 * Override ->
86
	 * 
87
	 * @param string $name Property name
88
	 * @return mixed
89
	 */
90
	public function __get($name) {
91
		switch ($name) {
92
			case 'name':
93
				return $this->getName();
94
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
95
			case 'attributes':
96
				return $this->getAttributes();
97
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
98
			case 'content':
99
				return $this->getContent();
100
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
101
			case 'children':
102
				return $this->getChildren();
103
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
104
		}
105
		return null;
106
	}
107
108
	/**
109
	 * Override isset
110
	 * 
111
	 * @param string $name Property name
112
	 * @return boolean
113
	 */
114
	public function __isset($name) {
115
		switch ($name) {
116
			case 'name':
117
				return $this->getName() !== null;
118
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
119
			case 'attributes':
120
				return $this->getAttributes() !== null;
121
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
122
			case 'content':
123
				return $this->getContent() !== null;
124
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
125
			case 'children':
126
				return $this->getChildren() !== null;
127
				break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
128
		}
129
		return false;
130
	}
131
}
132