Issues (25)

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/Exceptions/Handler.php (1 issue)

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 namespace App\Exceptions;
2
3
use App\Exceptions\Users\UserNotActivatedException;
4
use Illuminate\Auth\AuthenticationException;
5
use Illuminate\Auth\Access\AuthorizationException;
6
use Illuminate\Database\Eloquent\ModelNotFoundException;
7
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
8
use Illuminate\Http\Response as IlluminateResponse;
9
use Illuminate\Session\TokenMismatchException;
10
use Illuminate\Validation\ValidationException as IlluminateValidationException;
11
use Symfony\Component\HttpKernel\Exception\HttpException;
12
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
13
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
14
15
class Handler extends ExceptionHandler
16
{
17
    /**
18
     * A list of the exception types that should not be reported.
19
     *
20
     * @var array
21
     */
22
    protected $dontReport = [
23
        AuthenticationException::class,
24
        AuthorizationException::class,
25
        HttpException::class,
26
        TokenMismatchException::class,
27
        IlluminateValidationException::class,
28
        ModelNotFoundException::class,
29
    ];
30
31
    /**
32
     * Report or log an exception.
33
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
34
     *
35
     * @param \Exception $e
36
     *
37
     * @return void
38
     */
39 5
    public function report(\Exception $e)
40
    {
41 5
        parent::report($e);
42 5
    }
43
44
    /**
45
     * Render an exception into an HTTP response.
46
     *
47
     * @param \Illuminate\Http\Request $request
48
     * @param \Exception               $e
49
     *
50
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response
51
     */
52 4
    public function render($request, \Exception $e)
53
    {
54 4
        if ($e instanceof ModelNotFoundException) {
55 2
            $e = new NotFoundHttpException($e->getMessage(), $e);
56
        }
57
58 4
        if ($request->expectsJson()) {
59 4
            $exceptionClass = get_class($e);
60 4
            $responseBody = ['exception' => $exceptionClass, 'message' => $e->getMessage()];
61
62
            # FileStream exceptions response body
63 4
            $preventRetry = true;
64 4
            $resetUpload = false;
65 4
            if ($e instanceof FileStream\UploadFilenameIsEmptyException) {
66
                $preventRetry = false;
67 4
            } elseif ($e instanceof FileStream\UploadIncompleteException) {
68
                $preventRetry = false;
69
                $resetUpload = true;
70 4
            } elseif ($e instanceof FileStream\UploadAttemptFailedException) {
71
                $preventRetry = false;
72
            }
73 4
            if (strpos($exceptionClass, 'App\Exceptions\FileStream') !== false) {
74
                $responseBody = ['exception' => $exceptionClass, 'error' => $e->getMessage(), 'preventRetry' => $preventRetry, 'reset' => $resetUpload];
75
            }
76
77
            # Status codes
78 4
            if ($e instanceof UnauthorizedHttpException) {
79
                $statusCode = IlluminateResponse::HTTP_UNAUTHORIZED;
80 4
            } elseif ($e instanceof UserNotActivatedException) {
81
                $statusCode = IlluminateResponse::HTTP_FORBIDDEN;
82 4
            } elseif ($e instanceof NotFoundHttpException) {
83 2
                $statusCode = IlluminateResponse::HTTP_NOT_FOUND;
84 4
            } elseif ($e instanceof \BadMethodCallException) {
85
                $statusCode = IlluminateResponse::HTTP_METHOD_NOT_ALLOWED;
86 4
            } elseif ($e instanceof \UnexpectedValueException || $e instanceof IlluminateValidationException || $e instanceof TokenMismatchException) {
87 3
                $statusCode = IlluminateResponse::HTTP_UNPROCESSABLE_ENTITY;
88 3
                if ($e instanceof IlluminateValidationException) {
89
                    /** @var \Illuminate\Support\MessageBag $messageBag */
90 3
                    $messageBag = $e->validator->getMessageBag();
91 3
                    $responseBody['message'] = $messageBag->getMessages();
92
                }
93 1
            } elseif ($e instanceof \OverflowException) {
94
                $statusCode = IlluminateResponse::HTTP_REQUEST_ENTITY_TOO_LARGE;
95
            } else {
96 1
                $statusCode = method_exists($e, 'getStatusCode') ? $e->getStatusCode() : $e->getCode();
97
            }
98
99 4
            if (empty($statusCode)) {
100
                $statusCode = IlluminateResponse::HTTP_INTERNAL_SERVER_ERROR;
101
            }
102
103 4
            return response()->json($responseBody)->setStatusCode($statusCode);
104
        }
105
106
        if ($request->method() != 'GET' && $request->header('content-type') == 'application/x-www-form-urlencoded') {
107
            return redirect()->back()->withInput($request->all())->withErrors($e->getMessage());
108
        }
109
110
        return parent::render($request, $e);
111
    }
112
113
    /**
114
     * Convert an authentication exception into an unauthenticated response.
115
     *
116
     * @param  \Illuminate\Http\Request                 $request
117
     * @param  \Illuminate\Auth\AuthenticationException $exception
118
     *
119
     * @return \Illuminate\Http\Response
120
     */
121
    protected function unauthenticated($request, AuthenticationException $exception)
0 ignored issues
show
The parameter $exception 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...
122
    {
123
        if ($request->expectsJson()) {
124
            return response()->json(['error' => 'Unauthenticated.'], 401);
125
        }
126
127
        return redirect()->guest('login');
128
    }
129
}
130