Issues (16)

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/Cuttle.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
/*
4
 * This file is part of the overtrue/cuttle.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Overtrue\Cuttle;
13
14
use Monolog\Logger;
15
use Monolog\Registry;
16
17
/**
18
 * Class Cuttle.
19
 *
20
 * @author overtrue <[email protected]>
21
 */
22
class Cuttle
23
{
24
    /**
25
     * @var \Overtrue\Cuttle\Config
26
     */
27
    protected $config;
28
29
    /**
30
     * Cuttle constructor.
31
     *
32
     * @param array $config
33
     */
34
    public function __construct(array $config)
35
    {
36
        $this->config = new Config($config);
37
    }
38
39
    /**
40
     * @param string $name
41
     *
42
     * @return \Monolog\Logger
43
     */
44
    public function channel(string $name)
45
    {
46
        return $this->getLogger($name);
47
    }
48
49
    /**
50
     * @param string $name
51
     *
52
     * @return \Monolog\Logger
53
     */
54
    public function of(string $name)
0 ignored issues
show
This method's name is shorter than the configured minimum length of 3 characters.

Even though PHP does not care about the name of your methods, it is generally a good practice to choose method names which can be easily understood by other human readers.

Loading history...
55
    {
56
        return $this->channel($name);
57
    }
58
59
    /**
60
     * @param string $name
61
     *
62
     * @return \Monolog\Logger
63
     */
64
    public function from(string $name)
65
    {
66
        return $this->channel($name);
67
    }
68
69
    /**
70
     * @return \Overtrue\Cuttle\Config
71
     */
72
    public function getConfig()
73
    {
74
        return $this->config;
75
    }
76
77
    /**
78
     * @param \Overtrue\Cuttle\Config $config
79
     *
80
     * @return \Overtrue\Cuttle\Cuttle
81
     */
82
    public function setConfig(Config $config)
83
    {
84
        $this->config = $config;
85
86
        return $this;
87
    }
88
89
    /**
90
     * @param $name
91
     *
92
     * @return \Monolog\Logger
93
     */
94
    public function getLogger(string $name)
95
    {
96
        if (!Registry::hasLogger($name)) {
97
            $config = $this->config->getChannel($name);
98
            Registry::addLogger($this->makeLogger($name, $config['handlers'], $config['processors']));
99
        }
100
101
        return Registry::getInstance($name);
102
    }
103
104
    /**
105
     * @return \Monolog\Logger
106
     */
107
    public function getDefaultLogger()
108
    {
109
        return $this->getLogger($this->config->getDefaultChannel());
110
    }
111
112
    /**
113
     * @param string $name
114
     * @param array  $handlers
115
     * @param array  $processors
116
     *
117
     * @return \Monolog\Logger
118
     */
119
    public function makeLogger(string $name, array $handlers = [], array $processors = [])
120
    {
121
        return new Logger($name, $handlers, $processors);
122
    }
123
124
    /**
125
     * Magic call.
126
     *
127
     * @param string $method
128
     * @param array  $args
129
     *
130
     * @return mixed
131
     */
132
    public function __call($method, $args)
133
    {
134
        $logger = $this->getDefaultLogger();
135
136
        return call_user_func_array([$logger, $method], $args);
137
    }
138
}
139