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.

Understand/UnderstandLaravel5/ExceptionLogger.php (5 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 Illuminate\Config\Repository;
4
use Exception;
5
use Throwable;
6
7
class ExceptionLogger
8
{
9
10
    /**
11
     * Log writer
12
     *
13
     * @var Logger
14
     */
15
    protected $logger;
16
17
    /**
18
     * Exception encoder
19
     *
20
     * @var ExceptionEncoder
21
     */
22
    protected $encoder;
23
24
    /**
25
     * Configuration
26
     *
27
     * @var array
28
     */
29
    protected $config;
30
31
    /**
32
     * @param Logger $logger
33
     * @param ExceptionEncoder $encoder
34
     * @param Repository $config
35
     */
36
    public function __construct(
37
        Logger $logger,
38
        ExceptionEncoder $encoder,
39
        Repository $config
40
    )
41
    {
42
        $this->logger = $logger;
43
        $this->encoder = $encoder;
44
        $this->config = $config;
0 ignored issues
show
Documentation Bug introduced by
It seems like $config of type object<Illuminate\Config\Repository> is incompatible with the declared type array of property $config.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
45
46
        $this->encoder->setProjectRoot($this->config->get('understand-laravel.project_root'));
47
    }
48
49
    /**
50
     * Send PHP exception to Understand.io
51
     *
52
     * @deprecated
53
     * @param mixed $error
54
     * @return void
55
     */
56
    public function log($error)
57
    {
58
        if ( ! $this->canHandle($error))
59
        {
60
            return;
61
        }
62
63
        $errorArr = $this->encoder->exceptionToArray($error);
64
65
        return $this->dispatch($errorArr);
66
    }
67
68
    /**
69
     * @param string $level
70
     * @param mixed $message
71
     * @param mixed $context
72
     * @return void
73
     */
74
    public function logError($level, $message, $context)
75
    {
76
        if ( ! $this->canHandle($message))
77
        {
78
            return;
79
        }
80
81
        if ($message instanceof Exception || $message instanceof Throwable)
0 ignored issues
show
The class Throwable does not exist. Is this class maybe located in a folder that is not analyzed, or in a newer version of your dependencies than listed in your composer.lock/composer.json?
Loading history...
82
        {
83
            $log = $this->encoder->exceptionToArray($message);
84
        }
85
        // integer, float, string or boolean as message
86
        else if (is_scalar($message))
87
        {
88
            $log = [
89
                'message' => $message
90
            ];
91
92
            $log = $this->encoder->setCurrentStackTrace($log);
93
        }
94
        else
95
        {
96
            $log = (array)$message;
97
            $log = $this->encoder->setCurrentStackTrace($log);
98
        }
99
100
        $log['level'] = $level;
101
102
        if ($context)
103
        {
104
            $log['context'] = (array)$context;
105
        }
106
107
        return $this->dispatch($log);
108
    }
109
110
    /**
111
     * @param array $errorArr
112
     * @return array
113
     */
114
    protected function dispatch(array $errorArr)
115
    {
116
        $errorArr['tags'] = ['error_log'];
117
118
        $additionalFields = $this->getMetaFields();
119
        $customFields = $this->config->get('understand-laravel.errors.meta', []);
0 ignored issues
show
The method get cannot be called on $this->config (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
120
121
        return $this->logger->log($errorArr, $additionalFields, $customFields);
122
    }
123
124
    /**
125
     * @return array
126
     */
127
    protected function getMetaFields()
128
    {
129
        return [
130
            'session_id' => 'UnderstandFieldProvider::getSessionId',
131
            'request_id' => 'UnderstandFieldProvider::getProcessIdentifier',
132
            'group_id' => 'UnderstandFieldProvider::getGroupId',
133
            'user_id' => 'UnderstandFieldProvider::getUserId',
134
            'env' => 'UnderstandFieldProvider::getEnvironment',
135
            'url' => 'UnderstandFieldProvider::getUrl',
136
            'method' => 'UnderstandFieldProvider::getRequestMethod',
137
            'query_string_data' => 'UnderstandFieldProvider::getQueryStringArray',
138
            'request_body_data' => 'UnderstandFieldProvider::getPostDataArray',
139
            'client_ip' => 'UnderstandFieldProvider::getClientIp',
140
            'server_ip' => 'UnderstandFieldProvider::getServerIp',
141
            'user_agent' => 'UnderstandFieldProvider::getClientUserAgent',
142
            'laravel_version' => 'UnderstandFieldProvider::getLaravelVersion',
143
            'sql_queries' => 'UnderstandFieldProvider::getSqlQueries',
144
            'artisan_command' => 'UnderstandFieldProvider::getArtisanCommandName',
145
            'console' => 'UnderstandFieldProvider::getRunningInConsole',
146
            'logger_version' => 'UnderstandFieldProvider::getLoggerVersion',
147
        ];
148
    }
149
150
    /**
151
     * @param mixed $error
152
     * @return bool
153
     */
154
    protected function canHandle($error)
0 ignored issues
show
The parameter $error is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
155
    {
156
        return (bool)$this->config->get('understand-laravel.enabled');
0 ignored issues
show
The method get cannot be called on $this->config (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
157
    }
158
}