Issues (43)

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/Understand/UnderstandLaravel5/Logger.php (4 issues)

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 namespace Understand\UnderstandLaravel5;
2
3
use Understand\UnderstandLaravel5\FieldProvider;
4
use Understand\UnderstandLaravel5\Handlers\BaseHandler;
5
6
class Logger
7
{
8
9
    /**
10
     * Version Number
11
     */
12
    const VERSION = 2.3;
13
14
    /**
15
     * Field provider
16
     *
17
     * @var FieldProvider
18
     */
19
    protected $fieldProvider;
20
21
    /**
22
     * Transport layer
23
     *
24
     * @var BaseHandler
25
     */
26
    protected $handler;
27
28
    /**
29
     * @param FieldProvider $fieldProvider
30
     * @param BaseHandler $handler
31
     * @param bool $silent
0 ignored issues
show
There is no parameter named $silent. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
32
     */
33
    public function __construct(FieldProvider $fieldProvider, BaseHandler $handler)
34
    {
35
        $this->setFieldProvider($fieldProvider);
36
        $this->setHandler($handler);
37
    }
38
39
    /**
40
     * @param $log
41
     * @param array $additional
42
     * @param array $customFields
43
     * @return mixed
44
     */
45
    public function log($log, array $additional = [], array $customFields = [])
46
    {
47
        $event = $this->prepare($log, $additional, $customFields);
48
49
        return $this->send($event);
50
    }
51
52
    /**
53
     * @param $log
54
     * @param array $additional
55
     * @param array $customFields
56
     * @return array
57
     */
58
    protected function prepare($log, array $additional = [], array $customFields = [])
59
    {
60
        // integer, float, string or boolean as message
61
        if (is_scalar($log))
62
        {
63
            $log = ['message' => $log];
64
        }
65
        
66
        if (isset($log['message']))
67
        {
68
            $log['message'] = $this->formatMessage($log['message']);
69
        }
70
71
        // resolve additional properties from field providers
72
        $data = $this->resolveData($log, $additional, $customFields);
73
74
        $event = $data + $log;
75
76
        if (!isset($event['timestamp']))
77
        {
78
            $event['timestamp'] = round(microtime(true) * 1000);
79
        }
80
81
        return $event;
82
    }
83
84
    /**
85
     * @param $log
86
     * @param array $additional
87
     * @param array $customFields
88
     * @return array
89
     */
90
    protected function resolveData($log, array $additional = [], array $customFields = [])
91
    {
92
        $data = $this->fieldProvider->resolveValues($additional, $log);
93
94
        if ($customFields)
0 ignored issues
show
Bug Best Practice introduced by
The expression $customFields of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
95
        {
96
            $data['custom'] = $this->fieldProvider->resolveValues($customFields, $log);
97
        }
98
99
        return $data;
100
    }
101
    
102
    /**
103
     * Format message field
104
     * 
105
     * @param string $message
106
     * @return string
107
     */
108
    protected function formatMessage($message)
109
    {
110
        if ( ! is_bool($message))
111
        {
112
            return (string)$message;
113
        }
114
        
115
        // cast boolean values to "1" or "0" strings
116
        if ($message)
117
        {
118
            return '1';
119
        }
120
        
121
        return '0';
122
    }
123
124
    /**
125
     * Set handler
126
     *
127
     * @param BaseHandler $handler
128
     */
129
    public function setHandler(BaseHandler $handler)
130
    {
131
        $this->handler = $handler;
132
    }
133
134
    /**
135
     * Set field provider
136
     *
137
     * @param FieldProvider $fieldProvider
138
     */
139
    public function setFieldProvider(FieldProvider $fieldProvider)
140
    {
141
        $this->fieldProvider = $fieldProvider;
142
    }
143
144
    /**
145
     * Send data to storage
146
     *
147
     * @param array $requestData
0 ignored issues
show
There is no parameter named $requestData. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
148
     * @return mixed
149
     */
150
    protected function send(array $event)
151
    {
152
        try
153
        {
154
            return $this->handler->handle($event);
155
        }
156
        catch (\Throwable $e)
0 ignored issues
show
The class Throwable does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
157
        {
158
            return false;
159
        }
160
        catch (\Exception $ex)
161
        {
162
            return false;
163
        }
164
    }
165
}
166