Issues (38)

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.

src/modules/traits/LoggableTrait.php (1 issue)

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
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://github.com/flipbox/spark/blob/master/LICENSE
6
 * @link       https://github.com/flipbox/spark
7
 */
8
9
namespace flipbox\spark\modules\traits;
10
11
use Craft;
12
use flipbox\spark\helpers\LoggingHelper;
13
use yii\log\Dispatcher;
14
use yii\log\Logger;
15
16
/**
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 */
20
trait LoggableTrait
21
{
22
23
    private static $dispatcher;
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function isDebugModeEnabled()
29
    {
30
        return false;
31
    }
32
33
    /**
34
     * @return Logger
35
     */
36
    public static function getLogger()
37
    {
38
        return static::getDispatcher()->getLogger();
39
    }
40
41
    /**
42
     * Sets the logger object.
43
     * @param Logger $logger the logger object.
44
     */
45
    public static function setLogger($logger)
46
    {
47
        static::getDispatcher()->setLogger($logger);
48
    }
49
50
    /**
51
     * @return Dispatcher
52
     */
53
    public static function getDispatcher()
54
    {
55
        if (self::$dispatcher !== null) {
56
            return self::$dispatcher;
57
        } else {
58
            static::setDispatcher();
59
            return static::$dispatcher;
0 ignored issues
show
Since $dispatcher is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $dispatcher to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
60
        }
61
    }
62
63
    /**
64
     * @param array $dispatcher
65
     * @throws \yii\base\InvalidConfigException
66
     */
67
    public static function setDispatcher($dispatcher = [])
68
    {
69
70
        if (!$dispatcher instanceof Dispatcher) {
71
            $dispatcher = Craft::createObject(
72
                LoggingHelper::getDispatchDefinition(
73
                    static::getInstance(),
74
                    $dispatcher
75
                )
76
            );
77
        }
78
79
        self::$dispatcher = $dispatcher;
80
    }
81
82
    /**
83
     * Logs a trace message.
84
     * Trace messages are logged mainly for development purpose to see
85
     * the execution work flow of some code.
86
     * @param string $message the message to be logged.
87
     * @param string $category the category of the message.
88
     */
89
    public static function trace($message, $category = 'module')
90
    {
91
        static::getLogger()->log($message, Logger::LEVEL_TRACE, $category);
92
    }
93
94
    /**
95
     * Logs an error message.
96
     * An error message is typically logged when an unrecoverable error occurs
97
     * during the execution of an application.
98
     * @param string $message the message to be logged.
99
     * @param string $category the category of the message.
100
     */
101
    public static function error($message, $category = 'module')
102
    {
103
        static::getLogger()->log($message, Logger::LEVEL_ERROR, $category);
104
    }
105
106
    /**
107
     * Logs a warning message.
108
     * A warning message is typically logged when an error occurs while the execution
109
     * can still continue.
110
     * @param string $message the message to be logged.
111
     * @param string $category the category of the message.
112
     */
113
    public static function warning($message, $category = 'module')
114
    {
115
        static::getLogger()->log($message, Logger::LEVEL_WARNING, $category);
116
    }
117
118
    /**
119
     * Logs an informative message.
120
     * An informative message is typically logged by an application to keep record of
121
     * something important (e.g. an administrator logs in).
122
     * @param string $message the message to be logged.
123
     * @param string $category the category of the message.
124
     */
125
    public static function info($message, $category = 'module')
126
    {
127
        static::getLogger()->log($message, Logger::LEVEL_INFO, $category);
128
    }
129
}
130