Issues (5)

Security Analysis    not enabled

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/Services/Tickets.php (1 issue)

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 DigitalEquation\Teamwork\Services;
4
5
use DigitalEquation\Teamwork\Exceptions\TeamworkHttpException;
6
use DigitalEquation\Teamwork\Exceptions\TeamworkParameterException;
7
use GuzzleHttp\Client;
8
use GuzzleHttp\Exception\ClientException;
9
use GuzzleHttp\Psr7\Response;
10
use GuzzleHttp\Psr7\Stream;
11
12
class Tickets
13
{
14
    /**
15
     * @var \GuzzleHttp\Client
16
     */
17
    private Client $client;
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
18
19
    /**
20
     * Tickets constructor.
21
     *
22
     * @param \GuzzleHttp\Client $client
23
     */
24
    public function __construct(Client $client)
25
    {
26
        $this->client = $client;
27
    }
28
29
    /**
30
     * Get tickets priorities.
31
     *
32
     * @return array
33
     * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException
34
     * @throws \GuzzleHttp\Exception\GuzzleException
35
     * @throws \JsonException
36
     */
37
    public function priorities(): array
38
    {
39
        try {
40
            /** @var Response $response */
41
            $response = $this->client->get('ticketpriorities.json');
42
            /** @var Stream $body */
43
            $body = $response->getBody();
44
45
            return json_decode($body->getContents(), true, 512, JSON_THROW_ON_ERROR);
46
        } catch (ClientException $e) {
47
            throw new TeamworkHttpException($e->getMessage(), 400);
48
        }
49
    }
50
51
    /**
52
     * Get a list of tickets for a customer.
53
     *
54
     * @param int $customerId
55
     *
56
     * @return array
57
     * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException
58
     * @throws \GuzzleHttp\Exception\GuzzleException
59
     * @throws \JsonException
60
     */
61
    public function customer(int $customerId): array
62
    {
63
        try {
64
            /** @var Response $response */
65
            $response = $this->client->get(sprintf('customers/%s/previoustickets.json', $customerId));
66
            /** @var Stream $body */
67
            $body = $response->getBody();
68
69
            return json_decode($body->getContents(), true, 512, JSON_THROW_ON_ERROR);
70
        } catch (ClientException $e) {
71
            throw new TeamworkHttpException($e->getMessage(), 400);
72
        }
73
    }
74
75
    /**
76
     * Send a ticket to teamwork desk.
77
     *
78
     * @param array $data
79
     *
80
     * @return array
81
     * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException
82
     * @throws \GuzzleHttp\Exception\GuzzleException
83
     * @throws \JsonException
84
     */
85
    public function post(array $data): array
86
    {
87
        try {
88
            /** @var Response $response */
89
            $response = $this->client->post('tickets.json', [
90
                'form_params' => $data,
91
            ]);
92
93
            /** @var Stream $body */
94
            $body = $response->getBody();
95
96
            return json_decode($body->getContents(), true, 512, JSON_THROW_ON_ERROR);
97
        } catch (ClientException $e) {
98
            throw new TeamworkHttpException($e->getMessage(), 400);
99
        }
100
    }
101
102
    /**
103
     * Post a reply to a ticket.
104
     *
105
     * @param array $data
106
     *
107
     * @return array
108
     * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException
109
     * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkParameterException
110
     * @throws \GuzzleHttp\Exception\GuzzleException
111
     * @throws \JsonException
112
     */
113
    public function reply(array $data): array
114
    {
115
        if (empty($data['ticketId'])) {
116
            throw new TeamworkParameterException('The `reply` method expects the passed array param to contain `ticketId`', 400);
117
        }
118
119
        try {
120
            /** @var Response $response */
121
            $response = $this->client->post(sprintf('tickets/%s.json', $data['ticketId']), [
122
                'form_params' => $data,
123
            ]);
124
125
            /** @var Stream $body */
126
            $body = $response->getBody();
127
128
            return json_decode($body->getContents(), true, 512, JSON_THROW_ON_ERROR);
129
        } catch (ClientException $e) {
130
            throw new TeamworkHttpException($e->getMessage());
131
        }
132
    }
133
134
    /**
135
     * Get ticket by id.
136
     *
137
     * @param int $ticketId
138
     *
139
     * @return array
140
     * @throws \DigitalEquation\Teamwork\Exceptions\TeamworkHttpException
141
     * @throws \GuzzleHttp\Exception\GuzzleException
142
     * @throws \JsonException
143
     */
144
    public function ticket(int $ticketId): array
145
    {
146
        try {
147
            /** @var Response $response */
148
            $response = $this->client->get(sprintf('tickets/%s.json', $ticketId));
149
            /** @var Stream $body */
150
            $body = $response->getBody();
151
152
            return json_decode($body->getContents(), true, 512, JSON_THROW_ON_ERROR);
153
        } catch (ClientException $e) {
154
            throw new TeamworkHttpException($e->getMessage(), 400);
155
        }
156
    }
157
}
158