Issues (23)

Security Analysis    not enabled

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.

Controller/Controller.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
/*
4
 * This file is part of the XabbuhPandaBundle package.
5
 *
6
 * (c) Christian Flothmann <[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 Xabbuh\PandaBundle\Controller;
13
14
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
15
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ConstractsEventDispatcherInterface;
16
use Symfony\Component\HttpFoundation\JsonResponse;
17
use Symfony\Component\HttpFoundation\Request;
18
use Symfony\Component\HttpFoundation\Response;
19
use Xabbuh\PandaBundle\Event\EventFactory;
20
use Xabbuh\PandaClient\Api\CloudManagerInterface;
21
use Xabbuh\PandaClient\Signer\PandaSigner;
22
23
/**
24
 * XabbuhPandaBundle controllers.
25
 *
26
 * @author Christian Flothmann <[email protected]>
27
 */
28
class Controller
29
{
30
    /**
31
     * @var CloudManagerInterface
32
     */
33
    private $cloudManager;
34
35
    /**
36
     * @var EventDispatcherInterface
37
     */
38
    private $eventDispatcher;
39
40
    /**
41
     * @param CloudManagerInterface    $cloudManager
42
     * @param EventDispatcherInterface $eventDispatcher
43
     */
44 10
    public function __construct(CloudManagerInterface $cloudManager, EventDispatcherInterface $eventDispatcher)
45
    {
46 10
        $this->cloudManager = $cloudManager;
47 10
        $this->eventDispatcher = $eventDispatcher;
48 10
    }
49
50
    /**
51
     * Sign a set of given url parameters and return them as a JSON object.
52
     *
53
     * Specials keys are <em>method</em> and <em>path</em>. <em>method</em> is
54
     * the http method and <em>path</em> the url part of the api request for
55
     * which the signature is generated. The default <em>method</em> if not
56
     * given is <em>GET</em>, the default <em>path</em> is <em>/videos.json</em>.
57
     * All remaining url parameters are treated as parameters for the api
58
     * request.
59
     *
60
     * @param string  $cloud   Cloud to use for performing API requests
61
     * @param Request $request The current request
62
     *
63
     * @return JsonResponse The response
64
     */
65 2
    public function signAction($cloud, Request $request)
66
    {
67 2
        $params = $request->query->all();
68
69 2
        if (isset($params['method'])) {
70 1
            $method = $params['method'];
71 1
            unset($params['method']);
72
        } else {
73 2
            $method = 'GET';
74
        }
75
76 2
        if (isset($params['path'])) {
77 1
            $path = $params['path'];
78 1
            unset($params['path']);
79
        } else {
80 2
            $path = '/videos.json';
81
        }
82
83 2
        $httpClient = $this->cloudManager->getCloud($cloud)->getHttpClient();
84 2
        $cloudId = $httpClient->getCloudId();
85 2
        $account = $httpClient->getAccount();
86 2
        $signer = PandaSigner::getInstance($cloudId, $account);
87
88 2
        return new JsonResponse($signer->signParams($method, $path, $params));
89
    }
90
91
    /**
92
     * Authorize a file upload.
93
     *
94
     * The name of the file to upload and its size are passed as POST parameters.
95
     * The response contains a JSON encoded object. It includes a property
96
     * upload_url to which the caller should send its video file.
97
     *
98
     * @param string  $cloud   Cloud to use for performing API requests
99
     * @param Request $request The current request
100
     *
101
     * @return JsonResponse The response
102
     */
103 1
    public function authoriseUploadAction($cloud, Request $request)
104
    {
105 1
        $payload = json_decode($request->request->get('payload'));
106 1
        $upload = $this->cloudManager
107 1
            ->getCloud($cloud)
108 1
            ->registerUpload(
109 1
                $payload->filename,
110 1
                $payload->filesize,
111 1
                null,
112 1
                true
113
            );
114
115 1
        return new JsonResponse(array('upload_url' => $upload->location));
116
    }
117
118
    /**
119
     * Endpoint for notification requests.
120
     *
121
     * @param Request $request The current request
122
     *
123
     * @return Response An empty response with status code 200
124
     */
125 6
    public function notifyAction(Request $request)
126
    {
127
        try {
128 6
            $event = EventFactory::createEventFromRequest($request);
129
130 4
            if ($this->eventDispatcher instanceof ConstractsEventDispatcherInterface) {
131 4
                $this->eventDispatcher->dispatch($event, constant(get_class($event).'::NAME'));
0 ignored issues
show
$event is of type object<Xabbuh\PandaBundl...\EncodingCompleteEvent>, but the function expects a object<Symfony\Contracts\EventDispatcher\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
132
            } else {
133
                $this->eventDispatcher->dispatch(constant(get_class($event).'::NAME'), $event);
134
            }
135
136 4
            return new Response('');
137 2
        } catch (\InvalidArgumentException $e) {
138 2
            return new Response($e->getMessage(), 400);
139
        }
140
    }
141
}
142