Issues (11)

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/Http/HttpHeadersBag.php (1 issue)

Labels
Severity

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
 * This file is a part of Woketo package.
4
 *
5
 * (c) Nekland <[email protected]>
6
 *
7
 * For the full license, take a look to the LICENSE file
8
 * on the root directory of this project
9
 */
10
11
namespace Nekland\Woketo\Http;
12
13
14
/**
15
 * Class HttpHeadersBag
16
 *
17
 * @internal
18
 */
19
class HttpHeadersBag implements \ArrayAccess, \Iterator
20
{
21
    /**
22
     * @var string[]
23
     */
24
    private $headers;
25
26
    /**
27
     * Is used by the iterator feature to store a possible "false" value when the loop over the array is finished.
28
     *
29
     * @var mixed
30
     */
31
    private $next;
32
33 26
    public function __construct(array $headers = null)
34
    {
35 26
        $this->headers = $headers ?: [];
36 26
    }
37
38
    /**
39
     * @param string $name
40
     * @param mixed  $value
41
     * @return self
42
     */
43 3
    public function set(string $name, $value)
44
    {
45 3
        $this->headers[$name] = $value;
46
47 3
        return $this;
48
    }
49
50
    /**
51
     * @param string $name
52
     * @param mixed  $default
53
     * @return mixed
54
     */
55 27
    public function get(string $name, $default = null)
56
    {
57 27
        $headersLower = \array_change_key_case($this->headers);
58 27
        $name = \strtolower($name);
59
60 27
        return isset($headersLower[$name]) ? $headersLower[$name] : $default;
61
    }
62
63
    /**
64
     * @param string $name
65
     * @param mixed  $value
66
     * @return self
67
     */
68 22
    public function add(string $name, $value)
69
    {
70 22
        if (!empty($this->headers[$name])) {
71 2
            if (!\is_array($this->headers[$name])){
72 2
                $this->headers[$name] = [$this->headers[$name]];
73
            }
74 2
            $this->headers[$name][] = $value;
75
        } else {
76 22
            $this->headers[$name] = $value;
77
        }
78
        
79 22
        return $this;
80
    }
81
82
    /**
83
     * @param string $name
84
     */
85
    public function remove(string $name)
86
    {
87
        unset($this->headers[$name]);
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93 10
    public function offsetExists($offset)
94
    {
95 10
        return isset($this->headers[$offset]);
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101 17
    public function offsetGet($offset)
102
    {
103 17
        return $this->get($offset);
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109
    public function offsetSet($offset, $value)
110
    {
111
        throw new \Exception('You must use either add or set method to update the header bag.');
112
    }
113
114
    /**
115
     * {@inheritdoc}
116
     */
117
    public function offsetUnset($offset)
118
    {
119
        $this->remove($offset);
120
    }
121
122 14
    public function current()
123
    {
124 14
        return $this->next ?: \current($this->headers);
125
    }
126
127 14
    public function next()
128
    {
129 14
        $this->next = \next($this->headers);
130 14
    }
131
132 14
    public function key()
133
    {
134 14
        return \key($this->headers);
135
    }
136
137 14
    public function valid()
138
    {
139 14
        return $this->next !== false;
140
    }
141
142 14
    public function rewind()
143
    {
144 14
        $this->current = 0;
0 ignored issues
show
The property current does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
145 14
    }
146
}
147