Issues (23)

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/AppserverIo/Messaging/MessageQueueParser.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
/**
4
 * AppserverIo\Messaging\MessageQueueParser
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/messaging
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Messaging;
22
23
use AppserverIo\Psr\Socket\SocketInterface;
24
use AppserverIo\Psr\Pms\MessageQueueException;
25
26
/**
27
 * This is a parser for a native message invocation.
28
 *
29
 * A method invokation must have the following format:
30
 *
31
 * <METHOD> <CONTENT-LENGTH> <PROTOCOL>/<VERSION>\r\n
32
 * <CONTENT>
33
 *
34
 * for example:
35
 *
36
 * MSG 12 MQ/1.0
37
 * czoxOiIxIjs=
38
 *
39
 * @author    Tim Wagner <[email protected]>
40
 * @copyright 2015 TechDivision GmbH <[email protected]>
41
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
42
 * @link      https://github.com/appserver-io/messaging
43
 * @link      http://www.appserver.io
44
 */
45
class MessageQueueParser
46
{
47
48
    /**
49
     * Parses the header of a message call call.
50
     *
51
     * @param string $line The header line to parse
52
     *
53
     * @return integer The content length to parse
54
     * @throws \AppserverIo\Psr\Pms\MessageQueueException
55
     */
56
    public function parseHeader($line)
57
    {
58
59
        // parse the header line with
60
        list ($messageType, $contentLength, $protocolVersion) = explode(' ', trim($line));
61
62
        // check protocol and version
63
        $this->checkProtocolAndVersion($protocolVersion);
64
65
        // check the message type
66
        switch ($messageType) {
0 ignored issues
show
Blank line found at start of control structure
Loading history...
67
68
            case MessageQueueProtocol::MESSAGE_TYPE_MSG:
69
                return (integer) $contentLength;
70
71
            default:
72
                throw new MessageQueueException(sprintf('Found invalid message type %s', $messageType));
73
0 ignored issues
show
Blank line found at end of control structure
Loading history...
74
        }
75
    }
76
77
    /**
78
     * Parses the request body and tries to unpack the remote method
79
     * instance from it.
80
     *
81
     * @param \AppserverIo\Psr\Socket\SocketInterface $connection    The package remote method instance
82
     * @param integer                                 $contentLength The content length to read
83
     *
84
     * @return object The unpacked message object
85
     */
86
    public function parseBody(SocketInterface $connection, $contentLength)
87
    {
88
        $rawResponse = stream_get_contents($connection->getConnectionResource(), $contentLength);
89
        return MessageQueueProtocol::unpack($rawResponse);
90
    }
91
92
    /**
93
     * Parses the message queue response and returns a response instance.
94
     *
95
     * @param string $line The response string to parse
96
     *
97
     * @return \AppserverIo\Messaging\QueueResponse The queue response instance
98
     * @throws \AppserverIo\Psr\Pms\MessageQueueException Is thrown if we found an invalid status code
99
     */
100
    public function parseResult($line)
101
    {
102
        // parse the header line with
103
        list ($protocolVersion, $statusCode, $message, ) = explode(' ', trim($line));
104
105
        // check protocol and version
106
        $this->checkProtocolAndVersion($protocolVersion);
107
108
        // prepare the queue response
109
        $responseMessages = MessageQueueProtocol::getResponseMessages();
110
        if (isset($responseMessages[$statusCode])) {
111
            return new QueueResponse($statusCode, $message);
112
        }
113
114
        // we can't prepare the queue response because of an unknown status code
115
        throw new MessageQueueException(sprintf('Found unknown status code %d', $statusCode));
116
    }
117
118
    /**
119
     * Checks if the protocol version specified in the request is valid.
120
     *
121
     * @param string $protocolVersion The protocol version specified in the request header
122
     *
123
     * @return void
124
     * @throws \AppserverIo\Psr\Pms\MessageQueueException Is thrown if the protocol version is not supported
125
     */
126
    protected function checkProtocolAndVersion($protocolVersion)
127
    {
128
129
        // parse protocol and version
130
        list ($protocol, $version) = explode('/', $protocolVersion);
131
132
        // check if protocol and version are valid
133
        if ($protocol !== MessageQueueProtocol::PROTOCOL && $version !== MessageQueueProtocol::VERSION) {
134
            throw new MessageQueueException(sprintf('Protocol %s not supported', $protocolVersion));
135
        }
136
    }
137
}
138