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 (4)

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.

tests/ClientTest.php (3 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 Fab\Clarifai\Tests;
4
5
use Fab\Clarifai\Client;
6
use Fab\Clarifai\Models;
7
use GuzzleHttp\Client as HttpClient;
8
use Mockery;
9
10
class ClientTest extends TestCase
11
{
12
    /** @test */
13
    function can_instantiate_client()
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...
14
    {
15
        $httpClient = $this->getHttpClientMock();
16
17
        $client = new Client($httpClient, 'client-id', 'client-secret');
18
19
        $this->assertInstanceOf(Client::class, $client);
20
    }
21
22
    /** @test */
23
    function can_retrieve_an_access_token()
24
    {
25
        $httpClient = $this->getHttpClientMock();
26
        $httpClient
27
            ->shouldReceive('request')
28
            ->with('POST', 'https://api.clarifai.com/v2/token', [
29
                'headers' => [
30
                    'Accept' => 'application/json',
31
                    'Content-Type' => 'application/json',
32
                ],
33
                'auth' => ['client-id', 'client-secret'],
34
            ])
35
            ->andReturn($httpClient);
36
37
            $httpClient
38
                ->shouldReceive('getBody')
39
                ->andReturn(json_encode(['foo' => 'bar']));
40
41
        $client = new Client($httpClient, 'client-id', 'client-secret');
42
43
        $response = $client->accessToken();
44
45
        $this->assertEquals(['foo' => 'bar'], $response);
46
    }
47
48
    /** @test */
49
    function can_predict_the_content_of_an_image_by_passing_an_url()
50
    {
51
        $httpClient = $this->sendRequest(
52
            $this->getHttpClientMock(),
53
            'https://api.clarifai.com/v2/models/aaa03c23b3724a16a56b629203edc62c/outputs',
54
            [
55
                [
56
                    'data' => [
57
                        'image' => [
58
                            'url' => 'https://samples.clarifai.com/metro-north.jpg',
59
                        ]
60
                    ]
61
                ]
62
            ]
63
        );
64
65
        $client = new Client($httpClient, 'client-id', 'client-secret');
66
67
        $response = $client->withAccessToken('access-token')->predict([
68
            'https://samples.clarifai.com/metro-north.jpg',
69
        ]);
70
71
        $this->assertTrue(is_array($response));
72
        $this->assertEquals([
73
            'foo' => 'bar'
74
        ], $response);
75
    }
76
77
    /** @test */
78 View Code Duplication
    function use_general_model_by_default_when_predicting_the_content_of_an_image()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
79
    {
80
        $httpClient = $this->sendRequest(
81
            $this->getHttpClientMock(),
82
            'https://api.clarifai.com/v2/models/'.Models::GENERAL.'/outputs',
83
            [
84
                [
85
                    'data' => [
86
                        'image' => [
87
                            'url' => 'https://samples.clarifai.com/metro-north.jpg',
88
                        ]
89
                    ]
90
                ]
91
            ]
92
        );
93
94
        $client = new Client($httpClient, 'client-id', 'client-secret');
95
96
        $response = $client->withAccessToken('access-token')->predict([
97
            'https://samples.clarifai.com/metro-north.jpg',
98
        ]);
99
100
        $this->assertTrue(is_array($response));
101
        $this->assertEquals([
102
            'foo' => 'bar'
103
        ], $response);
104
    }
105
106
    /** @test */
107 View Code Duplication
    function can_predict_the_content_of_an_image_by_passing_an_url_and_a_specific_model()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
108
    {
109
        $httpClient = $this->sendRequest(
110
            $this->getHttpClientMock(),
111
            'https://api.clarifai.com/v2/models/'.Models::FOOD.'/outputs',
112
            [
113
                [
114
                    'data' => [
115
                        'image' => [
116
                            'url' => 'https://samples.clarifai.com/metro-north.jpg',
117
                        ]
118
                    ]
119
                ]
120
            ]
121
        );
122
123
        $client = new Client($httpClient, 'client-id', 'client-secret');
124
125
        $response = $client->withAccessToken('access-token')->predict([
126
            'https://samples.clarifai.com/metro-north.jpg',
127
        ], Models::FOOD);
128
129
        $this->assertTrue(is_array($response));
130
        $this->assertEquals([
131
            'foo' => 'bar'
132
        ], $response);
133
    }
134
135
    private function getHttpClientMock()
136
    {
137
        return Mockery::mock(HttpClient::class);
138
    }
139
140
    private function sendRequest($httpClient, $url, $inputs)
141
    {
142
        $httpClient
143
            ->shouldReceive('request')
144
            ->with('POST', $url, [
145
                'headers' => [
146
                    'Accept' => 'application/json',
147
                    'Content-Type' => 'application/json',
148
                    'Authorization' => 'Bearer access-token',
149
                ],
150
                'json' => [
151
                    'inputs' => $inputs
152
                ]
153
            ])
154
            ->andReturn($httpClient);
155
156
        $httpClient
157
            ->shouldReceive('getBody')
158
            ->andReturn(json_encode(['foo' => 'bar']));
159
160
        return $httpClient;
161
    }
162
}
163