Issues (125)

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/svg/xml/DOMNode.php (12 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 nstdio\svg\xml;
3
4
use nstdio\svg\util\KeyValueWriter;
5
use nstdio\svg\XMLDocumentInterface;
6
7
/**
8
 * Class DOMNode
9
 *
10
 * @package nstdio\svg\xml
11
 * @author  Edgar Asatryan <[email protected]>
12
 */
13
abstract class DOMNode implements XMLDocumentInterface
14
{
15
    /**
16
     * @inheritdoc
17
     */
18
    abstract public function setNodeValue($value);
19
20
    /**
21
     * @inheritdoc
22
     */
23
    abstract public function getNodeValue();
24
25
    /**
26
     * @inheritdoc
27
     */
28 9
    public function attributes(array $except = [])
29
    {
30 9
        return KeyValueWriter::allAttributes($this->getElement(), $except);
0 ignored issues
show
It seems like $this->getElement() targeting nstdio\svg\xml\DOMNode::getElement() can also be of type object<nstdio\svg\XMLDocumentInterface>; however, nstdio\svg\util\KeyValueWriter::allAttributes() does only seem to accept object<DOMNode>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    abstract public function getElement();
37
38
    /**
39
     * @inheritdoc
40
     */
41 150
    public function setAttribute($name, $value = null)
42
    {
43 150
        $this->getElement()->setAttribute($name, $value);
0 ignored issues
show
The method setAttribute does only exist in DOMElement and nstdio\svg\XMLDocumentInterface, but not in DOMDocument.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
44 150
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49 109
    public function getAttribute($name)
50
    {
51 109
        return $this->getElement()->getAttribute($name);
0 ignored issues
show
The method getAttribute does only exist in DOMElement and nstdio\svg\XMLDocumentInterface, but not in DOMDocument.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
52
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57 150
    public function setAttributeNS($namespaceURI, $qualifiedName, $value)
58
    {
59 150
        $this->getElement()->setAttributeNS($namespaceURI, $qualifiedName, $value);
0 ignored issues
show
The method setAttributeNS does only exist in DOMElement and nstdio\svg\XMLDocumentInterface, but not in DOMDocument.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
60 150
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65 81
    public function getAttributeNS($namespaceURI, $localName)
66
    {
67 81
        return $this->getElement()->getAttributeNS($namespaceURI, $localName);
0 ignored issues
show
The method getAttributeNS does only exist in DOMElement and nstdio\svg\XMLDocumentInterface, but not in DOMDocument.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
68
    }
69
70 150
    public function appendChild(XMLDocumentInterface $newNode)
71
    {
72 150
        $this->getElement()->appendChild($newNode->getElement());
0 ignored issues
show
It seems like $newNode->getElement() targeting nstdio\svg\XMLDocumentInterface::getElement() can also be of type object<DOMDocument> or object<DOMElement>; however, nstdio\svg\XMLDocumentInterface::appendChild() does only seem to accept object<nstdio\svg\XMLDocumentInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
73 150
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78 150
    public function createElement($name, $value = null)
79
    {
80
        // on PHP 5.4.* createElement method with null parameter will create empty DOMText object as child of created element
81 150
        $element = $value === null ? $this->getElement()->createElement($name) : $this->getElement()->createElement($name, $value);
0 ignored issues
show
The method createElement does only exist in DOMDocument and nstdio\svg\XMLDocumentInterface, but not in DOMElement.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
82
83 150
        return new DOMElementWrapper($element);
84
    }
85
86
    /**
87
     * @inheritdoc
88
     */
89
    public function createElementNS($namespaceURI, $qualifiedName, $value = null)
90
    {
91
        return $this->getElement()->createElementNS($namespaceURI, $qualifiedName, $value);
0 ignored issues
show
The method createElementNS does only exist in DOMDocument and nstdio\svg\XMLDocumentInterface, but not in DOMElement.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
92
    }
93
94
    /**
95
     * @inheritdoc
96
     */
97 9
    public function removeNode(XMLDocumentInterface $child)
98
    {
99 9
        return $this->getElement()->removeChild($child->getElement());
0 ignored issues
show
The method removeChild does only exist in DOMDocument and DOMElement, but not in nstdio\svg\XMLDocumentInterface.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
100
    }
101
102
    /**
103
     * @inheritdoc
104
     */
105 61
    public function saveHTML()
106
    {
107 61
        return $this->getElement()->saveHTML();
0 ignored issues
show
The method saveHTML does only exist in DOMDocument and nstdio\svg\XMLDocumentInterface, but not in DOMElement.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
108
    }
109
110 2
    public function saveXML($formatOutput)
111
    {
112 2
        return $this->getElement()->saveXML();
0 ignored issues
show
The call to saveXML() misses a required argument $formatOutput.

This check looks for function calls that miss required arguments.

Loading history...
The method saveXML does only exist in DOMDocument and nstdio\svg\XMLDocumentInterface, but not in DOMElement.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
113
    }
114
115
    /**
116
     * @inheritdoc
117
     */
118 150
    public static function isLoaded()
119
    {
120 150
        return extension_loaded('dom');
121
    }
122
123
    public function __debugInfo()
124
    {
125
        return [
126
            'nodeName' => $this->getElement()->nodeName,
127
        ];
128
    }
129
}