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/FirewallGroup.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
11
namespace Vultr\Api;
12
13
use Vultr\Entity\FirewallGroup as FirewallGroupEntity;
14
use Vultr\Exceptions\EntityNotFoundException;
15
16
/**
17
 * @author Albert Leitato <[email protected]>
18
 */
19
class FirewallGroup extends AbstractApi
20
{
21
    /**
22
     * List all firewall groups on the current account.
23
     *
24
     * @return FirewallGroupEntity
25
     */
26
    public function list()
27
    {
28
        $response = $this->getAny();
29
30
        return $this->handleResponse($response, self::class, true);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->handleResponse($r...se, self::class, true); of type array|object adds the type array to the return on line 30 which is incompatible with the return type documented by Vultr\Api\FirewallGroup::list of type Vultr\Entity\FirewallGroup.
Loading history...
31
    }
32
33
    /**
34
     * Get a firewall group by its id.
35
     *
36
     * @param string $groupId ID for the firewall group
37
     *
38
     * @return FirewallGroupEntity
39
     *
40
     * @throws EntityNotFoundException
41
     **/
42
    public function getById($groupId)
43
    {
44
        $response = $this->getAny($groupId);
45
        $object = \json_decode($response);
46
        try {
47
            $group = $object->$groupId;
48
        } catch (\Exception $e) {
0 ignored issues
show
catch (\Exception $e) { ...on($e->getMessage()); } 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...
49
            throw new EntityNotFoundException($e->getMessage());
50
        }
51
52
        return new FirewallGroupEntity($group);
53
    }
54
55
    /**
56
     * Get a firewall group by its id.
57
     *
58
     * @param string $groupId ID for the firewall group
59
     *
60
     * @return string API response
61
     */
62
    protected function getAny($groupId = null)
63
    {
64
        $params = null !== $groupId ? '?FIREWALLGROUPID=%s' : '';
65
66
        return $this->adapter->get(\sprintf('%s/firewall/group_list'.$params, $this->endpoint, $groupId));
67
    }
68
69
    /**
70
     * Create a new firewall group on the current account.
71
     *
72
     * @param string $description Description of firewall group
73
     *
74
     * @return FirewallGroupEntity
75
     **/
76
    public function create($description = null)
77
    {
78
        $response = $this->adapter->post(sprintf('%s/firewall/group_create', $this->endpoint), http_build_query(compact('description')));
79
        $object = json_decode($response);
80
81
        return $this->getById($object->FIREWALLGROUPID);
82
    }
83
84
    /**
85
     * Change the description on a firewall group.
86
     *
87
     * @param string $groupId     Firewall group to update
88
     * @param string $description Description of firewall group
89
     *
90
     * @throws HttpException
91
     */
92 View Code Duplication
    public function setDescription($groupId, $description)
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...
93
    {
94
        $data = [
95
            'FIREWALLGROUPID' => $groupId,
96
            'description' => $description,
97
        ];
98
        $this->adapter->post(\sprintf('%s/firewall/group_set_description', $this->endpoint), $data);
99
    }
100
101
    /**
102
     * Delete a firewall group.
103
     *
104
     * Use this function with caution because the firewall group being deleted
105
     * will be detached from all servers. This can result in open ports accessible
106
     * to the internet
107
     *
108
     * @param string $groupId Firewall group to delete
109
     *
110
     * @throws HttpException
111
     */
112
    public function delete($groupId)
113
    {
114
        $data = [
115
            'FIREWALLGROUPID' => $groupId,
116
        ];
117
        $this->adapter->post(\sprintf('%s/firewall/group_delete', $this->endpoint), $data);
118
    }
119
}
120