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/ReservedIp.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
/*
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\ReservedIp as ReservedIpEntity;
13
use Vultr\Exception\HttpException;
14
15
/**
16
 * @author Albert Leitato <[email protected]>
17
 */
18
class ReservedIp extends AbstractApi
19
{
20
    /**
21
     * List all the active reserved IPs on this account.
22
     *
23
     * @return ReservedIpEntity[]
24
     */
25
    public function list()
26
    {
27
        $response = $this->adapter->get(\sprintf('%s/reservedip/list', $this->endpoint));
28
29
        $ips = \json_decode($response);
30
31
        $this->extractMeta($ips);
0 ignored issues
show
The method extractMeta() does not seem to exist on object<Vultr\Api\ReservedIp>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
33
        return \array_map(function ($ip) {
34
            return new ReservedIpEntity($ip);
35
        }, $ips);
36
    }
37
38
    /**
39
     * Create a new reserved IP.
40
     *
41
     * Reserved IPs can only be used within the same datacenter for which
42
     * they were created.
43
     *
44
     * @param int    $dcId
45
     * @param string $ipType
46
     * @param string $label
47
     *
48
     * @throws HttpException
49
     *
50
     * @return FloatingIpEntity
51
     */
52
    public function create($dcId, $ipType, $label = null)
53
    {
54
        $content = [
55
            'DCID'    => $dcId,
56
            'ip_type' => $ipType,
57
        ];
58
        if (null !== $label) {
59
            $content['label'] = $label;
60
        }
61
        $response = $this->adapter->post(\sprintf('%s/reservedip/create', $this->endpoint), $content);
62
63
        return \json_decode($response);
64
    }
65
66
    /**
67
     * Remove a reserved IP from your account.
68
     *
69
     * After making this call, you will not be able to recover the IP address.
70
     *
71
     * @param int $ipAddressipAddress
72
     *
73
     * @throws HttpException
74
     */
75
    public function delete($ipAddressipAddress)
76
    {
77
        $this->adapter->delete(\sprintf('%s/reservedip/destroy', $this->endpoint), ['ip_address' => $ipAddressipAddress]);
0 ignored issues
show
The call to AdapterInterface::delete() has too many arguments starting with array('ip_address' => $ipAddressipAddress).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
78
    }
79
80
    /**
81
     * Convert an existing IP on a subscription to a reserved IP.
82
     *
83
     * @param int    $serverId  SUBID of the server that currently has the IP address
0 ignored issues
show
There is no parameter named $serverId. Did you maybe mean $serverIdd?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
84
     * @param string $ipAddress IP address you want to convert
85
     * @param string $paramname Label for this reserved IP
0 ignored issues
show
There is no parameter named $paramname. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
86
     *
87
     * @throws HttpException
88
     */
89
    public function convert($serverIdd, $ipAddress, $label = null)
90
    {
91
        $content = [
92
            'SUBID'      => $serverIdd,
93
            'ip_address' => $ipAddress,
94
        ];
95
        if (null !== $label) {
96
            $content['label'] = $label;
97
        }
98
        $this->adapter->post(\sprintf('%s/reservedip/conver', $this->endpoint), $content);
99
    }
100
101
    /**
102
     * Attach a reserved IP to an existing subscription.
103
     *
104
     * @param int $ipAddress Reserved IP to attach to your account
105
     * @param int $serverId  Server to attach the reserved IP to
106
     *
107
     * @throws HttpException
108
     *
109
     * @return ActionEntity
110
     */
111
    public function attach($ipAddress, $serverId)
112
    {
113
        return $this->executeAction($ipAddress, $serverId, 'attach');
114
    }
115
116
    /**
117
     * @param int $ipAddress
118
     * @param int $serverId
119
     *
120
     * @throws HttpException
121
     */
122
    public function detach($ipAddress, $serverId)
123
    {
124
        return $this->executeAction($ipAddress, $serverId, 'detach');
125
    }
126
127
    /**
128
     * Detach a reserved IP from an existing subscription.
129
     *
130
     * @param string $ipAddress
131
     * @param int    $serverId
132
     * @param string $action
133
     *
134
     * @throws HttpException
135
     */
136
    private function executeAction($ipAddress, $serverId, $action)
137
    {
138
        return $this->adapter->post(\sprintf('%s/reservedip/' . $action, $this->endpoint), ['ip_address' => $ipAddress, 'attach_SUBID' => $serverId]);
139
    }
140
}
141