XssSecurity   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 21 1
1
<?php
2
/*
3
 * This file is part of the Laravel Platfourm package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\Platfourm\Http\Middleware;
12
13
use Closure;
14
15
class XssSecurity
16
{
17
    /**
18
     * Handle the given request and get the response.
19
     *
20
     * @param  \Illuminate\Http\Request $request
21
     * @param  \Closure                 $next
22
     * @return \Illuminate\Http\Response
23
     */
24
    public function handle($request, Closure $next)
25
    {
26
        $response = $next($request);
27
28
        // Set security headers
29
        $uri = $request->getUri();
0 ignored issues
show
Unused Code introduced by
$uri is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
30
31
        // checking for debugger
32
        //if (strpos($uri, '/itdc/debug') === false) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
        // http://blogs.msdn.com/b/ieinternals/archive/2010/03/30/combating-clickjacking-with-x-frame-options.aspx
34
        $response->headers->set('X-Frame-Options', 'DENY', false);
35
        //}
36
37
        // http://msdn.microsoft.com/en-us/library/ie/gg622941(v=vs.85).aspx
38
        $response->headers->set('X-Content-Type-Options', 'nosniff', false);
39
40
        // http://msdn.microsoft.com/en-us/library/dd565647(v=vs.85).aspx
41
        $response->headers->set('X-XSS-Protection', '1; mode=block', false);
42
43
        return $response;
44
    }
45
}
46