Issues (6)

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/Http/ClientTest.php (6 issues)

Labels
Severity

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
/*
4
 * This file is part of the Kickbox Bundle.
5
 *
6
 * (c) Abdoul Ndiaye <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Andi\KickBoxBundle\Tests\Http;
13
14
use Andi\KickBoxBundle\Exception\EmptyContentException;
15
use Andi\KickBoxBundle\Exception\KickBoxApiException;
16
use Andi\KickBoxBundle\Factory\ResponseFactory;
17
use Andi\KickBoxBundle\Http\Client;
18
use Andi\KickBoxBundle\Http\Response;
19
use Andi\KickBoxBundle\Tests\Factory\ResponseFactoryTest;
20
use GuzzleHttp\Psr7\Response as HttpResponse;
21
use GuzzleHttp\Psr7\Request;
22
use GuzzleHttp\Psr7\Stream;
23
use Phake;
24
use GuzzleHttp\Client as HttpClient;
25
26
/**
27
 * Class ClientTest
28
 *
29
 * @author Abdoul Ndiaye <[email protected]>
30
 *
31
 * @see    Andi\KickBoxBundle\Http\Client
32
 */
33
class ClientTest extends \PHPUnit_Framework_TestCase
34
{
35
    /**
36
     * @var HttpClient|\Phake_IMock
37
     */
38
    protected $httpClient;
39
40
    /**
41
     * @var ResponseFactory
42
     */
43
    protected $responseFactory;
44
45
    /**
46
     * @{@inheritdoc}
47
     */
48
    protected function setUp()
49
    {
50
        $this->httpClient      = Phake::mock(HttpClient::class);
51
        $this->responseFactory = new ResponseFactory();
52
    }
53
54
    public function testVerify()
55
    {
56
        Phake::when($this->httpClient)->get(
0 ignored issues
show
It seems like $this->httpClient can also be of type object<GuzzleHttp\Client>; however, Phake::when() does only seem to accept object<Phake_IMock>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
57
            'my_end_point',
58
            [
59
                'query' => [
60
                    'email'   => '[email protected]',
61
                    'apikey'  => 'my_key',
62
                    'timeout' => 7000,
63
                ]
64
            ]
65
        )->thenReturn($this->getResponse());
66
67
        $client = new Client($this->httpClient, $this->responseFactory, 'my_end_point', 'my_key');
0 ignored issues
show
It seems like $this->httpClient can also be of type object<Phake_IMock>; however, Andi\KickBoxBundle\Http\Client::__construct() does only seem to accept object<GuzzleHttp\Client>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
68
69
        $this->assertInstanceOf(Response::class, $client->verify('[email protected]', 7000));
70
    }
71
72
    public function testKickboxApiException()
73
    {
74
        Phake::when($this->httpClient)->get(Phake::anyParameters())->thenThrow(
0 ignored issues
show
It seems like $this->httpClient can also be of type object<GuzzleHttp\Client>; however, Phake::when() does only seem to accept object<Phake_IMock>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
75
            new KickBoxApiException('expectedMessage', new Request('GET', 'error'), $this->getErrorResponse())
76
        );
77
78
        $this->setExpectedException(
79
            KickBoxApiException::class,
80
            'An error occurred during the api call : exception message'
81
        );
82
83
        $client = new Client($this->httpClient, $this->responseFactory, '', '');
0 ignored issues
show
It seems like $this->httpClient can also be of type object<Phake_IMock>; however, Andi\KickBoxBundle\Http\Client::__construct() does only seem to accept object<GuzzleHttp\Client>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
84
        $client->verify('');
85
    }
86
87
    public function testEmptyContentException()
88
    {
89
        Phake::when($this->httpClient)->get(Phake::anyParameters())->thenReturn(new HttpResponse(400));
0 ignored issues
show
It seems like $this->httpClient can also be of type object<GuzzleHttp\Client>; however, Phake::when() does only seem to accept object<Phake_IMock>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
90
91
        $this->setExpectedException(
92
            EmptyContentException::class
93
        );
94
95
        $client = new Client($this->httpClient, $this->responseFactory, '', '');
0 ignored issues
show
It seems like $this->httpClient can also be of type object<Phake_IMock>; however, Andi\KickBoxBundle\Http\Client::__construct() does only seem to accept object<GuzzleHttp\Client>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
96
        $client->verify('');
97
    }
98
99
    /**
100
     * @return HttpResponse
101
     */
102
    protected function getResponse()
103
    {
104
        return new HttpResponse(
105
            200,
106
            ResponseFactoryTest::$goodHeaders,
107
            json_encode(ResponseFactoryTest::$goodParameters)
108
        );
109
    }
110
111
    /**
112
     * @return HttpResponse
113
     */
114
    protected function getErrorResponse()
115
    {
116
        return new HttpResponse(
117
            500,
118
            [],
119
            json_encode(['message' => 'exception message'])
120
        );
121
    }
122
}
123