Issues (2)

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/FlashService.php (2 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 Jalle19\Laravel\UnshittyFlash;
4
5
use Illuminate\Http\Request;
6
7
/**
8
 * Class FlashService
9
 * @package Jalle19\Laravel\UnshittyFlash
10
 */
11
class FlashService
12
{
13
14
    const LEVEL_SUCCESS = 'success';
15
    const LEVEL_INFO    = 'info';
16
    const LEVEL_WARNING = 'warning';
17
    const LEVEL_DANGER  = 'danger';
18
19
    /**
20
     * @var string
21
     */
22
    private $sessionKey;
23
24
25
    /**
26
     * FlashService constructor.
27
     *
28
     * @param array $configuration
29
     *
30
     * @throws \InvalidArgumentException
31
     */
32
    public function __construct(array $configuration)
33
    {
34
        if (!isset($configuration['session_key'])) {
35
            throw new \InvalidArgumentException('session_key cannot be empty');
36
        }
37
38
        $this->sessionKey = $configuration['session_key'];
39
    }
40
41
42
    /**
43
     * @param Request $request
44
     * @param string  $message
45
     * @param string  $level
46
     * @param bool    $sameRequest
47
     */
48
    public function message(Request $request, string $message, string $level, bool $sameRequest = false)
49
    {
50
        $session = $request->session();
51
52
        $data = $session->get($this->sessionKey, []);
53
54
        // Append the new message and store again
55
        $data[] = ['message' => $message, 'level' => $level];
56
57
        // Flash the message, either immediately or for the next request
58
        if ($sameRequest) {
59
            $session->now($this->sessionKey, $data);
0 ignored issues
show
The method now() does not seem to exist on object<Symfony\Component...ssion\SessionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
        } else {
61
            $session->flash($this->sessionKey, $data);
0 ignored issues
show
The method flash() does not seem to exist on object<Symfony\Component...ssion\SessionInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
62
        }
63
    }
64
65
66
    /**
67
     * @param Request $request
68
     * @param string  $message
69
     * @param bool    $sameRequest
70
     */
71
    public function success(Request $request, string $message, bool $sameRequest = false)
72
    {
73
        $this->message($request, $message, self::LEVEL_SUCCESS, $sameRequest);
74
    }
75
76
77
    /**
78
     * @param Request $request
79
     * @param string  $message
80
     * @param bool    $sameRequest
81
     */
82
    public function info(Request $request, string $message, bool $sameRequest = false)
83
    {
84
        $this->message($request, $message, self::LEVEL_INFO, $sameRequest);
85
    }
86
87
88
    /**
89
     * @param Request $request
90
     * @param string  $message
91
     * @param bool    $sameRequest
92
     */
93
    public function warning(Request $request, string $message, bool $sameRequest = false)
94
    {
95
        $this->message($request, $message, self::LEVEL_WARNING, $sameRequest);
96
    }
97
98
99
    /**
100
     * @param Request $request
101
     * @param string  $message
102
     * @param bool    $sameRequest
103
     */
104
    public function danger(Request $request, string $message, bool $sameRequest = false)
105
    {
106
        $this->message($request, $message, self::LEVEL_DANGER, $sameRequest);
107
    }
108
109
}
110