Issues (1131)

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/logging/ScribeLoggerAppender.class.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
namespace Agavi\Logging;
3
4
// +---------------------------------------------------------------------------+
5
// | This file is part of the Agavi package.                                   |
6
// | Copyright (c) 2005-2011 the Agavi Project.                                |
7
// |                                                                           |
8
// | For the full copyright and license information, please view the LICENSE   |
9
// | file that was distributed with this source code. You can also view the    |
10
// | LICENSE file online at http://www.agavi.org/LICENSE.txt                   |
11
// |   vi: set noexpandtab:                                                    |
12
// |   Local Variables:                                                        |
13
// |   indent-tabs-mode: t                                                     |
14
// |   End:                                                                    |
15
// +---------------------------------------------------------------------------+
16
use Agavi\Exception\LoggingException;
17
18
/**
19
 * ScribeLoggerAppender sends LoggerMessages to a Scribe server or an
20
 * interface using the Scribe Thrift protocol (Facebook Scribe, Cloudera Flume).
21
 *
22
 * Configuration parameters:
23
 *  'buffer'                 - Whether or not to buffer all messages and only
24
 *                             send them on shutdown. Defaults to false.
25
 *  'default_category'       - Default scribe category for messages ("default"),
26
 *                             can be overriden in a message using parameter
27
 *                             "scribe_category".
28
 *  'socket_host'            - Hostname of scribe server (default "localhost")
29
 *  'socket_port'            - Port of scribe server (default 1463)
30
 *  'socket_persist'         - Whether to use persistent conns (default false)
31
 *  'socket_timeout'         - Socket timeout in seconds (default The thrift default)
32
 *  'transport_strict_read'  - Strict protocol reads (default false)
33
 *  'transport_strict_write' - Strict protocol writes (default true)
34
 *
35
 * @package    agavi
36
 * @subpackage logging
37
 *
38
 * @author     David Zülke <[email protected]>
39
 * @copyright  Authors
40
 * @copyright  The Agavi Project
41
 *
42
 * @since      1.0.4
43
 *
44
 * @version    $Id$
45
 */
46
class ScribeLoggerAppender extends LoggerAppender
47
{
48
    /**
49
     * @var        scribeClient The scribeClient instance to write to.
50
     */
51
    protected $scribeClient = null;
52
    
53
    /**
54
     * @var        TTransport The Thrift transport instance to use.
55
     */
56
    protected $transport = null;
57
    
58
    /**
59
     * @var        array A buffer of messages to log
60
     */
61
    protected $buffer = array();
62
    
63
    /**
64
     * Retrieve the scribeClient instance to write to.
65
     *
66
     * @return     scribeClient The scribeClient instance to write to.
67
     *
68
     * @author     David Zülke <[email protected]>
69
     * @since      1.0.4
70
     */
71
    protected function getScribeClient()
72
    {
73
        if (!$this->scribeClient) {
74
            $socketClass = $this->getParameter('socket_class', 'TSocket');
75
            $socket = new $socketClass($this->getParameter('socket_host', 'localhost'), $this->getParameter('socket_port', 1463), $this->getParameter('socket_persist', false));
76
            if ($this->hasParameter('socket_timeout')) {
77
                // setRecvTimeout takes milliseconds
78
                $socket->setRecvTimeout(1000 * $this->getParameter('socket_timeout'));
79
            }
80
            
81
            $transportClass = $this->getParameter('transport_class', 'TFramedTransport');
82
            $this->transport = new $transportClass($socket);
83
            
84
            $protocolClass = $this->getParameter('protocol_class', 'TBinaryProtocol');
85
            $protocol = new $protocolClass($this->transport, $this->getParameter('transport_strict_read', false), $this->getParameter('transport_strict_write', true));
86
            
87
            $clientClass = $this->getParameter('client_class', 'scribeClient');
88
            $this->scribeClient = new $clientClass($protocol, $protocol);
89
            
90
            try {
91
                $this->transport->open();
92
            } catch (TException $e) {
0 ignored issues
show
The class Agavi\Logging\TException 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...
93
                $this->scribeClient = null;
94
                $this->transport = null;
95
                throw new LoggingException(sprintf("Failed to connect to Scribe server:\n\n%s", $e->getMessage()), 0, $e);
96
            }
97
        }
98
        
99
        return $this->scribeClient;
100
    }
101
102
    /**
103
     * Execute the shutdown procedure.
104
     *
105
     * Tells the Scribe client to flush and send a shutdown command.
106
     * Underlying sockets will be auto-closed at the end of the script.
107
     *
108
     * @author     David Zülke <[email protected]>
109
     * @since      1.0.4
110
     */
111
    public function shutdown()
112
    {
113
        try {
114
            $this->flush();
115
        } catch (LoggingException $e) {
116
            // not much we can do at this point...
117
        }
118
        if ($this->transport) {
119
            $this->transport->close();
120
        }
121
    }
122
123
    /**
124
     * Write log data to this appender.
125
     *
126
     * @param      LoggerMessage $message Log data to be written.
127
     *
128
     * @throws     LoggingException if no Layout is set or the stream
129
     *                                          cannot be written.
130
     *
131
     *
132
     * @author     David Zülke <[email protected]>
133
     * @since      1.0.4
134
     */
135
    public function write(LoggerMessage $message)
136
    {
137
        if (($layout = $this->getLayout()) === null) {
138
            throw new LoggingException('No Layout set');
139
        }
140
        
141
        $this->buffer[] = new LogEntry(array(
142
            'category' => $message->getParameter('scribe.category', $this->getParameter('default_category', 'default')),
143
            'message' => (string)$this->getLayout()->format($message),
144
        ));
145
        
146
        if (!$this->getParameter('buffer', false)) {
147
            $this->flush();
148
        }
149
    }
150
    
151
    /**
152
     * Send buffer contents if there are any.
153
     *
154
     * @author     David Zülke <[email protected]>
155
     * @since      1.0.4
156
     */
157
    protected function flush()
158
    {
159
        if (!$this->buffer) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->buffer 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...
160
            // nothing to send
161
            return;
162
        }
163
        
164
        $this->getScribeClient()->Log($this->buffer);
165
        
166
        $this->buffer = array();
167
    }
168
}
169