Issues (243)

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/Log/CLogger.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 Anax\Log;
4
5
/**
6
 * Anax default logger instance
7
 *
8
 * The message MUST be a string or object implementing __toString().
9
 *
10
 * The message MAY contain placeholders in the form: {foo} where foo
11
 * will be replaced by the context data in key "foo".
12
 *
13
 * The context array can contain arbitrary data, the only assumption that
14
 * can be made by implementors is that if an Exception instance is given
15
 * to produce a stack trace, it MUST be in a key named "exception".
16
 *
17
 * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
18
 * for the full interface specification.
19
 */
20
class CLogger
21
{
22
23
    /**
24
     * Constans for loglevel.
25
     *
26
     */
27
    const EMERGENCY = 'emergency';
28
    const ALERT     = 'alert';
29
    const CRITICAL  = 'critical';
30
    const ERROR     = 'error';
31
    const WARNING   = 'warning';
32
    const NOTICE    = 'notice';
33
    const INFO      = 'info';
34
    const DEBUG     = 'debug';
35
36
37
38
    /**
39
     * Constans for loglevel.
40
     *
41
     */
42
    private $context = 'development'; // production, development or debug
43
44
45
    /**
46
     * Init the logger depending on its context production, development or debug.
47
     *
48
     * @param string $context as production, development or debug, default is development
49
     * @return $this
50
     */
51
    public function setContext($context = 'development')
52
    {
53
54
        switch ($context) {
55
            
56
            case 'production':
57
                break;
58
            
59
            case 'development':
60
                error_reporting(-1);              // Report all type of errors
61
                ini_set('display_errors', 1);     // Display all errors
62
                ini_set('output_buffering', 0);   // Do not buffer output
63
64
                set_exception_handler(function ($exception) {
65
                    echo "Anax: Uncaught exception: <p>" .
66
                        $exception->getMessage() . "</p><pre>" .
67
                        $exception->getTraceAsString() . "</pre>";
68
                });
69
                break;
70
            
71
            case 'debug':
72
                break;
73
            
74
            default:
75
                throw new \Exception('Unknown context.');
76
                break;
0 ignored issues
show
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
77
        }
78
79
        $this->context = $context;
80
        return $this;
81
    }
82
83
84
85
    /**
86
     * Logs with an arbitrary level.
87
     *
88
     * @param mixed $level
89
     * @param string $message
90
     * @param array $context
91
     * @return null
92
     */
93
    public function log($level, $message, array $context = array())
94
    {
95
        echo "Level: " . $level . "<br>"
96
            . "Message: " . $message . "<br>"
97
            . htmlentities(print_r($context, 1)) . "<br>";
98
    }
99
100
101
102
    /**
103
     * System is unusable.
104
     *
105
     * @param string $message
106
     * @param array $context
107
     * @return null
108
     */
109
    public function emergency($message, array $context = array())
110
    {
111
        $this->log(self::EMERGENCY, $message, $context);
112
    }
113
114
115
116
    /**
117
     * Action must be taken immediately.
118
     *
119
     * Example: Entire website down, database unavailable, etc. This should
120
     * trigger the SMS alerts and wake you up.
121
     *
122
     * @param string $message
123
     * @param array $context
124
     * @return null
125
     */
126
    public function alert($message, array $context = array())
127
    {
128
        $this->log(self::ALERT, $message, $context);
129
    }
130
131
132
133
    /**
134
     * Critical conditions.
135
     *
136
     * Example: Application component unavailable, unexpected exception.
137
     *
138
     * @param string $message
139
     * @param array $context
140
     * @return null
141
     */
142
    public function critical($message, array $context = array())
143
    {
144
        $this->log(self::CRITICAL, $message, $context);
145
    }
146
147
148
149
    /**
150
     * Runtime errors that do not require immediate action but should typically
151
     * be logged and monitored.
152
     *
153
     * @param string $message
154
     * @param array $context
155
     * @return null
156
     */
157
    public function error($message, array $context = array())
158
    {
159
        $this->log(self::ERROR, $message, $context);
160
    }
161
162
163
164
    /**
165
     * Exceptional occurrences that are not errors.
166
     *
167
     * Example: Use of deprecated APIs, poor use of an API, undesirable things
168
     * that are not necessarily wrong.
169
     *
170
     * @param string $message
171
     * @param array $context
172
     * @return null
173
     */
174
    public function warning($message, array $context = array())
175
    {
176
        $this->log(self::WARNING, $message, $context);
177
    }
178
179
180
181
    /**
182
     * Normal but significant events.
183
     *
184
     * @param string $message
185
     * @param array $context
186
     * @return null
187
     */
188
    public function notice($message, array $context = array())
189
    {
190
        $this->log(self::NOTICE, $message, $context);
191
    }
192
193
194
195
    /**
196
     * Interesting events.
197
     *
198
     * Example: User logs in, SQL logs.
199
     *
200
     * @param string $message
201
     * @param array $context
202
     * @return null
203
     */
204
    public function info($message, array $context = array())
205
    {
206
        $this->log(self::INFO, $message, $context);
207
    }
208
209
210
211
    /**
212
     * Detailed debug information.
213
     *
214
     * @param string $message
215
     * @param array $context
216
     * @return null
217
     */
218
    public function debug($message, array $context = array())
219
    {
220
        $this->log(self::DEBUG, $message, $context);
221
    }
222
}
223