GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (3)

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/Facebook.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 NotificationChannels\Facebook;
4
5
use Exception;
6
use GuzzleHttp\Client as HttpClient;
7
use GuzzleHttp\Exception\ClientException;
8
use GuzzleHttp\Exception\GuzzleException;
9
use NotificationChannels\Facebook\Exceptions\CouldNotSendNotification;
10
use Psr\Http\Message\ResponseInterface;
11
12
/**
13
 * Class Facebook.
14
 */
15
class Facebook
16
{
17
    /** @var HttpClient HTTP Client */
18
    protected $http;
19
20
    /** @var string|null Page Token. */
21
    protected $token;
22
23
    /** @var string|null App Secret */
24
    protected $secret;
25
26
    /** @var string Default Graph API Version */
27
    protected $graphApiVersion = '4.0';
28
29
    /**
30
     * @param  string|null      $token
31
     * @param  HttpClient|null  $httpClient
32
     */
33
    public function __construct(string $token = null, HttpClient $httpClient = null)
34
    {
35
        $this->token = $token;
36
37
        $this->http = $httpClient;
38
    }
39
40
    /**
41
     * Set Default Graph API Version.
42
     *
43
     * @param $graphApiVersion
44
     *
45
     * @return Facebook
46
     */
47
    public function setGraphApiVersion($graphApiVersion): self
48
    {
49
        $this->graphApiVersion = $graphApiVersion;
50
51
        return $this;
52
    }
53
54
    /**
55
     * Set App Secret to generate appsecret_proof.
56
     *
57
     * @param string $secret
58
     *
59
     * @return Facebook
60
     */
61
    public function setSecret($secret = null): self
62
    {
63
        $this->secret = $secret;
64
65
        return $this;
66
    }
67
68
    /**
69
     * Get HttpClient.
70
     *
71
     * @return HttpClient
72
     */
73
    protected function httpClient(): HttpClient
74
    {
75
        return $this->http ?? new HttpClient();
76
    }
77
78
    /**
79
     * Send text message.
80
     *
81
     * @param  array  $params
82
     *
83
     * @throws GuzzleException
84
     * @throws CouldNotSendNotification
85
     * @return ResponseInterface
86
     */
87
    public function send(array $params): ResponseInterface
88
    {
89
        return $this->post('me/messages', $params);
90
    }
91
92
    /**
93
     * @param  string  $endpoint
94
     * @param  array   $params
95
     *
96
     * @throws GuzzleException
97
     * @throws CouldNotSendNotification
98
     * @return ResponseInterface
99
     */
100
    public function get(string $endpoint, array $params = []): ResponseInterface
101
    {
102
        return $this->api($endpoint, ['query' => $params]);
103
    }
104
105
    /**
106
     * @param  string  $endpoint
107
     * @param  array   $params
108
     *
109
     * @throws GuzzleException
110
     * @throws CouldNotSendNotification
111
     * @return ResponseInterface
112
     */
113
    public function post(string $endpoint, array $params = []): ResponseInterface
114
    {
115
        return $this->api($endpoint, ['json' => $params], 'POST');
116
    }
117
118
    /**
119
     * Send an API request and return response.
120
     *
121
     * @param  string  $endpoint
122
     * @param  array   $options
123
     * @param  string  $method
124
     *
125
     * @throws GuzzleException
126
     * @throws CouldNotSendNotification
127
     * @return mixed|ResponseInterface
128
     */
129
    protected function api(string $endpoint, array $options, $method = 'GET')
130
    {
131
        if (empty($this->token)) {
132
            throw CouldNotSendNotification::facebookPageTokenNotProvided('You must provide your Facebook Page token to make any API requests.');
133
        }
134
135
        $url = "https://graph.facebook.com/v{$this->graphApiVersion}/{$endpoint}?access_token={$this->token}";
136
137
        if ($this->secret) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->secret of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
138
            $appsecret_proof = hash_hmac('sha256', $this->token, $this->secret);
139
140
            $url .= "&appsecret_proof={$appsecret_proof}";
141
        }
142
143
        try {
144
            return $this->httpClient()->request($method, $url, $options);
145
        } catch (ClientException $exception) {
146
            throw CouldNotSendNotification::facebookRespondedWithAnError($exception);
147
        } catch (Exception $exception) {
148
            throw CouldNotSendNotification::couldNotCommunicateWithFacebook($exception);
149
        }
150
    }
151
}
152