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/OAuth2.php (8 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 OAuth2 extends Resource
6
{
7
	protected $endpoint = 'https://api.hubapi.com/oauth/v1';
8
9
	/**
10
	 * Initiate an Integration with OAuth 2.0
11
	 *
12
	 * @param string $clientId      The Client ID of your app.
13
	 * @param string $redirectURI   The URL that you want the visitor redirected to after granting access to your app. For security reasons, this URL must use https.
14
	 * @param array  $scopesArray   A set of scopes that your app will need access to.
15
	 * @return \SevenShores\Hubspot\Http\Response
16
	 */
17
	function getAuthUrl($clientId, $redirectURI, $scopesArray=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...
18
	{
19
		$scopeString = '';
20
		if(count($scopesArray)>0)
21
		{
22
			$scopeString = '';
23
			foreach($scopesArray as $_index => $scopeStr)
24
			{
25
				if($_index>0)
26
					$scopeString .= "%20";
27
28
				$scopeString .= $scopeStr;
29
			}
30
		}
31
32
		return "https://app.hubspot.com/oauth/authorize?client_id={$clientId}&scope={$scopeString}&redirect_uri=".urlencode($redirectURI);
33
	}
34
35
	/**
36
	 * Get OAuth 2.0 Access Token and Refresh Tokens by using a one-time code
37
	 *
38
	 * @param string $clientId      The Client ID of your app.
39
	 * @param string $clientSecret  The Client Secret of your app.
40
	 * @param string $redirectURI   The redirect URI that was used when the user authorized your app. This must exactly match the redirect_uri used when initiating the OAuth 2.0 connection.
41
	 * @param string $tokenCode     The code parameter returned to your redirect URI when the user authorized your app. Or a refresh token.
42
	 * @return \SevenShores\Hubspot\Http\Response
43
	 */
44 View Code Duplication
	function getTokensByCode($clientId, $clientSecret, $redirectURI, $tokenCode)
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...
45
	{
46
		$options['form_params'] = [
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...
47
			'grant_type' => 'authorization_code',
48
			'client_id' => $clientId,
49
			'client_secret' => $clientSecret,
50
			'redirect_uri' => $redirectURI,
51
			'code' => $tokenCode
52
		];
53
54
		$options['headers']['content-type'] = 'application/x-www-form-urlencoded';
55
56
		return $this->client->request('post', $this->endpoint.'/token', $options);
57
	}
58
59
	/**
60
	 * Get OAuth 2.0 Access Token and Refresh Tokens by using a refresh token
61
	 * Note: Contrary to HubSpot documentation, $redirectURI is NOT required.
62
	 *
63
	 * @param string $clientId      The Client ID of your app.
64
	 * @param string $clientSecret  The Client Secret of your app.
65
	 * @param string $refreshToken  The refresh token.
66
	 * @return \SevenShores\Hubspot\Http\Response
67
	 */
68 View Code Duplication
	function getTokensByRefresh($clientId, $clientSecret, $refreshToken)
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...
69
	{
70
		$options['form_params'] = [
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
			'grant_type' => 'refresh_token',
72
			'client_id' => $clientId,
73
			'client_secret' => $clientSecret,
74
			'refresh_token' => $refreshToken
75
		];
76
77
		$options['headers']['content-type'] = 'application/x-www-form-urlencoded';
78
79
		return $this->client->request('post', $this->endpoint.'/token', $options);
80
	}
81
82
	/**
83
	 * Get Information for OAuth 2.0 Access Token
84
	 *
85
	 * @param  int $token The access token that you want to get the information for.
86
	 * @return \SevenShores\Hubspot\Http\Response
87
	 */
88
	function getAccessTokenInfo($token)
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
		return $this->client->request('get', $this->endpoint."/access-tokens/{$token}");
91
	}
92
93
	/**
94
	 * Get Information for OAuth 2.0 Refresh Token
95
	 *
96
	 * @param  int $token The refresh token that you want to get the information for.
97
	 * @return \SevenShores\Hubspot\Http\Response
98
	 */
99
	function getRefreshTokenInfo($token)
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...
100
	{
101
		return $this->client->request('get', $this->endpoint."/refresh-tokens/{$token}");
102
	}
103
104
	/**
105
	 * Delete OAuth 2.0 Refresh Token
106
	 *
107
	 * @param  int $token The refresh token that you want to delete.
108
	 * @return \SevenShores\Hubspot\Http\Response
109
	 */
110
	function deleteRefreshToken($token)
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...
111
	{
112
		return $this->client->request('delete', $this->endpoint."/refresh-tokens/{$token}");
113
	}
114
115
}
116