Issues (64)

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/Api/Block.php (3 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
 *   This file is part of the Vultr PHP library.
4
 *
5
 *   (c) Albert Leitato <[email protected]>
6
 *
7
 *   For the full copyright and license information, please view the LICENSE
8
 *   file that was distributed with this source code.
9
 */
10
namespace Vultr\Api;
11
12
use Vultr\Entity\Block as BlockEntity;
13
14
/**
15
 * @author Albert Leitato <[email protected]>
16
 */
17
class Block extends AbstractApi
18
{
19
    /**
20
     * Retrieve a list of any active block storage subscriptions on this account.
21
     *
22
     * @return BlockEntity
23
     */
24
    public function list()
25
    {
26
        $blocks = $this->adapter->get(\sprintf('%s/block/list', $this->endpoint));
27
28
        $blocks = \json_decode($blocks, true);
29
30
        return \array_map(function ($block) {
31
            return new BlockEntity($block);
32
        }, $blocks);
33
    }
34
35
    /**
36
     * Retrieve a list of any active block storage subscriptions on this account
37
     *
38
     * @return BlockEntity
39
     *
40
     * @param int $subId Id for the Block storage
41
     */
42
    public function getById($subId)
43
    {
44
        $response = $this->adapter->get(\sprintf('%s/block/list?SUBID=%d', $this->endpoint, $subId));
45
46
        return $this->handleResponse($response, BlockEntity::class);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->handleResponse($r...r\Entity\Block::class); of type array|object adds the type array to the return on line 46 which is incompatible with the return type documented by Vultr\Api\Block::getById of type Vultr\Entity\Block.
Loading history...
47
    }
48
49
    /**
50
     * Create a block storage subscription.
51
     *
52
     * @param int    $dc_id DCID of the location to create this subscription in
53
     * @param int    $size  size (in GB) of this subscription
54
     * @param string $label Text label that will be associated with the subscription
55
     **/
56
    public function create($dc_id, int $size, $label = '')
57
    {
58
        $data = [
59
            'DCID'    => $dc_id,
60
            'size_gb' => $size,
61
        ];
62
        if (!empty($label)) {
63
            $data['label'] = $label;
64
        }
65
        $response = $this->adapter->post(\sprintf('%s/block/create', $this->endpoint), http_build_query($data));
66
67
        return \json_decode($response);
68
    }
69
70
    /**
71
     * Delete a block storage subscription. All data will be permanently lost.
72
     *
73
     * There is no going back from this call.
74
     *
75
     * @param int $subid ID of the block storage subscription to delete
76
     *
77
     * @throws HttpException
78
     */
79
    public function delete($subid)
80
    {
81
        $this->adapter->post(\sprintf('%s/block/delete', $this->endpoint), http_build_query(['SUBID' => $subid]));
82
    }
83
84
    /**
85
     * Detach a block storage subscription from the currently attached instance.
86
     *
87
     * @param int $subid ID of the block storage subscription to detach
88
     *
89
     * @throws HttpException
90
     */
91
    public function detach($subid)
92
    {
93
        $this->adapter->post(\sprintf('%s/block/detach', $this->endpoint), http_build_query(['SUBID' => $subid]));
94
    }
95
96
    /**
97
     * Set the label of a block storage subscription.
98
     *
99
     * @param int    $subid ID of the block storage subscription to detach
100
     * @param string $label Text label that will be shown in the control panel
101
     *
102
     * @throws HttpException
103
     */
104 View Code Duplication
    public function labelSet($subid, $label)
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...
105
    {
106
        $data = [
107
            'SUBID' => $subid,
108
            'label' => $label,
109
        ];
110
        $this->adapter->post(\sprintf('%s/block/label_set', $this->endpoint), http_build_query($data));
111
    }
112
113
    /**
114
     * Resize the block storage volume to a new size.
115
     *
116
     * WARNING: When shrinking the volume,
117
     * you must manually shrink the filesystem and partitions beforehand,
118
     * or you will lose data.
119
     *
120
     * @param int    $subid ID of the block storage subscription to resize
121
     * @param string $size  New size (in GB) of the block storage subscription
122
     *
123
     * @throws HttpException
124
     */
125 View Code Duplication
    public function resize($subid, $size)
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...
126
    {
127
        $data = [
128
            'SUBID'   => $subid,
129
            'size_gb' => $size,
130
        ];
131
        $this->adapter->post(\sprintf('%s/block/resize', $this->endpoint), http_build_query($data));
132
    }
133
}
134