Issues (8)

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.

Logger/Formatters/StandardFormatter.php (2 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
2
3
/**
4
 * AppserverIo\Logger\Handlers\StandardFormatter
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      http://github.com/appserver-io/logger
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Logger\Formatters;
22
23
use Psr\Log\LogLevel;
24
use Psr\Log\LoggerInterface;
25
use AppserverIo\Logger\LogMessageInterface;
26
27
/**
28
 * The default formatter that uses vsprintf() to format the message.
29
 *
30
 * The following arguments are available and passed to vsprintf()
31
 * method in the given order:
32
 *
33
 * 1. date (formatted with the date format passed to the constructor)
34
 * 2. hostname (queried by PHP gethostname() method)
35
 * 3. loglevel
36
 * 4. message
37
 * 5. context (always JSON encoded)
38
 *
39
 * If you want to change the order of the arguments have a look at
40
 * the sprintf() documentation.
41
 *
42
 * @author    Tim Wagner <[email protected]>
43
 * @copyright 2015 TechDivision GmbH <[email protected]>
44
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
45
 * @link      http://github.com/appserver-io/logger
46
 * @link      http://www.appserver.io
47
 * @see       http://php.net/manual/en/function.sprintf.php
48
 */
49
class StandardFormatter implements FormatterInterface
50
{
51
52
    /**
53
     * The message format to use, timestamp, id, line, message, context
54
     *
55
     * @var string
56
     */
57
    protected $messageFormat = '[%s] - %s (%s): %s %s';
58
59
    /**
60
     * The date format to use.
61
     *
62
     * @var string
63
     */
64
    protected $dateFormat = 'Y-m-d H:i:s';
65
66
    /**
67
     * Initializes the handler instance with channel name and log level.
68
     *
69
     * @param string|null $messageFormat The message format, MUST be valid for sprintf
70
     * @param string|null $dateFormat    The date format, valid for PHP date() function
71
     */
72 10
    public function __construct($messageFormat = null, $dateFormat = null)
73
    {
74
        // initialize message and date format
75 10
        if ($messageFormat != null && is_string($messageFormat)) {
0 ignored issues
show
It seems like you are loosely comparing $messageFormat of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
76
            $this->messageFormat = $messageFormat;
77
        }
78 10
        if ($dateFormat != null && is_string($dateFormat)) {
0 ignored issues
show
It seems like you are loosely comparing $dateFormat of type string|null against null; this is ambiguous if the string can be empty. Consider using a strict comparison !== instead.
Loading history...
79
            $this->dateFormat = $dateFormat;
80
        }
81 10
    }
82
83
    /**
84
     * Formats and returns a string representation of the passed log message.
85
     *
86
     * @param \AppserverIo\Logger\LogMessageInterface $logMessage The log message we want to format
87
     *
88
     * @return string The formatted string representation for the log messsage
89
     */
90 6
    public function format(LogMessageInterface $logMessage)
91
    {
92
93
        // initialize the parameters for the formatted message
94
        $params = array(
95 6
            date($this->dateFormat),
96 6
            gethostname(),
97 6
            $logMessage->getLevel(),
98 6
            $logMessage->getMessage(),
99 6
            json_encode($logMessage->getContext())
100
        );
101
102
        // format, trim and return the message
103 6
        return trim(vsprintf($this->messageFormat, $params));
104
    }
105
}
106