Issues (127)

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.

app/Containers/Debugger/Values/Output.php (5 issues)

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 App\Containers\Debugger\Values;
4
5
use App\Ship\Parents\Values\Value;
6
use Illuminate\Support\Facades\Config;
7
use Jenssegers\Agent\Facades\Agent;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Response;
10
11
/**
12
 * Class Output
13
 *
14
 * @author  Mahmoud Zalt  <[email protected]>
15
 */
16
class Output extends Value
17
{
18
19
    /**
20
     * @var  string
21
     */
22
    public $output = '';
23
24
    /**
25
     * @var
26
     */
27
    private $request;
28
29
    /**
30
     * @var
31
     */
32
    private $response;
33
34
    /**
35
     * @var
36
     */
37
    protected $responseDataCut;
38
39
    /**
40
     * @var
41
     */
42
    protected $tokenDataCut;
43
44
    /**
45
     * Output constructor.
46
     *
47
     * @param \Symfony\Component\HttpFoundation\Request  $request
48
     * @param \Symfony\Component\HttpFoundation\Response $response
49
     */
50
    public function __construct(Request $request, Response $response)
0 ignored issues
show
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
51
    {
52
        $this->request = $request;
53
        $this->response = $response;
54
55
        $this->responseDataCut = Config::get("debugger.requests.response_show_first");
56
        $this->tokenDataCut = Config::get("debugger.requests.token_show_first");
57
    }
58
59
    /**
60
     * @param $text
61
     *
62
     * @return  string
63
     */
64
    protected function set($text)
65
    {
66
        return $this->output = $text;
67
    }
68
69
    /**
70
     * @return  string
71
     */
72
    public function get()
73
    {
74
        return $this->output;
75
    }
76
77
    /**
78
     * @void
79
     */
80
    public function clear()
81
    {
82
        $this->set('');
83
    }
84
85
    /**
86
     * Add header
87
     *
88
     * @param $name
89
     */
90
    public function header($name)
91
    {
92
        $this->append("$name: \n");
93
    }
94
95
    /**
96
     * Add line to indicate new request
97
     *
98
     * @void
99
     */
100
    public function newRequest()
101
    {
102
        $this->append("----------------- NEW REQUEST -----------------");
103
    }
104
105
    /**
106
     * Add empty line
107
     *
108
     * @void
109
     */
110
    public function spaceLine()
111
    {
112
        $this->append("\n \n");
113
    }
114
115
    /**
116
     * @void
117
     */
118
    public function endpoint()
119
    {
120
        $this->append(" * Endpoint: " . $this->request->fullUrl() . "\n");
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class Symfony\Component\HttpFoundation\Request as the method fullUrl() does only exist in the following sub-classes of Symfony\Component\HttpFoundation\Request: Illuminate\Foundation\Http\FormRequest, Illuminate\Http\Request. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
121
        $this->append(" * Method: " . $this->request->getMethod() . "\n");
122
    }
123
124
    /**
125
     * @void
126
     */
127
    public function version()
128
    {
129
        if (method_exists($this->request, 'version')) {
130
            $this->append(" * Version: " . $this->request->version() . "\n");
131
        }
132
    }
133
134
    /**
135
     * @void
136
     */
137
    public function ip()
138
    {
139
        $this->append(" * IP: " . $this->request->ip() . " (Port: " . $this->request->getPort() . ") \n");
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class Symfony\Component\HttpFoundation\Request as the method ip() does only exist in the following sub-classes of Symfony\Component\HttpFoundation\Request: Illuminate\Foundation\Http\FormRequest, Illuminate\Http\Request. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
140
    }
141
142
    /**
143
     * @void
144
     */
145
    public function format()
146
    {
147
        $this->append(" * Format: " . $this->request->format() . "\n");
148
    }
149
150
    /**
151
     * @void
152
     */
153
    public function userInfo()
154
    {
155
        // Auth Header
156
        $authHeader = $this->request->header("Authorization");
157
        // User
158
        $user = $this->request->user() ? "ID: " . $this->request->user()->id . " (Name: " . $this->request->user()->name . ")" : "N/A";
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class Symfony\Component\HttpFoundation\Request as the method user() does only exist in the following sub-classes of Symfony\Component\HttpFoundation\Request: Illuminate\Foundation\Http\FormRequest, Illuminate\Http\Request. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
159
        // Browser
160
        $browser = Agent::browser();
161
162
        $this->append(" * Access Token: " . substr($authHeader, 0,
163
                $this->tokenDataCut) . (!is_null($authHeader) ? "..." : "N/A") . "\n");
164
        $this->append(" * User: " . $user . "\n");
165
        $this->append(" * Device: " . Agent::device() . " (Platform: " . Agent::platform() . ") \n");
166
        $this->append(" * Browser: " . $browser . " (Version: " . Agent::version($browser) . ") \n");
167
        $this->append(" * Languages: " . implode(", ", Agent::languages()) . "\n");
168
    }
169
170
    /**
171
     * @void
172
     */
173
    public function requestData()
174
    {
175
        // Request Data
176
        $requestData = $this->request->all() ? http_build_query($this->request->all(), "", " + ") : "N/A";
0 ignored issues
show
It seems like you code against a specific sub-type and not the parent class Symfony\Component\HttpFoundation\Request as the method all() does only exist in the following sub-classes of Symfony\Component\HttpFoundation\Request: Illuminate\Foundation\Http\FormRequest, Illuminate\Http\Request. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
177
178
        $this->append(" * " . $requestData . "\n");
179
    }
180
181
    /**
182
     * @void
183
     */
184
    public function responseData()
185
    {
186
        // Response Data
187
        $responseContent = ($this->response && method_exists($this->response,
188
                "content")) ? $this->response->content() : "N/A";
189
190
        $this->append(" * " . substr($responseContent, 0, $this->responseDataCut) . "..." . "\n");
191
    }
192
193
    /**
194
     * @param $output
195
     *
196
     * @return  string
197
     */
198
    private function append($output)
199
    {
200
        return $this->output .= $output;
201
    }
202
203
}
204