Issues (24)

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/MakesHttpRequests.php (4 issues)

Severity

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
namespace TestMonitor\ActiveCampaign;
4
5
use Psr\Http\Message\ResponseInterface;
6
use TestMonitor\ActiveCampaign\Exceptions\NotFoundException;
7
use TestMonitor\ActiveCampaign\Exceptions\ValidationException;
8
use TestMonitor\ActiveCampaign\Exceptions\FailedActionException;
9
10
/**
11
 * Class MakesHttpRequests.
12
 *
13
 * @property \GuzzleHttp\Client $guzzle
14
 */
15
trait MakesHttpRequests
16
{
17
    /**
18
     * Make a GET request to ActiveCampaign and return the response.
19
     *
20
     * @param  string $uri
21
     * @param array $payload
22
     *
23
     * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException
24
     * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException
25
     * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException
26
     *
27
     * @return mixed
28
     */
29
    private function get($uri, $payload = [])
0 ignored issues
show
This method is not used, and could be removed.
Loading history...
30
    {
31
        return $this->request('GET', $uri, $payload);
32
    }
33
34
    /**
35
     * Make a POST request to ActiveCampaign and return the response.
36
     *
37
     * @param  string $uri
38
     * @param  array $payload
39
     *
40
     * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException
41
     * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException
42
     * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException
43
     *
44
     * @return mixed
45
     */
46
    private function post($uri, array $payload = [])
0 ignored issues
show
This method is not used, and could be removed.
Loading history...
47
    {
48
        return $this->request('POST', $uri, $payload);
49
    }
50
51
    /**
52
     * Make a PUT request to ActiveCampaign and return the response.
53
     *
54
     * @param  string $uri
55
     * @param  array $payload
56
     *
57
     * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException
58
     * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException
59
     * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException
60
     *
61
     * @return mixed
62
     */
63
    private function put($uri, array $payload = [])
0 ignored issues
show
This method is not used, and could be removed.
Loading history...
64
    {
65
        return $this->request('PUT', $uri, $payload);
66
    }
67
68
    /**
69
     * Make a DELETE request to ActiveCampaign and return the response.
70
     *
71
     * @param  string $uri
72
     * @param  array $payload
73
     *
74
     * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException
75
     * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException
76
     * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException
77
     *
78
     * @return mixed
79
     */
80
    private function delete($uri, array $payload = [])
0 ignored issues
show
This method is not used, and could be removed.
Loading history...
81
    {
82
        return $this->request('DELETE', $uri, $payload);
83
    }
84
85
    /**
86
     * Make request to ActiveCampaign and return the response.
87
     *
88
     * @param  string $verb
89
     * @param  string $uri
90
     * @param  array $payload
91
     *
92
     * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException
93
     * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException
94
     * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException
95
     *
96
     * @return mixed
97
     */
98
    private function request($verb, $uri, array $payload = [])
99
    {
100
        $response = $this->guzzle->request(
101
            $verb,
102
            $uri,
103
            $payload
104
        );
105
106
        if (! in_array($response->getStatusCode(), [200, 201])) {
107
            return $this->handleRequestError($response);
108
        }
109
110
        $responseBody = (string) $response->getBody();
111
112
        return json_decode($responseBody, true) ?: $responseBody;
113
    }
114
115
    /**
116
     * @param  \Psr\Http\Message\ResponseInterface $response
117
     *
118
     * @throws \TestMonitor\ActiveCampaign\Exceptions\ValidationException
119
     * @throws \TestMonitor\ActiveCampaign\Exceptions\NotFoundException
120
     * @throws \TestMonitor\ActiveCampaign\Exceptions\FailedActionException
121
     * @throws \Exception
122
     *
123
     * @return void
124
     */
125
    private function handleRequestError(ResponseInterface $response)
126
    {
127
        if ($response->getStatusCode() == 422) {
128
            throw new ValidationException(json_decode((string) $response->getBody(), true));
129
        }
130
131
        if ($response->getStatusCode() == 404) {
132
            throw new NotFoundException();
133
        }
134
135
        if ($response->getStatusCode() == 400) {
136
            throw new FailedActionException((string) $response->getBody());
137
        }
138
139
        throw new \Exception((string) $response->getBody());
140
    }
141
}
142