Issues (36)

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/Request/Batch.php (5 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 Cassandra\Request;
3
use Cassandra\Protocol\Frame;
4
use Cassandra\Protocol;
5
use Cassandra\Connection;
6
use Cassandra\Type;
7
8
class Batch extends Request{
9
    const TYPE_LOGGED = 0;
10
    const TYPE_UNLOGGED = 1;
11
    const TYPE_COUNTER = 2;
12
    
13
    protected $opcode = Frame::OPCODE_BATCH;
14
    
15
    /**
16
     * @var array
17
     */
18
    protected $_queryArray = [];
19
20
    /**
21
     * @var int
22
     */
23
    protected $_batchType;
24
    
25
    /**
26
     * 
27
     * @var int
28
     */
29
    protected $_consistency;
30
    
31
    /**
32
     * 
33
     * @var array
34
     */
35
    protected $_options;
36
    
37
    /**
38
     * 
39
     * @param string $type
40
     * @param string $consistency
41
     * @param array $options
42
     */
43
    public function __construct($type = null, $consistency = null, $options = []) {
44
        $this->_batchType = $type === null ? Batch::TYPE_LOGGED : $type;
45
        $this->_consistency = $consistency === null ? Request::CONSISTENCY_ONE : $consistency;
46
        $this->_options = $options;
47
    }
48
49
    /**
50
     * Exec transaction
51
     */
52
    public function getBody() {
53
        return pack('C', $this->_batchType)
54
            . pack('n', count($this->_queryArray)) . implode('', $this->_queryArray)
55
            . self::queryParameters($this->_consistency, $this->_options);
56
    }
57
58
    /**
59
     * @param string $cql
60
     * @param array $values
61
     * @return self
62
     */
63 View Code Duplication
    public function appendQuery($cql, array $values = []) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
        $binary = pack('C', 0);
65
    
66
        $binary .= pack('N', strlen($cql)) . $cql;
67
        $binary .= Request::valuesBinary($values, !empty($this->_options['names_for_values']));
68
        
69
        $this->_queryArray[] = $binary;
70
        
71
        return $this;
72
    }
73
    
74
    /**
75
     * 
76
     * @param string $queryId
77
     * @param array $values
78
     * @return self
79
     */
80 View Code Duplication
    public function appendQueryId($queryId, array $values = []) {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
        $binary = pack('C', 1);
82
        
83
        $binary .= pack('n', strlen($queryId)) . $queryId;
84
        $binary .= Request::valuesBinary($values, !empty($this->_options['names_for_values']));
85
        
86
        $this->_queryArray[] = $binary;
87
        
88
        return $this;
89
    }
90
    
91
    /**
92
     *
93
     * @param int $consistency
94
     * @param array $options
95
     * @return string
96
     */
97
    public static function queryParameters($consistency, array $options = []){
98
        $flags = 0;
99
        $optional = '';
100
    
101 View Code Duplication
        if (isset($options['serial_consistency'])) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
102
            $flags |= Query::FLAG_WITH_SERIAL_CONSISTENCY;
103
            $optional .= pack('n', $options['serial_consistency']);
104
        }
105
    
106 View Code Duplication
        if (isset($options['default_timestamp'])) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
107
            $flags |= Query::FLAG_WITH_DEFAULT_TIMESTAMP;
108
            $optional .= Type\Bigint::binary($options['default_timestamp']);
109
        }
110
    
111
        if (!empty($options['names_for_values'])){
112
            /**
113
             * @link https://github.com/duoshuo/php-cassandra/issues/40
114
             */
115
            throw new \Cassandra\Exception('NAMES_FOR_VALUES in batch request seems never work in Cassandra 2.1.x.  Keep NAMES_FOR_VALUES flag false to avoid this bug.');
116
            
117
            $flags |= Query::FLAG_WITH_NAMES_FOR_VALUES;
0 ignored issues
show
$flags |= \Cassandra\Req..._WITH_NAMES_FOR_VALUES; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
118
        }
119
        
120
        return pack('n', $consistency) . pack('C', $flags) . $optional;
121
    }
122
}
123