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/HubDB.php (4 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 HubDB extends Resource
6
{
7
    /**
8
     * Get all tables
9
     *
10
     * @param int $portalId Hub/Portal ID
11
     *
12
     * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response
13
     */
14
    public function tables($portalId) {
15
        $endpoint = 'https://api.hubapi.com/hubdb/api/v1/tables';
16
17
        $queryString = build_query_string(['portalId' => $portalId]);
18
19
        return $this->client->request('get', $endpoint, [], $queryString);
20
    }
21
22
    /**
23
     * Get details about a table
24
     *
25
     * @param int $portalId Hub ID
26
     * @param int $tableId Table ID
27
     *
28
     * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response
29
     */
30 View Code Duplication
    public function tableInfo($portalId, $tableId) {
31
        $endpoint = 'https://api.hubapi.com/hubdb/api/v1/tables/'.$tableId;
32
33
        $queryString = build_query_string(['portalId' => $portalId]);
34
35
        return $this->client->request('get', $endpoint, [], $queryString);
36
    }
37
38
    /**
39
     * Delete a table
40
     *
41
     * @param int $tableId Table ID
42
     *
43
     * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response
44
     */
45
    public function deleteTable($tableId) {
46
        $endpoint = 'https://api.hubapi.com/hubdb/api/v1/tables/'.$tableId;
47
48
        return $this->client->request('delete', $endpoint);
49
    }
50
51
    /**
52
     * Delete a row
53
     *
54
     * @param int $tableId Table ID
55
     * @param int $rowId Row ID
56
     *
57
     * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response
58
     */
59
    public function deleteRow($tableId, $rowId) {
60
        $endpoint = 'https://api.hubapi.com/hubdb/api/v1/tables/'.$tableId.'/rows/'.$rowId;
61
62
        return $this->client->request('delete', $endpoint);
63
    }
64
65
    /**
66
     * @param string $name table name
67
     * @param array $columns column name and type should be represented as associative array, e.g. ["name" => "Name", "type" => "TEXT"], @see https://developers.hubspot.com/docs/methods/hubdb/create_table
68
     * @param bool $published whether to publish table
69
     * @param bool $useForPages use table for dynamic pages, see https://designers.hubspot.com/docs/tutorials/how-to-build-dynamic-pages-with-hubdb
70
     *
71
     * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response
72
     */
73
    public function createTable($name, array $columns, $published = true, $useForPages = false) {
74
        $endpoint = 'https://api.hubapi.com/hubdb/api/v1/tables';
75
        $options['json'] = ['name' => $name, 'columns' => $columns];
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...
76
        if($published) {
77
            $options['json']['publishedAt'] = round(microtime(true) * 1000);
78
        }
79
        $options['json']['useForPages'] = $useForPages;
80
81
        return $this->client->request('post', $endpoint, $options);
82
    }
83
84
    /**
85
     * Get table rows
86
     *
87
     * @param int $portalId Hub/Portal ID
88
     * @param int $tableId table ID
89
     * @param array $params key-value array to filter and sort rows
90
     *
91
     * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response
92
     */
93 View Code Duplication
    public function rows($portalId, $tableId, array $params)
94
    {
95
        $endpoint = 'https://api.hubapi.com/hubdb/api/v1/tables/'.$tableId.'/rows';
96
97
        $queryString = build_query_string(array_merge(['portalId' => $portalId], $params));
98
99
        return $this->client->request('get', $endpoint, [], $queryString);
100
    }
101
102
    /**
103
     * @param int $tableId table ID
104
     * @param array $values
105
     *
106
     * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response
107
     */
108
    public function addRow($tableId, array $values) {
109
        $endpoint = 'https://api.hubapi.com/hubdb/api/v1/tables/'.$tableId.'/rows';
110
        $options['json'] = ['values' => $values];
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...
111
112
        return $this->client->request('post', $endpoint, $options);
113
    }
114
115
    /**
116
     * @param int $tableId table ID
117
     * @param array $values
118
     * @param string $title page title for dynamic page
119
     * @param string $path path to access page (appended to domain to form page URL)
120
     *
121
     * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response
122
     */
123
    public function addRowForPage($tableId, array $values, $title = '', $path = '') {
124
        $endpoint = 'https://api.hubapi.com/hubdb/api/v1/tables/'.$tableId.'/rows';
125
        $options['json'] = ['values' => $values, 'name' => $title, 'path' => $path];
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...
126
127
        return $this->client->request('post', $endpoint, $options);
128
    }
129
130
    /**
131
     * update database table row
132
     *
133
     * @param int   $tableId
134
     * @param int $rowId
135
     * @param array $values
136
     *
137
     * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response
138
     */
139
    public function updateRow($tableId, $rowId, array $values) {
140
        $endpoint = 'https://api.hubapi.com/hubdb/api/v1/tables/'.$tableId.'/rows/'.$rowId;
141
        $options['json'] = ['values' => $values];
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...
142
143
        return $this->client->request('put', $endpoint, $options);
144
    }
145
}