Issues (65)

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/Phossa2/Logger/Logger.php (1 issue)

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
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Logger
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Logger;
16
17
use Psr\Log\LoggerTrait;
18
use Psr\Log\LoggerInterface;
19
use Phossa2\Logger\Message\Message;
20
use Phossa2\Shared\Base\ObjectAbstract;
21
use Phossa2\Logger\Entry\LogEntryInterface;
22
use Phossa2\Logger\Traits\ExtendedLoggerTrait;
23
use Phossa2\Logger\Entry\LogEntryPrototypeTrait;
24
use Phossa2\Logger\Entry\LogEntryPrototypeInterface;
25
use Phossa2\Logger\Exception\InvalidArgumentException;
26
27
/**
28
 * Logger
29
 *
30
 * Implementation of LoggerInterface
31
 *
32
 * @package Phossa2\Logger
33
 * @author  Hong Zhang <[email protected]>
34
 * @see     ObjectAbstract
35
 * @see     LoggerInterface
36
 * @see     LogEntryPrototypeInterface
37
 * @version 2.0.0
38
 * @since   2.0.0 added
39
 * @since   2.0.1 updated addHandler() with level support
40
 */
41
class Logger extends ObjectAbstract implements LoggerInterface, LogEntryPrototypeInterface
42
{
43
    use LoggerTrait, LogEntryPrototypeTrait, ExtendedLoggerTrait;
44
45
    /**
46
     * Instantiate with default channel name and log entry prototype
47
     *
48
     * @param  string $channel default channel
49
     * @param  LogEntryInterface $entryPrototype if any
50
     * @access protected
51
     */
52
    public function __construct(
53
        /*# string */ $channel = 'LOGGER',
54
        LogEntryInterface $entryPrototype = null
55
    ) {
56
        $this->default_channel = strtoupper($channel);
57
        $this->setLogEntryPrototype($entryPrototype);
58
    }
59
60
    /**
61
     * Set/With current channel, followed by any log() method
62
     *
63
     * @param  string $channel current channel
64
     * @return $this
65
     * @access protected
66
     */
67
    public function with(/*# string */ $channel)
68
    {
69
        $this->current_channel = strtoupper($channel);
70
        return $this;
71
    }
72
73
    /**
74
     * Logs with an arbitrary level.
75
     *
76
     * @param  mixed $level
77
     * @param  string $message
78
     * @param  array $context
79
     * @return null
80
     */
81
    public function log($level, $message, array $context = array())
82
    {
83
        // create log entry
84
        $entry = $this->newLogEntry(
85
            $this->getChannel(),
86
            $level,
87
            $message,
88
            $context
89
        );
90
91
        // run processors
92
        $this->runProcessors($entry);
93
94
        // run handlers
95
        $this->runHandlers($entry);
96
97
        // unset current channel
98
        $this->current_channel = null;
99
    }
100
101
    /**
102
     * Add handler to the channel with priority
103
     *
104
     * @param  string $level the level this handler is handling
105
     * @param  callable $handler
106
     * @param  string $channel channel to listen to
107
     * @param  int $priority
108
     * @return $this
109
     * @access public
110
     * @since  2.0.1 added level param
111
     * @api
112
     */
113
    public function addHandler(
114
        /*# string */ $level,
115
        callable $handler,
116
        /*# string */ $channel = '*',
117
        /*# int */ $priority = 0
118
    ) {
119
        // check level
120 View Code Duplication
        if (!isset(LogLevel::$levels[$level])) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
121
            throw new InvalidArgumentException(
122
                Message::get(Message::LOG_LEVEL_INVALID, $level),
123
                Message::LOG_LEVEL_INVALID
124
            );
125
        }
126
127
        return $this->addCallable(
128
            'handlers',
129
            $handler,
130
            $channel,
131
            $priority,
132
            $level
133
        );
134
    }
135
136
    /**
137
     * Remove this handler from the channel
138
     *
139
     * if $channel == '', then remove this handler from all channels
140
     *
141
     * @param  callable|string $handlerOrClassname
142
     * @param  string $channel
143
     * @return $this
144
     * @access public
145
     * @api
146
     */
147
    public function removeHandler($handlerOrClassname, $channel = '')
148
    {
149
        return $this->removeCallable('handlers', $handlerOrClassname, $channel);
150
    }
151
152
    /**
153
     * Add processor to the channel with priority
154
     *
155
     * @param  callable $processor
156
     * @param  string $channel channel to listen to
157
     * @param  int $priority
158
     * @return $this
159
     * @access public
160
     * @api
161
     */
162
    public function addProcessor(
163
        callable $processor,
164
        /*# string */ $channel = '*',
165
        /*# int */ $priority = 0
166
    ) {
167
        return $this->addCallable(
168
            'processors',
169
            $processor,
170
            $channel,
171
            $priority
172
        );
173
    }
174
175
    /**
176
     * Remove this $processor from $channel
177
     *
178
     * if $channel == '', then remove processor from all channels
179
     *
180
     * @param  callable|string $processorOrClassname
181
     * @param  string $channel
182
     * @return $this
183
     * @access public
184
     * @api
185
     */
186
    public function removeProcessor($processorOrClassname, $channel = '')
187
    {
188
        return $this->removeCallable(
189
            'processors',
190
            $processorOrClassname,
191
            $channel
192
        );
193
    }
194
}
195