Issues (24)

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/Hydrator/Assembler.php (4 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
namespace Dgame\Soap\Hydrator;
4
5
use Dgame\Soap\Attribute\Attribute;
6
use Dgame\Soap\Attribute\XmlAttribute;
7
use Dgame\Soap\Element;
8
use Dgame\Soap\Visitor\AttributeVisitorInterface;
9
use Dgame\Soap\Visitor\ElementVisitorInterface;
10
use Dgame\Soap\XmlElement;
11
use Dgame\Soap\XmlNode;
12
use DOMDocument;
13
use DOMElement;
14
use DOMNode;
15
16
/**
17
 * Class Assembler
18
 * @package Dgame\Soap\Hydrator
19
 */
20
final class Assembler implements ElementVisitorInterface, AttributeVisitorInterface
21
{
22
    /**
23
     * @var DOMDocument
24
     */
25
    private $document;
26
    /**
27
     * @var DOMElement
28
     */
29
    private $node;
30
31
    /**
32
     * Assembler constructor.
33
     *
34
     * @param DOMNode|null $node
35
     */
36
    public function __construct(DOMNode $node = null)
37
    {
38
        if ($node === null) {
39
            $this->node = $this->document = new DOMDocument('1.0', 'utf-8');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->document = new \D...ocument('1.0', 'utf-8') of type object<DOMDocument> is incompatible with the declared type object<DOMElement> of property $node.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
40
        } else {
41
            $this->node     = $node;
0 ignored issues
show
Documentation Bug introduced by
$node is of type object<DOMNode>, but the property $node was declared to be of type object<DOMElement>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
42
            $this->document = $node->ownerDocument ?? $this->node;
0 ignored issues
show
Documentation Bug introduced by
It seems like $node->ownerDocument ?? $this->node can also be of type object<DOMNode>. However, the property $document is declared as type object<DOMDocument>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
43
        }
44
    }
45
46
    /**
47
     * @return DOMDocument
48
     */
49
    public function getDocument(): DOMDocument
50
    {
51
        return $this->document;
52
    }
53
54
    /**
55
     * @param Element $element
56
     * @param DOMNode $node
57
     *
58
     * @return DOMNode
59
     */
60
    private function assemble(Element $element, DOMNode $node): DOMNode
61
    {
62
        $this->node->appendChild($node);
63
        $this->node = $node;
0 ignored issues
show
Documentation Bug introduced by
$node is of type object<DOMNode>, but the property $node was declared to be of type object<DOMElement>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
64
65
        foreach ($element->getAttributes() as $attribute) {
66
            $attribute->accept($this);
67
        }
68
69
        return $node;
70
    }
71
72
    /**
73
     * @param Element $element
74
     */
75
    public function visitElement(Element $element)
76
    {
77
        $node = $this->document->createElement($element->getName(), $element->hasValue() ? $element->getValue() : null);
78
        $this->assemble($element, $node);
79
    }
80
81
    /**
82
     * @param XmlElement $element
83
     */
84
    public function visitXmlElement(XmlElement $element)
85
    {
86
        $node = $this->document->createElement($element->getPrefixedName(), $element->hasValue() ? $element->getValue() : null);
87
        $node = $this->assemble($element, $node);
88
        if ($element->hasPrefix()) {
89
            $node->prefix = $element->getPrefix();
90
        }
91
    }
92
93
    /**
94
     * @param XmlNode $node
95
     */
96
    public function visitXmlNode(XmlNode $node)
97
    {
98
        $this->visitXmlElement($node);
99
100
        foreach ($node->getElements() as $child) {
101
            $assembler = new self($this->node);
102
            $child->accept($assembler);
103
        }
104
    }
105
106
    /**
107
     * @param Attribute $attribute
108
     */
109
    public function visitAttribute(Attribute $attribute)
110
    {
111
        $this->node->setAttribute($attribute->getName(), $attribute->hasValue() ? $attribute->getValue() : null);
112
    }
113
114
    /**
115
     * @param XmlAttribute $attribute
116
     */
117
    public function visitXmlAttribute(XmlAttribute $attribute)
118
    {
119
        $this->node->setAttribute($attribute->getPrefixedName(), $attribute->hasValue() ? $attribute->getValue() : null);
120
    }
121
}