Issues (142)

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.

lib/ConfigToken/TreeCompiler/Xref.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
namespace ConfigToken\TreeCompiler;
4
5
use ConfigToken\TreeCompiler\XrefResolver\XrefResolverFactory;
6
7
8
class Xref
9
{
10
    /** @var string */
11
    protected $type;
12
13
    /** @var string */
14
    protected $location;
15
16
    /** @var string */
17
    protected $contentType;
18
19
    /** @var array */
20
    protected $data;
21
22
    /** @var boolean */
23
    protected $resolved = false;
24
25
26 7
    public function __construct($type, $location)
27
    {
28 7
        $this->setType($type);
29 7
        $this->setLocation($location);
30 7
    }
31
32
    /**
33
     * Get the type and location from the definition string.
34
     *
35
     * @param string $typeAndLocation
36
     * @param string $delimiter
37
     * @return array Type and Location.
38
     * @throws \Exception
39
     */
40 1
    public static function parseDefinitionString($typeAndLocation, $delimiter)
41
    {
42 1
        $k = strpos($typeAndLocation, $delimiter);
43 1
        if ($k === false) {
44
            throw new \Exception(sprintf('Missing Xref type in "%s".', $typeAndLocation));
45
        }
46 1
        return array(substr($typeAndLocation, 0, $k), substr($typeAndLocation, $k + 1));
47
    }
48
49
    /**
50
     * Get the id from the definition string.
51
     *
52
     * @param string $typeAndLocation
53
     * @param string $delimiter
54
     * @return string
55
     * @throws \Exception
56
     */
57
    public static function getIdFromDefinitionString($typeAndLocation, $delimiter)
58
    {
59
        list($type, $location) = static::parseDefinitionString($typeAndLocation, $delimiter);
60
        return static::computeId($type, $location);
61
    }
62
63
    /**
64
     * Create Xref instance based on the given definition string.
65
     *
66
     * @param string $typeAndLocation
67
     * @param string $delimiter
68
     * @return Xref
69
     * @throws \Exception
70
     */
71
    public static function makeFromDefinitionString($typeAndLocation, $delimiter)
72
    {
73
        list($type, $location) = static::parseDefinitionString($typeAndLocation, $delimiter);
74
        $xref = new static($type, $location);
75
        return $xref;
76
    }
77
78 7
    public function isResolved()
79
    {
80 7
        return $this->resolved;
81
    }
82
83 7
    public function setResolved($value)
84
    {
85 7
        $this->resolved = $value;
86
87 7
        return $this;
88
    }
89
90 7
    public function getResolver()
91
    {
92 7
        return XrefResolverFactory::getByType($this->type);
93
    }
94
95 7
    public function resolve($force = false)
96
    {
97 7
        if ($this->isResolved() && (!$force)) {
98 7
            return;
99
        }
100
        if (!$this->hasType()) {
101
            throw new \Exception('Unable to resolve Xref without type.');
102
        }
103
        $resolver = $this->getResolver();
104
        $resolver::resolve($this, $force);
105
    }
106
107
    public function hasType()
108
    {
109
        return isset($this->type);
110
    }
111
112
    public function getType()
113
    {
114
        return $this->type;
115
    }
116
117 7
    public function setType($value)
118
    {
119 7
        $this->type = $value;
120
121 7
        return $this;
122
    }
123
124
    public function hasLocation()
125
    {
126
        return isset($this->location);
127
    }
128
129
    public function getLocation()
130
    {
131
        return $this->location;
132
    }
133
134 7
    public static function computeAbsoluteLocation($xrefType, $xrefLocation, $xrefPath)
135
    {
136 7
        $resolver = XrefResolverFactory::getByType($xrefType);
137 7
        return $resolver::getAbsoluteLocation($xrefLocation, $xrefPath);
138
    }
139
140 7
    public static function computeId($type, $location)
141
    {
142 7
        return md5($type . $location);
143
    }
144
145 7
    public function getId()
146
    {
147 7
        return static::computeId($this->type, $this->location);
148
    }
149
150 7
    public function setLocation($value)
151
    {
152 7
        if (isset($value)) {
153 7
            $resolver = $this->getResolver();
154 7
            if (isset($resolver)) {
155 7
                $value = $resolver->getPlatformSpecificLocation($value);
156 7
            }
157 7
        }
158 7
        $this->location = $value;
159
160 7
        return $this;
161
    }
162
163
    public function hasContentType()
164
    {
165
        return isset($this->contentType);
166
    }
167
168
    public function getContentType()
169
    {
170
        return $this->contentType;
171
    }
172
173
    public function setContentType($value)
174
    {
175
        $this->contentType = $value;
176
        return $this;
177
    }
178
179
    public function hasData()
180
    {
181
        return isset($this->data);
182
    }
183
184 7
    public function getData()
185
    {
186 7
        return $this->data;
187
    }
188
189 7
    public function setData($value)
190
    {
191 7
        $this->data = $value;
192
193 7
        return $this;
194
    }
195
196
    function __toString()
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...
197
    {
198
        return $this->getId() . ':' . $this->getType() . ':' . $this->getLocation();
199
    }
200
201
202
}