Issues (24)

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.

Zewa/HTTP/Request.php (1 issue)

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
declare(strict_types=1);
3
namespace Zewa\HTTP;
4
5
use Zewa\Dependency;
6
use Zewa\Security;
7
8
/**
9
 * Class Request
10
 * @package Zewa\HTTP
11
 */
12
class Request
13
{
14
    /**
15
     * @var Server
16
     */
17
    public $server;
18
19
    /**
20
     * @var Session
21
     */
22
    public $session;
23
24
    /**
25
     * @var Get
26
     */
27
    public $get;
28
29
    /**
30
     * @var Post
31
     */
32
    public $post;
33
34
    /**
35
     * @var Put
36
     */
37
    public $put;
38
39
    /**
40
     * @var Delete
41
     */
42
    public $delete;
43
44
    /**
45
     * @var File
46
     */
47
    public $file;
48
49
    /**
50
     * @var Cookie
51
     */
52
    public $cookie;
53
54
    /**
55
     * @var
56
     */
57
    private $request;
58
59
    /**
60
     * @var Security
61
     */
62
    private $security;
63
64
    /** @var string */
65
    private $method;
66
67
    /** @var array */
68
    private $params;
69
70
    /** @var  int */
71
    private $statusCode;
0 ignored issues
show
The property $statusCode is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
72
73
    /** @var  string */
74
    private $responseMessage;
75
76 32
    public function __construct(Dependency $dependency, Security $security)
77
    {
78 32
        $this->security = $security;
79
        /** @var Server server */
80 32
        $this->server = $dependency->resolve('\Zewa\HTTP\Server', true);
81
        /** @var Session session */
82 32
        $this->session = $dependency->resolve('\Zewa\HTTP\Session', true);
83
        /** @var Get get */
84 32
        $this->get = $dependency->resolve('\Zewa\HTTP\Get', true);
85
        /** @var Post post */
86 32
        $this->post = $dependency->resolve('\Zewa\HTTP\Post', true);
87
        /** @var Put put */
88 32
        $this->put = $dependency->resolve('\Zewa\HTTP\Put', true);
89
        /** @var Delete delete */
90 32
        $this->delete = $dependency->resolve('\Zewa\HTTP\Delete', true);
91
        /** @var File file */
92 32
        $this->file = $dependency->resolve('\Zewa\HTTP\File', true);
93
        /** @var Cookie cookie */
94 32
        $this->cookie = $dependency->resolve('\Zewa\HTTP\Cookie', true);
95 32
    }
96
97 5
    public function getRequest()
98
    {
99 5
        return $this->request;
100
    }
101
102 5
    public function setRequest($request)
103
    {
104 5
        $this->request = $request;
105 5
    }
106
107 5
    public function getMethod()
108
    {
109 5
        return $this->method;
110
    }
111
112 3
    public function setMethod($method)
113
    {
114 3
        $this->method = $method;
115 3
    }
116
117 5
    public function getParams()
118
    {
119 5
        return $this->params;
120
    }
121
122 5
    public function setParams($params)
123
    {
124 5
        $this->params = $this->security->normalize($params);
125 5
    }
126
127 4
    public function redirect(string $url, int $status = 302)
128
    {
129 4
        $url = str_replace(array('\r', '\n', '%0d', '%0a'), '', $url);
130 4
        if (headers_sent()) {
131 1
            return false;
132
        }
133 3
        session_write_close();
134
135 3
        $this->setStatusCode($status);
136
137 3
        header('HTTP/1.1 ' . $this->responseMessage);
138 3
        $url = preg_replace('!^/*!', '', $url);
139 3
        header("Location: " . $url);
140 3
        return true;
141
    }
142
143 3
    public function setStatusCode(int $status = 302)
144
    {
145
        switch ($status) {
146 3
            case '301':
147 1
                $this->responseMessage = '301 Moved Permanently';
148 1
                break;
149 2
            case '307':
150 1
                $this->responseMessage = '307 Temporary Redirect';
151 1
                break;
152 1
            case '302':
153
            default:
154 1
                $this->responseMessage = '302 Found';
155 1
                break; // temp redirect
156
        }
157 3
    }
158
}
159