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.

src/Client.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 Shutterstock\Api;
4
5
use GuzzleHttp\Client as Guzzle;
6
use GuzzleHttp\HandlerStack;
7
use GuzzleHttp\Middleware;
8
use GuzzleHttp\Promise\PromiseInterface as Promise;
9
use Psr\Http\Message\ResponseInterface as Response;
10
11
class Client
12
{
13
14
    /** @var  Guzzle */
15
    protected $guzzle;
16
17
    /**
18
     * @param string $clientId
19
     * @param string $clientSecret
20
     */
21
    public function __construct($clientId, $clientSecret)
22
    {
23
        $stack = HandlerStack::create();
24
        $stack->push(Middleware::mapResponse(function (Response $response) {
25
            $jsonStream = new JsonStream($response->getBody());
26
            return $response->withBody($jsonStream);
27
        }));
28
29
        $guzzle = new Guzzle([
30
            'base_uri' => 'https://api.shutterstock.com/v2/',
31
            'auth' => [$clientId, $clientSecret],
32
            'handler' => $stack,
33
        ]);
34
        $this->guzzle = $guzzle;
35
    }
36
37
    /**
38
     * @param string $uri
39
     * @param array  $query
40
     * @param array  $options
41
     *
42
     * @return Response
43
     */
44 View Code Duplication
    public function get($uri, array $query = [], array $options = [])
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...
45
    {
46
        if (!empty($query)) {
47
            $options['query'] = $this->buildQuery($query);
48
        }
49
        return $this->guzzle->get($uri, $options);
50
    }
51
52
    /**
53
     * @param string $uri
54
     * @param array  $query
55
     * @param array  $options
56
     *
57
     * @return Promise
58
     */
59 View Code Duplication
    public function getAsync($uri, array $query = [], array $options = [])
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...
60
    {
61
        if (!empty($query)) {
62
            $options['query'] = $this->buildQuery($query);
63
        }
64
        return $this->guzzle->getAsync($uri, $options);
65
    }
66
67
    /**
68
     * @param array  $query
69
     * @param string $separator
70
     *
71
     * @return string
72
     */
73
    public function buildQuery(array $query, $separator = '&')
74
    {
75
        $queryPieces = [];
76
        foreach ($query as $key => $value) {
77
            if (!is_array($value)) {
78
                $piece = urlencode($key) . '=' . urlencode($value);
79
                array_push($queryPieces, $piece);
80
                continue;
81
            }
82
            foreach ($value as $valuePiece) {
83
                $piece = urlencode($key) . '=' . urlencode($valuePiece);
84
                array_push($queryPieces, $piece);
85
            }
86
        }
87
88
        $queryString = implode($separator, $queryPieces);
89
        return $queryString;
90
    }
91
92
    /**
93
     * @param string $uri
94
     * @param array  $body
95
     * @param array  $options
96
     *
97
     * @return Response
98
     */
99 View Code Duplication
    public function post($uri, array $body = [], array $options = [])
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...
100
    {
101
        if (!empty($body)) {
102
            $options['json'] = $body;
103
        }
104
        return $this->guzzle->post($uri, $options);
105
    }
106
107
    /**
108
     * @param string $uri
109
     * @param array  $body
110
     * @param array  $options
111
     *
112
     * @return Promise
113
     */
114 View Code Duplication
    public function postAsync($uri, array $body = [], array $options = [])
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...
115
    {
116
        if (!empty($body)) {
117
            $options['json'] = $body;
118
        }
119
        return $this->guzzle->postAsync($uri, $options);
120
    }
121
}
122