Issues (13)

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/Middleware/RenderBar.php (4 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 Recca0120\LaravelTracy\Middleware;
4
5
use Illuminate\Contracts\Events\Dispatcher;
6
use Illuminate\Http\Request;
7
use Recca0120\LaravelTracy\DebuggerManager;
8
use Recca0120\LaravelTracy\Events\BeforeBarRender;
9
use Symfony\Component\HttpFoundation\BinaryFileResponse;
10
use Symfony\Component\HttpFoundation\RedirectResponse;
11
use Symfony\Component\HttpFoundation\Response;
12
use Symfony\Component\HttpFoundation\StreamedResponse;
13
14
class RenderBar
15
{
16
    /**
17
     * $debuggerManager.
18
     *
19
     * @var \Recca0120\LaravelTracy\DebuggerManager
20
     */
21
    protected $debuggerManager;
22
23
    /**
24
     * $events.
25
     *
26
     * @var \Illuminate\Contracts\Events\Dispatcher
27
     */
28
    protected $events;
29
30
    /**
31
     * __construct.
32
     *
33
     *
34
     * @param \Recca0120\LaravelTracy\DebuggerManager $debuggerManager
35
     * @param \Illuminate\Contracts\Events\Dispatcher $events
36
     */
37 9
    public function __construct(DebuggerManager $debuggerManager, Dispatcher $events)
38
    {
39 9
        $this->debuggerManager = $debuggerManager;
40 9
        $this->events = $events;
41 9
    }
42
43
    /**
44
     * handle.
45
     *
46
     * @param \Illuminate\Http\Request $request
47
     * @param \Closure $next
48
     * @return \Symfony\Component\HttpFoundation\Response
49
     */
50 9
    public function handle($request, $next)
51
    {
52 9
        return $request->has('_tracy_bar') === true
53 1
            ? $this->keepFlashSession($request, $next)
54 9
            : $this->render($request, $next);
55
    }
56
57
    /**
58
     * keepFlashSession.
59
     *
60
     * @param \Illuminate\Http\Request $request
61
     * @param \Closure $next
62
     * @return \Symfony\Component\HttpFoundation\Response
63
     */
64 1
    protected function keepFlashSession($request, $next)
65
    {
66 1
        $type = $request->get('_tracy_bar');
67 1
        if ($request->hasSession() === true && in_array($type, ['js', 'css'], true) === false) {
68 1
            $request->session()->reflash();
69
        }
70
71 1
        return $next($request);
72
    }
73
74
    /**
75
     * render.
76
     *
77
     * @param \Illuminate\Http\Request $request
78
     * @param \Closure $next
79
     * @return \Symfony\Component\HttpFoundation\Response
80
     */
81 8
    protected function render($request, $next)
82
    {
83 8
        $this->debuggerManager->dispatch();
84
85 8
        $response = $next($request);
86
87 8
        $ajax = $request->ajax();
88
89 8
        if ($this->reject($response, $request, $ajax) === true) {
90 4
            return $response;
91
        }
92
93 4
        $method = method_exists($this->events, 'dispatch') ? 'dispatch' : 'fire';
94 4
        $this->events->{$method}(new BeforeBarRender($request, $response));
95
96 4
        $response->setContent(
97 4
            $this->debuggerManager->shutdownHandler(
98 4
                $response->getContent(), $ajax
99
            )
100
        );
101
102 4
        return $response;
103
    }
104
105
    /**
106
     * reject.
107
     *
108
     * @param \Symfony\Component\HttpFoundation\Response $response
109
     * @param \Illuminate\Http\Request $request
110
     * @param bool $ajax
111
     *
112
     * @return bool
113
     */
114 8
    protected function reject(Response $response, Request $request, $ajax)
0 ignored issues
show
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
115
    {
116
        if (
117 8
            $response instanceof BinaryFileResponse ||
0 ignored issues
show
The class Symfony\Component\HttpFo...tion\BinaryFileResponse does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
118 7
            $response instanceof StreamedResponse ||
0 ignored issues
show
The class Symfony\Component\HttpFoundation\StreamedResponse does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
119 8
            $response instanceof RedirectResponse
0 ignored issues
show
The class Symfony\Component\HttpFoundation\RedirectResponse does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
120
        ) {
121 3
            return true;
122
        }
123
124 5
        if ($ajax === true) {
125 1
            return false;
126
        }
127
128 4
        $contentType = strtolower($response->headers->get('Content-Type'));
129 4
        $accepts = $this->debuggerManager->accepts();
130 4
        if ((empty($contentType) === true && $response->getStatusCode() >= 400) ||
131 4
            count($accepts) === 0
132
        ) {
133 2
            return false;
134
        }
135
136 2
        foreach ($accepts as $accept) {
137 2
            if (strpos($contentType, $accept) !== false) {
138 1
                return false;
139
            }
140
        }
141
142 1
        return true;
143
    }
144
}
145