Issues (243)

Security Analysis    2 potential vulnerabilities

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 (2)
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/web/FlashMessage.php (6 issues)

Labels
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 /** MicroFlashMessage */
2
3
namespace Micro\Web;
4
5
/**
6
 * FlashMessage is a flash messenger.
7
 *
8
 * @author Oleg Lunegov <[email protected]>
9
 * @link https://github.com/linpax/microphp-framework
10
 * @copyright Copyright (c) 2013 Oleg Lunegov
11
 * @license https://github.com/linpax/microphp-framework/blob/master/LICENSE
12
 * @package Micro
13
 * @subpackage Web
14
 * @version 1.0
15
 * @since 1.0
16
 */
17
class FlashMessage
18
{
19
    /** @var integer $TYPE_SUCCESS success */
20
    const TYPE_SUCCESS = 1;
21
    /** @var integer $TYPE_NOTICE notice */
22
    const TYPE_INFO = 2;
23
    /** @var integer $TYPE_WARNING warning */
24
    const TYPE_WARNING = 3;
25
    /** @var integer TYPE_DANGER danger */
26
    const TYPE_DANGER = 4;
27
28
29
    /** @var ISession $session Session component */
30
    protected $session;
31
32
33
    /**
34
     * Constructor messenger
35
     *
36
     * @access public
37
     *
38
     * @param ISession $session
39
     *
40
     * @result void
41
     */
42
    public function __construct(ISession $session)
43
    {
44
        $this->session = $session;
45
    }
46
47
    /**
48
     * Get label for type by id
49
     *
50
     * @access public
51
     *
52
     * @param int $type type id
53
     *
54
     * @return string
55
     * @static
56
     */
57
    public static function getTypeLabel($type = self::TYPE_SUCCESS)
58
    {
59
        return self::getTypeLabels()[$type];
60
    }
61
62
    /**
63
     * Get labels for types
64
     *
65
     * @access public
66
     * @return string[]
67
     * @static
68
     */
69
    public static function getTypeLabels()
70
    {
71
        return [
72
            self::TYPE_SUCCESS => 'success',
73
            self::TYPE_INFO => 'info',
74
            self::TYPE_WARNING => 'warning',
75
            self::TYPE_DANGER => 'danger'
76
        ];
77
    }
78
79
    /**
80
     * Push a new flash
81
     *
82
     * @access public
83
     *
84
     * @param int $type type id
85
     * @param string $title title flash
86
     * @param string $description description flash
87
     *
88
     * @return void
89
     */
90
    public function push($type = FlashMessage::TYPE_SUCCESS, $title = '', $description = '')
91
    {
92
        $flashes = $this->session->flash;
0 ignored issues
show
Accessing flash on the interface Micro\Web\ISession suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
93
        $flashes[] = [
94
            'type' => $type,
95
            'title' => $title,
96
            'description' => $description
97
        ];
98
        $this->session->flash = $flashes;
0 ignored issues
show
Accessing flash on the interface Micro\Web\ISession suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
99
    }
100
101
    /**
102
     * Has flashes by type
103
     *
104
     * @access public
105
     *
106
     * @param int $type type of flash
107
     *
108
     * @return bool
109
     */
110
    public function has($type = FlashMessage::TYPE_SUCCESS)
111
    {
112
        foreach ($this->session->flash AS $element) {
0 ignored issues
show
Accessing flash on the interface Micro\Web\ISession suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
113
            if (!empty($element['type']) && $element['type'] === $type) {
114
                return true;
115
            }
116
        }
117
118
        return false;
119
    }
120
121
    /**
122
     * Get flash by type
123
     *
124
     * @access public
125
     *
126
     * @param int $type type of flash
127
     *
128
     * @return array|bool
129
     */
130
    public function get($type = FlashMessage::TYPE_SUCCESS)
131
    {
132
        foreach ($this->session->flash AS $key => $element) {
0 ignored issues
show
Accessing flash on the interface Micro\Web\ISession suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
133
            if (!empty($element['type']) && $element['type'] === $type) {
134
                $result = $element;
135
                unset($this->session->flash[$key]);
136
137
                return $result;
138
            }
139
        }
140
141
        return false;
142
    }
143
144
    /**
145
     * Get all flashes
146
     *
147
     * @access public
148
     *
149
     * @return mixed
150
     */
151
    public function getAll()
152
    {
153
        $result = $this->session->flash;
0 ignored issues
show
Accessing flash on the interface Micro\Web\ISession suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
154
        $this->session->flash = [];
0 ignored issues
show
Accessing flash on the interface Micro\Web\ISession suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
155
156
        return $result;
157
    }
158
}
159