Issues (34)

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/Common/Protocol/Spike.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
/*
4
 * This file is part of the slince/spike package.
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Spike\Common\Protocol;
13
14
use Spike\Common\Exception\BadRequestException;
15
16
class Spike implements SpikeInterface
17
{
18
    /**
19
     * The action.
20
     *
21
     * @var string
22
     */
23
    protected $action;
24
25
    /**
26
     * Array of custom headers.
27
     *
28
     * @var array
29
     */
30
    protected $headers = [];
31
32
    /**
33
     * @var mixed
34
     */
35
    protected $body;
36
37
    /**
38
     * The global headers.
39
     *
40
     * @var array
41
     */
42
    protected static $globalHeaders = [];
43
44
    /**
45
     * Spike constructor.
46
     *
47
     * @param string $action
48
     * @param mixed  $body
49
     * @param array  $headers
50
     */
51
    public function __construct($action, $body = null, $headers = [])
52
    {
53
        $this->action = $action;
54
        $this->body = $body;
55
        $this->headers = $headers;
56
    }
57
58
    public function __toString()
59
    {
60
        return $this->toString();
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function setAction($action)
67
    {
68
        $this->action = $action;
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function getAction()
75
    {
76
        return $this->action;
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function setHeaders(array $headers)
83
    {
84
        $this->headers = $headers;
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function getHeaders()
91
    {
92
        return $this->headers;
93
    }
94
95
    /**
96
     * {@inheritdoc}
97
     */
98
    public function setHeader($name, $value)
99
    {
100
        $this->headers[$name] = $value;
101
    }
102
103
    /**
104
     * {@inheritdoc}
105
     */
106
    public function getHeader($name)
107
    {
108
        return isset($this->headers[$name]) ? $this->headers[$name] : null;
109
    }
110
111
    /**
112
     * {@inheritdoc}
113
     */
114
    public function toString()
115
    {
116
        $data = [
117
            'action' => $this->action,
118
            'headers' => array_merge($this->headers, static::$globalHeaders),
119
            'body' => $this->body,
120
        ];
121
122
        return (string)json_encode($data);
123
    }
124
125
    /**
126
     * {@inheritdoc}
127
     */
128
    public function setBody($body)
129
    {
130
        $this->body = $body;
131
    }
132
133
    /**
134
     * {@inheritdoc}
135
     */
136
    public function getBody()
137
    {
138
        return $this->body;
139
    }
140
141
    /**
142
     * {@inheritdoc}
143
     */
144
    public static function fromString($string)
145
    {
146
        $parsed = json_decode($string, true);
147
        if (json_last_error() || !isset($headers['action'])) {
0 ignored issues
show
The variable $headers seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
148
            throw new BadRequestException('Bad spike protocol message"');
149
        }
150
151
        return new static($parsed['action'], $parsed['body'], $parsed['headers']);
152
    }
153
154
    /**
155
     * {@inheritdoc}
156
     */
157
    public static function fromArray($array)
158
    {
159
        if (!isset($array['action'])) {
160
            throw new BadRequestException('Bad spike protocol message"');
161
        }
162
163
        return new static($array['action'], $array['body'], $array['headers']);
164
    }
165
166
    /**
167
     * Sets a global header.
168
     *
169
     * @param string $name
170
     * @param string $value
171
     */
172
    public static function setGlobalHeader($name, $value)
173
    {
174
        static::$globalHeaders[$name] = $value;
175
    }
176
}