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/Forms.php (12 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
class Forms extends Resource
6
{
7
    /**
8
     * Submit data to a form.
9
     *
10
     * @see http://developers.hubspot.com/docs/methods/forms/submit_form
11
     *
12
     * Send form submission data to HubSpot. Form submissions from external sources can be made to any registered
13
     * HubSpot form. You can see a list of forms on your portal by going to the Contacts > Forms page
14
     *
15
     * @param int    $portal_id
16
     * @param string $form_guid
17
     * @param array  $form
18
     * @return \SevenShores\Hubspot\Http\Response
19
     */
20 View Code Duplication
    function submit($portal_id, $form_guid, $form)
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...
21
    {
22
        $endpoint = "https://forms.hubspot.com/uploads/form/v2/{$portal_id}/{$form_guid}";
23
24
        $options['form_params'] = $form;
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...
25
26
        return $this->client->request('post', $endpoint, $options, null, false);
27
    }
28
29
    /**
30
     * Return all forms that have been created in the portal.
31
     *
32
     * @see http://developers.hubspot.com/docs/methods/forms/v2/get_forms
33
     *
34
     * @return \SevenShores\Hubspot\Http\Response
35
     */
36
    function all()
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...
37
    {
38
        $endpoint = "https://api.hubapi.com/forms/v2/forms";
39
40
        return $this->client->request('get', $endpoint);
41
    }
42
43
    /**
44
     * Return a single form based on the unique ID of that form.
45
     *
46
     * @see http://developers.hubspot.com/docs/methods/forms/v2/get_form
47
     *
48
     * @param string $form_guid
49
     * @return \SevenShores\Hubspot\Http\Response
50
     */
51
    function getById($form_guid)
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...
52
    {
53
        $endpoint = "https://api.hubapi.com/forms/v2/forms/{$form_guid}";
54
55
        return $this->client->request('get', $endpoint);
56
    }
57
58
    /**
59
     * Create a new form.
60
     *
61
     * @see http://developers.hubspot.com/docs/methods/forms/v2/create_form
62
     *
63
     * @param array $form
64
     * @return \SevenShores\Hubspot\Http\Response
65
     */
66
    function create($form)
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...
67
    {
68
        $endpoint = "https://api.hubapi.com/forms/v2/forms";
69
70
        $options['json'] = $form;
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...
71
72
        return $this->client->request('post', $endpoint, $options);
73
    }
74
75
    /**
76
     * Update an existing form.
77
     *
78
     * @see http://developers.hubspot.com/docs/methods/forms/v2/update_form
79
     *
80
     * @param string $form_guid
81
     * @param array  $form
82
     * @return \SevenShores\Hubspot\Http\Response
83
     */
84 View Code Duplication
    function update($form_guid, $form)
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...
85
    {
86
        $endpoint = "https://api.hubapi.com/forms/v2/forms/{$form_guid}";
87
88
        $options['json'] = $form;
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...
89
90
        return $this->client->request('post', $endpoint, $options);
91
    }
92
93
    /**
94
     * Delete an existing form.
95
     *
96
     * @see http://developers.hubspot.com/docs/methods/forms/v2/delete_form
97
     *
98
     * @param string $form_guid
99
     * @return \SevenShores\Hubspot\Http\Response
100
     */
101
    function delete($form_guid)
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...
102
    {
103
        $endpoint = "https://api.hubapi.com/forms/v2/forms/{$form_guid}";
104
105
        return $this->client->request('delete', $endpoint);
106
    }
107
108
    /**
109
     * Get all fields from a form.
110
     *
111
     * @see http://developers.hubspot.com/docs/methods/forms/v2/get_fields
112
     *
113
     * @param string $form_guid
114
     * @return \SevenShores\Hubspot\Http\Response
115
     */
116
    function getFields($form_guid)
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...
117
    {
118
        $endpoint = "https://api.hubapi.com/forms/v2/fields/{$form_guid}";
119
120
        return $this->client->request('get', $endpoint);
121
    }
122
123
    /**
124
     * Get a single field from a form.
125
     *
126
     * @see http://developers.hubspot.com/docs/methods/forms/v2/get_field
127
     *
128
     * @param string $form_guid
129
     * @param string $name
130
     * @return \SevenShores\Hubspot\Http\Response
131
     */
132
    function getFieldByName($form_guid, $name)
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/forms/v2/fields/{$form_guid}/{$name}";
135
136
        return $this->client->request('get', $endpoint);
137
    }
138
139
    /**
140
     * Get all submissions from a form.
141
     *
142
     * @see https://developers.hubspot.com/docs/methods/forms/get-submissions-for-a-form
143
     *
144
     * @param string $form_guid
145
     * @return \SevenShores\Hubspot\Http\Response
146
     */
147
    function getSubmissions($form_guid, $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...
148
        $endpoint = "https://api.hubapi.com/form-integrations/v1/submissions/forms/{$form_guid}";
149
150
        $queryString = build_query_string($params);
151
        
152
        return $this->client->request('get', $endpoint, [], $queryString);
153
    }
154
155
}
156