Issues (57)

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.

src/WebinoDraw/Dom/Element.php (1 issue)

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
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
6
 * @copyright   Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoDraw\Dom;
12
13
use DOMElement;
14
use DOMNode;
15
use DOMText;
16
17
/**
18
 * Class Element
19
 *
20
 * Extended DOMElement
21
 *
22
 * @method $this appendChild(DOMNode $newnode)
23
 */
24
class Element extends DOMElement implements
25
    NodeInterface,
26
    Locator\LocatorAwareInterface
27
{
28
    use NodeTrait;
29
    use Locator\LocatorAwareTrait;
30
31
    const NODE_NAME_PROPERTY  = 'nodeName';
32
    const NODE_PATH_PROPERTY  = 'nodePath';
33
34
    /**
35
     * @param string $locator CSS selector or XPath (xpath=)
36
     * @return NodeList
37
     */
38
    public function query($locator)
39
    {
40
        return new NodeList($this->getLocator(), $this->getLocator()->locate($this, $locator));
41
    }
42
43
    /**
44
     * Attributes mass assignment
45
     *
46
     * @param array $attribs
47
     * @param callable $callback Called on each attribute value
48
     * @return self
49
     */
50
    public function setAttributes(array $attribs, $callback = null)
51
    {
52
        foreach ($attribs as $name => $value) {
53
54
            is_callable($callback)
55
                and $value = $callback($value, $name);
56
57
            if (empty($value) && !is_numeric($value)) {
58
                $this->removeAttribute($name);
59
            } else {
60
                $this->setAttribute($name, trim($value));
61
            }
62
        }
63
64
        return $this;
65
    }
66
67
    /**
68
     * Returns the node body html
69
     *
70
     * @return string
71
     */
72
    public function getInnerHtml()
73
    {
74
        if (null === $this->childNodes) {
75
            return '';
76
        }
77
78
        $innerHtml = '';
79
        foreach ($this->childNodes as $child) {
80
            $childHtml = $child->ownerDocument->saveXML($child);
81
            empty($childHtml) or $innerHtml .= $childHtml;
82
        }
83
        return $innerHtml;
84
    }
85
86
    /**
87
     * Returns the node html
88
     *
89
     * @return string
90
     */
91
    public function getOuterHtml()
92
    {
93
        return trim($this->ownerDocument->saveXML($this));
94
    }
95
96
    /**
97
     * Returns the node text value and attributes in the array
98
     *
99
     * @param string $prefix
100
     * @return array
101
     */
102
    public function getProperties($prefix = null)
103
    {
104
        $properties = [
105
            $prefix . $this::NODE_NAME_PROPERTY  => empty($this->nodeName)  ? '' : $this->nodeName,
106
            $prefix . $this::NODE_VALUE_PROPERTY => empty($this->nodeValue) ? '' : $this->nodeValue,
107
            $prefix . $this::NODE_PATH_PROPERTY  => empty($this->nodeName)  ? '' : $this->getNodePath(),
108
        ];
109
110
        if (!empty($this->attributes)) {
111
            foreach ($this->attributes as $attr) {
112
                $properties[$prefix . $attr->name] = $attr->value;
113
            }
114
        }
115
116
        return $properties;
117
    }
118
119
    /**
120
     * @return bool
121
     */
122
    public function isEmpty()
123
    {
124
        $nodeValue = trim($this->nodeValue);
125
126
        if (!empty($nodeValue) || is_numeric($nodeValue)) {
127
            return false;
128
        }
129
130
        // node value is empty,
131
        // check for children other than text
132
        foreach ($this->childNodes as $childNode) {
133
            if (!($childNode instanceof DOMText)) {
134
                return false;
135
            }
136
        }
137
138
        return true;
139
    }
140
141
    /**
142
     * @param string $source
143
     * @return $this
144
     */
145
    public function appendHtml($source)
146
    {
147
        $errors = libxml_use_internal_errors();
148
        libxml_use_internal_errors(true);
149
150
        // from fragment
151
        $frag = $this->ownerDocument->createDocumentFragment();
152
        $frag->appendXml($source);
153
154
        if ($frag->hasChildNodes()) {
155
            $this->appendChild($frag);
156
            libxml_use_internal_errors($errors);
157
            return $this;
158
        }
159
160
        // from document fallback
161
        $dom = new Document;
162
        $dom->loadHTML($source, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
0 ignored issues
show
LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD is of type integer, but the function expects a array|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
163
        $elm = $this->ownerDocument->importNode($dom->getDocumentElement(), true);
164
        $this->appendChild($elm);
165
166
        libxml_use_internal_errors($errors);
167
        return $this;
168
    }
169
}
170