Issues (14)

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/Emitter/AbstractEmitter.php (2 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
2
3
namespace Apix\Log\Emitter;
4
5
use Apix\Log\Logger;
6
use Apix\Log\Logger\LoggerInterface;
7
8
abstract class AbstractEmitter implements EmitterInterface
9
{
10
    /**
11
     * Holds the emitter/transporter's URL.
12
     *
13
     * @var string
14
     */
15
    protected $url;
16
17
    /**
18
     * Holds the emitter/transporter's debug mode.
19
     *
20
     * @var bool
21
     */
22
    protected $debug = false;
23
24
    /**
25
     * Holds the query parameters.
26
     *
27
     * @var array
28
     */
29
    protected $params = array();
30
31
    /**
32
     * Sets the emitter/transporter's URL.
33
     *
34
     * @param string $url
35
     */
36 64
    public function setUrl($url)
37
    {
38 64
        $this->url = vsprintf($url, $this->params);
39 64
    }
40
41
    /**
42
     * Sets the emitter/transporter's debug mode.
43
     *
44
     * @param bool $bool
45
     */
46 108
    public function setDebug($bool = true)
47
    {
48 108
        $this->debug = (bool) $bool;
49 108
    }
50
51
    /**
52
     * Returns the current query parameters.
53
     *
54
     * @return array
55
     */
56 76
    public function getParams()
57
    {
58 76
        return $this->params;
59
    }
60
61
    /**
62
     * Checks wether the named query parameter exists.
63
     *
64
     * @param string $key
65
     *
66
     * @return bool
67
     */
68 12
    public function hasParam($key)
69
    {
70 12
        return isset($this->params[$key]);
71
    }
72
73
    /**
74
     * Returns the named query parameter.
75
     *
76
     * @param string $key
77
     *
78
     * @return mixed
79
     */
80 16
    public function getParam($key)
81
    {
82 16
        return $this->params[$key];
83
    }
84
85
    /**
86
     * Sets a query parameter.
87
     *
88
     * @param string $key
89
     * @param mixed  $value
90
     */
91 76
    public function setParam($key, $value)
92
    {
93 76
        $this->params[$key] = $value;
94 76
    }
95
96
    /**
97
     * Merges new query parameters.
98
     *
99
     * @param array $params
100
     *
101
     * @return array
102
     */
103 108
    public function setParams(array $params)
104
    {
105 108
        $this->params = $params;
106 108
    }
107
108
    /**
109
     * Merges new query parameters.
110
     *
111
     * @param array $params
112
     *
113
     * @return array
114
     */
115 108
    public function addParams(array $params)
116
    {
117 108
        $this->params = array_merge($this->params, $params);
118 108
    }
119
120
    /**
121
     * @var Logger
122
     */
123
    protected $error_handler = null;
124
125 4
    public function setErrorHandler(LoggerInterface $logger)
126
    {
127 4
        $this->error_handler = $logger;
0 ignored issues
show
Documentation Bug introduced by
It seems like $logger of type object<Apix\Log\Logger\LoggerInterface> is incompatible with the declared type object<Apix\Log\Logger> of property $error_handler.

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...
128 4
    }
129
130
    /**
131
     * Returns the.
132
     */
133 8
    public function getErrorHandler()
134
    {
135 8
        $this->error_handler = $this->error_handler ?: new Logger\ErrorLog('/dev/stdout');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->error_handler ?: ...ErrorLog('/dev/stdout') can also be of type object<Apix\Log\Logger\ErrorLog>. However, the property $error_handler is declared as type object<Apix\Log\Logger>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
136
137 8
        return $this->error_handler;
138
    }
139
140
    /**
141
     * Handle error.
142
     *
143
     * @param string $code
144
     * @param string $msg
145
     */
146 4
    public function handleError($code, $msg)
147
    {
148 4
        $logger = $this->getErrorHandler();
149 4
        $logger->error(
150 4
            '{0} - {1} - Code #{2}',
151 4
            array(get_class($this), $msg, $code)
152 3
        );
153 4
    }
154
}
155