Issues (1507)

Security Analysis    not enabled

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.

PHPDaemon/XMLStream/XMLStreamObject.php (6 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
namespace PHPDaemon\XMLStream;
3
4
class XMLStreamObject
5
{
6
    use \PHPDaemon\Traits\ClassWatchdog;
7
    use \PHPDaemon\Traits\StaticObjectWatchdog;
8
9
    /**
10
     * Tag name
11
     *
12
     * @var string
13
     */
14
    public $name;
15
16
    /**
17
     * Namespace
18
     *
19
     * @var string
20
     */
21
    public $ns;
22
23
    /**
24
     * Attributes
25
     *
26
     * @var array
27
     */
28
    public $attrs = [];
29
30
    /**
31
     * Subs?
32
     *
33
     * @var array
34
     */
35
    public $subs = [];
36
37
    /**
38
     * Node data
39
     *
40
     * @var string
41
     */
42
    public $data = '';
43
44
    /**
45
     * Constructor
46
     *
47
     * @param string $name
48
     * @param string $ns
49
     * @param array $attrs
50
     * @param string $data
51
     */
52
    public function __construct($name, $ns = '', $attrs = [], $data = '')
53
    {
54
        $this->name = strtolower($name);
55
        $this->ns = $ns;
56
        if (is_array($attrs) && count($attrs)) {
57
            foreach ($attrs as $key => $value) {
58
                $this->attrs[strtolower($key)] = $value;
59
            }
60
        }
61
        $this->data = $data;
62
    }
63
64
    /**
65
     * Dump this XML Object to output.
66
     *
67
     * @param integer $depth
68
     */
69
    public function printObj($depth = 0)
70
    {
71
        $s = str_repeat("\t", $depth) . $this->name . " " . $this->ns . ' ' . $this->data . "\n";
72
        foreach ($this->subs as $sub) {
73
            $s .= $sub->printObj($depth + 1);
74
        }
75
        return $s;
76
    }
77
78
    /**
79
     * Return this XML Object in xml notation
80
     *
81
     * @param string $str
82
     */
83
    public function toString($str = '')
84
    {
85
        $str .= "<{$this->name} xmlns='{$this->ns}' ";
86
        foreach ($this->attrs as $key => $value) {
87
            if ($key !== 'xmlns') {
88
                $value = htmlspecialchars($value);
89
                $str .= "$key='$value' ";
90
            }
91
        }
92
        $str .= ">";
93
        foreach ($this->subs as $sub) {
94
            $str .= $sub->toString();
95
        }
96
        $body = htmlspecialchars($this->data);
97
        $str .= "$body</{$this->name}>";
98
        return $str;
99
    }
100
101
    /**
102
     * Has this XML Object the given sub?
103
     *
104
     * @param string $name
105
     * @return boolean
106
     */
107 View Code Duplication
    public function hasSub($name, $ns = null)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
108
    {
109
        foreach ($this->subs as $sub) {
110
            if (($name === "*" or $sub->name === $name) and ($ns === null or $sub->ns === $ns)) {
111
                return true;
112
            }
113
        }
114
        return false;
115
    }
116
117
    /**
118
     * Return a sub
119
     *
120
     * @param string $name
121
     * @param string $attrs
0 ignored issues
show
Should the type for parameter $attrs not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
122
     * @param string $ns
0 ignored issues
show
Should the type for parameter $ns not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
123
     */
124 View Code Duplication
    public function sub($name, $attrs = null, $ns = null)
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
The parameter $attrs is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
125
    {
126
        //@TODO: attrs is ignored
127
        foreach ($this->subs as $sub) {
128
            if ($sub->name === $name and ($ns === null or $sub->ns === $ns)) {
129
                return $sub;
130
            }
131
        }
132
        return null;
133
    }
134
}
135