Issues (415)

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/Http/Middleware/ViewPostThrottleMiddleware.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
3
namespace App\Http\Middleware;
4
5
use Illuminate\Session\Store;
6
7
class ViewPostThrottleMiddleware
8
{
9
    /**
10
     * Views will expire after 12 hours.
11
     *
12
     * @var int
13
     */
14
    protected $throttleTime = 43200;
15
16
    /**
17
     * @var Store
18
     */
19
    protected $session;
20
21
    /**
22
     * ViewThrottleMiddleware constructor.
23
     * @param Store $session
24
     */
25
    public function __construct(Store $session)
26
    {
27
        $this->session = $session;
28
    }
29
30
    /**
31
     * Handle an incoming request.
32
     *
33
     * @param  \Illuminate\Http\Request  $request
34
     * @param  \Closure  $next
35
     * @param  string|null  $guard
36
     * @return mixed
37
     */
38
    public function handle($request, \Closure $next, $guard = null)
0 ignored issues
show
The parameter $guard 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...
39
    {
40
        $posts = $this->getViewedPosts();
41
42
        if ( ! is_null($posts))
43
        {
44
            $posts = $this->cleanExpiredViews($posts);
45
46
            $this->storePosts($posts);
47
        }
48
49
        return $next($request);
50
    }
51
52
    /**
53
     * Get all the viewed posts from the session. If no
54
     * entry in the session exists, default to null.
55
     *
56
     * @return mixed
57
     */
58
    private function getViewedPosts()
59
    {
60
        return $this->session->get('viewed_posts', null);
61
    }
62
63
    /**
64
     * Clean expired views.
65
     *
66
     * @param $posts
67
     * @return array
68
     */
69
    private function cleanExpiredViews($posts)
70
    {
71
        $time = time();
72
73
        // Filter through the post array. The argument passed to the
74
        // function will be the value from the array, which is the
75
        // timestamp in our case.
76
        return array_filter($posts, function ($timestamp) use ($time)
77
        {
78
            // If the view timestamp + the throttle time is
79
            // still after the current timestamp the view
80
            // has not expired yet, so we want to keep it.
81
            return ($timestamp + $this->throttleTime) > $time;
82
        });
83
    }
84
85
    /**
86
     * Push the post id onto the viewed_posts session array.
87
     *
88
     * @param $posts
89
     */
90
    private function storePosts($posts)
91
    {
92
        $this->session->put('viewed_posts', $posts);
93
    }
94
}