Issues (731)

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.

gan_xml2array.php (19 issues)

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
 * @author Niels A.D.
4
 * @author Todd Burry <[email protected]>
5
 * @copyright 2010 Niels A.D., 2014 Todd Burry
6
 * @license http://opensource.org/licenses/LGPL-2.1 LGPL-2.1
7
 * @package pQuery
8
 */
9
10
namespace pQuery;
11
12
/**
13
 * Converts a XML document to an array
14
 */
15
class XML2ArrayParser extends HtmlParserBase {
16
17
	/**
18
	 * Holds the document structure
19
	 * @var array array('name' => 'tag', 'attrs' => array('attr' => 'val'), 'childen' => array())
20
	 */
21
	var $root = array(
0 ignored issues
show
The visibility should be declared for property $root.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
22
		'name' => '',
23
		'attrs' => array(),
24
		'children' => array()
25
	);
26
27
	/**
28
	 * Current parsing hierarchy
29
	 * @var array
30
	 * @access private
31
	 */
32
	var $hierarchy = array();
0 ignored issues
show
The visibility should be declared for property $hierarchy.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
33
34
	protected function parse_hierarchy($self_close) {
35
		if ($this->status['closing_tag']) {
0 ignored issues
show
The property status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
36
			$found = false;
37
			for ($count = count($this->hierarchy), $i = $count - 1; $i >= 0; $i--) {
38
				if (strcasecmp($this->hierarchy[$i]['name'], $this->status['tag_name']) === 0) {
0 ignored issues
show
The property status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
39
40
					for($ii = ($count - $i - 1); $ii >= 0; $ii--) {
41
						$e = array_pop($this->hierarchy);
42
						if ($ii > 0) {
43
							$this->addError('Closing tag "'.$this->status['tag_name'].'" while "'.$e['name'].'" is not closed yet');
0 ignored issues
show
The property status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
44
						}
45
					}
46
47
					$found = true;
48
					break;
49
				}
50
			}
51
52
			if (!$found) {
53
				$this->addError('Closing tag "'.$this->status['tag_name'].'" which is not open');
0 ignored issues
show
The property status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
54
			}
55
		} else {
56
			$tag = array(
57
				'name' => $this->status['tag_name'],
0 ignored issues
show
The property status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
58
				'attrs' => $this->status['attributes'],
0 ignored issues
show
The property status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
59
				'children' => array()
60
			);
61
			if ($this->hierarchy) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->hierarchy 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...
62
				$current =& $this->hierarchy[count($this->hierarchy) - 1];
63
				$current['children'][] = $tag;
64
				$tag =& $current['children'][count($current['children']) - 1];
65
				unset($current['tagData']);
66
			} else {
67
				$this->root = $tag;
68
				$tag =& $this->root;
69
				$self_close = false;
70
			}
71
			if (!$self_close) {
72
				$this->hierarchy[] =& $tag;
73
			}
74
		}
75
	}
76
77
	function parse_tag_default() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
78
		if (!parent::parse_tag_default()) {return false;}
79
80
		if ($this->status['tag_name'][0] !== '?') {
0 ignored issues
show
The property status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
81
			$this->parse_hierarchy(($this->status['self_close']) ? true : null);
0 ignored issues
show
The property status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
82
		}
83
		return true;
84
	}
85
86
	function parse_text() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
87
		parent::parse_text();
88
		if (($this->status['text'] !== '') && $this->hierarchy) {
0 ignored issues
show
The property status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
Bug Best Practice introduced by
The expression $this->hierarchy 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...
89
			$current =& $this->hierarchy[count($this->hierarchy) - 1];
90
			if (!$current['children']) {
91
				$current['tagData'] = $this->status['text'];
0 ignored issues
show
The property status cannot be accessed from this context as it is declared private in class pQuery\HtmlParserBase.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
92
			}
93
		}
94
	}
95
96
	function parse_all() {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
97
		return ((parent::parse_all()) ? $this->root : false);
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::parse_all() ? $this->root : false; of type array|false adds the type array to the return on line 97 which is incompatible with the return type of the parent method pQuery\HtmlParserBase::parse_all of type boolean.
Loading history...
98
	}
99
}
100
101
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...