Issues (318)

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/Resources/Engagements.php (10 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
namespace SevenShores\Hubspot\Resources;
4
5
use SevenShores\Hubspot\Exceptions\BadRequest;
6
7
class Engagements extends Resource
8
{
9
    /**
10
     * @param array $engagement Array of engagement engagement.
11
     * @param array $associations Array of engagement associations.
12
     * @param array $metadata Array of engagement metadata.
13
     * @param array $attachments Array of engagement attachments.
14
     * @return \SevenShores\Hubspot\Http\Response
15
     */
16
    function create($engagement, $associations, $metadata, $attachments = array())
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
17
    {
18
        $endpoint = "https://api.hubapi.com/engagements/v1/engagements";
19
20
        $options['json'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
21
            'engagement' => $engagement,
22
            'associations' => $associations,
23
            'metadata' => $metadata,
24
            'attachments' => $attachments
25
        ];
26
27
        return $this->client->request('post', $endpoint, $options);
28
    }
29
30
    /**
31
     * Returns all recently created or updated engagements.
32
     *
33
     * @param array $params Array of optional parameters ['count', 'offset', 'since]
34
     *
35
     * @see https://developers.hubspot.com/docs/methods/engagements/get-recent-engagements
36
     *
37
     * @return \SevenShores\Hubspot\Http\Response
38
     */
39
    function recent($params = [])
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
40
    {
41
        $endpoint = 'https://api.hubapi.com/engagements/v1/engagements/recent/modified';
42
43
        $queryString = build_query_string($params);
44
45
        return $this->client->request('get', $endpoint, [], $queryString);
46
    }
47
48
    /**
49
     * @param int $id The engagement id.
50
     * @param array $engagement The engagement engagement to update.
51
     * @param array $metadata The engagement metadata to update.
52
     * @param string $method
53
     * @return \SevenShores\Hubspot\Http\Response
54
     * @throws \SevenShores\Hubspot\Exceptions\BadRequest
55
     */
56
    function update($id, $engagement, $metadata, $method = 'patch')
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
57
    {
58
        $availableMethods = ['put', 'patch'];
59
60
        if (! \in_array($method, $availableMethods)) {
61
            throw new BadRequest('Method name '.$method.' is invalid', 400);
62
        }
63
        $endpoint = "https://api.hubapi.com/engagements/v1/engagements/{$id}";
64
65
        $options['json'] = [
0 ignored issues
show
Coding Style Comprehensibility introduced by
$options was never initialized. Although not strictly required by PHP, it is generally a good practice to add $options = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
66
            'engagement' => $engagement,
67
            'metadata' => $metadata,
68
        ];
69
70
        return $this->client->request($method, $endpoint, $options);
71
    }
72
73
    /**
74
     * @param int $id
75
     * @return \SevenShores\Hubspot\Http\Response
76
     */
77
    function delete($id)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
78
    {
79
        $endpoint = "https://api.hubapi.com/engagements/v1/engagements/{$id}";
80
81
        return $this->client->request('delete', $endpoint);
82
    }
83
84
    /**
85
     * @param int $id
86
     * @return \SevenShores\Hubspot\Http\Response
87
     */
88
    function get($id)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
89
    {
90
        $endpoint = "https://api.hubapi.com/engagements/v1/engagements/{$id}";
91
92
        return $this->client->request('get', $endpoint);
93
    }
94
95
    /**
96
     * Returns all engagements.
97
     *
98
     * @param array $params Array of optional parameters ['limit', 'offset']
99
     *
100
     * @see http://developers.hubspot.com/docs/methods/engagements/get-all-engagements
101
     *
102
     * @return \SevenShores\Hubspot\Http\Response
103
     */
104
    public function all($params = [])
105
    {
106
        $endpoint = 'https://api.hubapi.com/engagements/v1/engagements/paged';
107
108
        $queryString = build_query_string($params);
109
110
        return $this->client->request('get', $endpoint, [], $queryString);
111
    }
112
113
    /**
114
     * @param int $id
115
     * @param string $object_type
116
     * @param int $object_id
117
     * @return \SevenShores\Hubspot\Http\Response
118
     **/
119
    function associate($id, $object_type, $object_id)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
120
    {
121
        $endpoint = "https://api.hubapi.com/engagements/v1/engagements/{$id}/associations/{$object_type}/{$object_id}";
122
123
        return $this->client->request('put', $endpoint);
124
    }
125
126
    /**
127
     * @param string $object_type
128
     * @param int $object_id
129
     * @param array $params Array of optional parameters ['limit', 'offset']
130
     * @return \SevenShores\Hubspot\Http\Response
131
     **/
132
    function associated($object_type, $object_id, $params = [])
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
133
    {
134
        $endpoint = "https://api.hubapi.com/engagements/v1/engagements/associated/{$object_type}/{$object_id}/paged";
135
        $queryString = build_query_string($params);
136
        return $this->client->request('get', $endpoint, [], $queryString);
137
    }
138
139
    /**
140
     * @return \SevenShores\Hubspot\Http\Response
141
     */
142
    function activityTypes()
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
143
    {
144
        $endpoint = "https://api.hubapi.com/engagements/v1/activity-types";
145
146
        return $this->client->request('get', $endpoint);
147
    }
148
}
149