GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (7)

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/ZMQHandler.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
2
namespace Bankiru\MonologLogstash;
3
4
use Monolog\Handler\AbstractProcessingHandler;
5
use Monolog\Logger;
6
use Psr\Log\InvalidArgumentException;
7
8
class ZMQHandler extends AbstractProcessingHandler
9
{
10
    protected $dsn;
11
    protected $persistent;
12
    protected $options = array();
13
    protected $socketType;
14
    protected $socketOptions = array();
15
    /** @var \ZMQSocket */
16
    private $socket;
17
18
    /**
19
     * @param int $dsn
20
     * @param bool $persistent
21
     * @param array $options
22
     * @param $socketType
23
     * @param array $socketOptions
24
     * @param integer $level The minimum logging level at which this handler will be triggered
25
     * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
26
     * @throws \Psr\Log\InvalidArgumentException
27
     */
28
    public function __construct($dsn, $persistent = true, $options = array(), $socketType = \ZMQ::SOCKET_PUSH, $socketOptions = array(),
29
                         $level = Logger::DEBUG, $bubble = true)
30
    {
31
        parent::__construct($level, $bubble);
32
33
        if (!is_string($dsn) || !trim($dsn) || parse_url($dsn) === false) {
34
            throw new InvalidArgumentException('dsn is invalid');
35
        }
36
37
        if (parse_url($dsn, PHP_URL_SCHEME) != 'tcp') {
38
            throw new InvalidArgumentException('dsn has invalid schema');
39
        }
40
41
        if (!parse_url($dsn, PHP_URL_PORT)) {
42
            throw new InvalidArgumentException('no port specified in the dsn');
43
        }
44
45
        if (!preg_match('@^(/)?$@', parse_url($dsn, PHP_URL_PATH))
46
            || parse_url($dsn, PHP_URL_QUERY) != ''
47
            || parse_url($dsn, PHP_URL_FRAGMENT) != ''
48
        ) {
49
            throw new InvalidArgumentException("dsn '{$dsn}' has unexpected path or query");
50
        }
51
52
        if (!in_array($socketType, array(\ZMQ::SOCKET_PUSH, \ZMQ::SOCKET_REQ))) {
53
            throw new InvalidArgumentException('socketType is invalid');
54
        }
55
56
        $this->dsn = $dsn;
57
        $this->persistent = $persistent;
58
        $this->options = $options;
59
        $this->socketType = $socketType;
60
        $this->socketOptions = $socketOptions;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function close()
67
    {
68
        if ($this->socket instanceof \ZMQSocket && !$this->socket->isPersistent()) {
0 ignored issues
show
The class ZMQSocket does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
69
            $this->socket->disconnect($this->dsn);
70
        }
71
        $this->socket = null;
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     * @throws \RuntimeException
77
     */
78
    protected function write(array $record)
79
    {
80
        $socket = $this->getSocket();
81
        if ($socket) {
82
            try {
83
                $socket->send((string)$record['formatted'], \ZMQ::MODE_DONTWAIT);
84
            } catch (\ZMQSocketException $e) {
0 ignored issues
show
The class ZMQSocketException 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...
85
                throw new \RuntimeException(sprintf('Could not write logs to logstash through ZMQ: %s', (string)$e));
86
            }
87
        }
88
    }
89
90
    /**
91
     * @return \ZMQSocket
92
     * @throws \RuntimeException
93
     */
94
    protected function getSocket()
95
    {
96
        if ($this->socket === null) {
97
            $exception = null;
98
99
            $socketOptions = $this->socketOptions;
100
            $dsn = $this->dsn;
101
102
            $this->socket = $this->getContext()->getSocket(
103
                $this->socketType,
104
                $this->persistent ? get_class($this) : null,
105
                function (\ZMQSocket $socket) use (&$exception, $socketOptions, $dsn) {
106
                    foreach ($socketOptions as $optKey => $optValue) {
107
                        $socket->setSockOpt($optKey, $optValue);
108
                    }
109
110
                    try {
111
                        $socket->connect($dsn);
112
                    } catch (\ZMQSocketException $e) {
0 ignored issues
show
The class ZMQSocketException 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...
113
                        $exception = $e;
114
                        $socket->disconnect($dsn);
115
                    }
116
                }
117
            );
118
119
            if ($exception) {
120
                $this->socket = null;
121
                throw new \RuntimeException(sprintf('Could not connect to logstash through ZMQ: %s', (string)$exception));
122
            }
123
        }
124
125
        return $this->socket;
126
    }
127
128
    /**
129
     * @return \ZMQContext
130
     */
131
    protected function getContext()
132
    {
133
        $context = new \ZMQContext();
134
        if ($this->options && method_exists($context, 'setOpt')) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->options 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...
135
            foreach ($this->options as $optKey => $optValue) {
136
                $context->setOpt($optKey, $optValue);
137
            }
138
        }
139
140
        return $context;
141
    }
142
}
143