Issues (162)

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.

app/Http/Controllers/VideoController.php (8 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 App\Http\Controllers;
4
5
use App\Http\Requests\VideoUploadRequest;
6
use App\Repositories\UserRepository as User;
7
use App\Repositories\VideoRepository as Video;
8
use App\Transformers\VideoTransformer;
9
use Chrisbjr\ApiGuard\Http\Controllers\ApiGuardController;
10
use Illuminate\Http\Request;
11
use Illuminate\Support\Facades\Storage;
12
use Linkthrow\Ffmpeg\Classes\FFMPEG;
13
14
/**
15
 * Class VideoController.
16
 */
17
class VideoController extends ApiGuardController
18
{
19
    /**
20
     * @var VideoTransformer
21
     */
22
    protected $videoTransformer;
23
24
    /**
25
     * @var Video
26
     */
27
    protected $video;
28
29
    /**
30
     * @var array
31
     */
32
    protected $apiMethods = [
33
        'getAllVideos' => [
34
            'keyAuthentication' => false,
35
        ],
36
        'show' => [
37
            'keyAuthentication' => false,
38
        ],
39
        'getBestVideos' => [
40
            'keyAuthentication' => false,
41
        ],
42
        'getVideosUser' => [
43
            'keyAuthentication' => false,
44
        ],
45
        'getVideosForCategory' => [
46
            'keyAuthentication' => false,
47
        ],
48
        'getVideosForSearch' => [
49
            'keyAuthentication' => false,
50
        ],
51
        'store' => [
52
            'limits' => [
53
                'key' => [
54
                    'increment' => '1 hour',
55
                    'limit'     => 10,
56
                ],
57
            ],
58
        ],
59
    ];
60
61
    /**
62
     * VideoController constructor.
63
     *
64
     * @param VideoTransformer $videoTransformer
65
     * @param Video            $video
66
     * @param User             $user
67
     */
68 12
    public function __construct(Video $video, User $user, VideoTransformer $videoTransformer)
69
    {
70 12
        parent::__construct();
71
72 12
        $this->videoTransformer = $videoTransformer;
73 12
        $this->video = $video;
74 12
        $this->user = $user;
75 12
    }
76
77
    /**
78
     * Return all Videos.
79
     */
80 5
    public function getAllVideos()
81
    {
82 5
        $video = $this->video->all();
83
84 5
        return $this->response->withCollection($video, $this->videoTransformer);
0 ignored issues
show
$this->videoTransformer is of type object<App\Transformers\VideoTransformer>, but the function expects a callable.

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...
85
    }
86
87
    /**
88
     * Return the best Videos.
89
     */
90 1
    public function getBestVideos()
91
    {
92 1
        $video = $this->video->best();
93
94 1
        return $this->response->withCollection($video, $this->videoTransformer);
0 ignored issues
show
$this->videoTransformer is of type object<App\Transformers\VideoTransformer>, but the function expects a callable.

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...
95
    }
96
97
    /**
98
     * Return Videos only user.
99
     */
100 1
    public function getVideosUser($id)
101
    {
102 1
        $user = $this->user->findOrFail($id);
103 1
        $video = $user->getVideos;
104
105 1
        return $this->response->withCollection($video, $this->videoTransformer);
0 ignored issues
show
$this->videoTransformer is of type object<App\Transformers\VideoTransformer>, but the function expects a callable.

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...
106
    }
107
108
    /**
109
     * Return Videos for Category.
110
     */
111 1
    public function getVideosForCategory($name)
112
    {
113 1
        $video = $this->video->findBy('category', $name);
114
115 1
        return $this->response->withCollection($video, $this->videoTransformer);
0 ignored issues
show
$this->videoTransformer is of type object<App\Transformers\VideoTransformer>, but the function expects a callable.

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...
116
    }
117
118
    /**
119
     * Return Videos for Search.
120
     */
121 1
    public function getVideosForSearch($search)
122
    {
123 1
        $video = $this->video->search('name', $search);
124
125 1
        return $this->response->withCollection($video, $this->videoTransformer);
0 ignored issues
show
$this->videoTransformer is of type object<App\Transformers\VideoTransformer>, but the function expects a callable.

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...
126
    }
127
128
    /**
129
     * Store a newly created video in storage.
130
     *
131
     * @param VideoUploadRequest $request
132
     *
133
     * @return mixed
134
     */
135 1
    public function store(VideoUploadRequest $request)
136
    {
137 1
        $user = $this->user->authenticated();
138 1
        $file = $request->video;
139 1
        $nameFile = str_replace(' ', '', $request->input('name').$user->id);
140
141
        $data = [
142 1
            'name'     => $request->input('name'),
143 1
            'category' => $request->input('category'),
144 1
            'path'     => Storage::url('videos/'.$nameFile),
145 1
            'user_id'  => $user->id,
146
        ];
147
148 1
        $video = $this->video->create($data);
149
150 1
        $this->saveAndConvert($file, $nameFile);
151
152 1
        return $this->response->withItem($video, $this->videoTransformer);
0 ignored issues
show
$this->videoTransformer is of type object<App\Transformers\VideoTransformer>, but the function expects a callable.

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...
153
    }
154
155
    /**
156
     * @param $id
157
     *
158
     * @return mixed
159
     */
160 2
    public function show($id)
161
    {
162 2
        $video = $this->video->findOrFail($id);
163
164 1
        return $this->response->withItem($video, $this->videoTransformer);
0 ignored issues
show
$this->videoTransformer is of type object<App\Transformers\VideoTransformer>, but the function expects a callable.

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...
165
    }
166
167
    /**
168
     * Update the specified video in storage.
169
     *
170
     * @param Request $request
171
     * @param $id
172
     *
173
     * @return mixed
174
     */
175 1
    public function update(Request $request, $id)
176
    {
177 1
        $video = $this->video->findOrFail($id);
178
179 1
        $this->video->update($request->all(), $id);
180
181 1
        return $this->response->withItem($video, $this->videoTransformer);
0 ignored issues
show
$this->videoTransformer is of type object<App\Transformers\VideoTransformer>, but the function expects a callable.

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...
182
    }
183
184
    /**
185
     * Remove the specified video from storage.
186
     *
187
     * @param $id
188
     *
189
     * @return mixed
190
     */
191 1
    public function destroy($id)
192
    {
193 1
        $video = $this->video->findOrFail($id);
194
195 1
        $nameFile = str_replace('storage/', '', $video->path);
196
197 1
        Storage::disk('public')->delete([$nameFile.'.mp4', $nameFile.'.webm']);
198
199 1
        $this->video->delete($id);
200 1
    }
201
202
    /**
203
     * Save and Convert to webm video.
204
     *
205
     * @param $video
206
     * @param $name
207
     */
208 1
    private function saveAndConvert($video, $name)
209
    {
210 1
        Storage::disk('public')->put('videos/'.$name.'.mp4', file_get_contents($video->getRealPath()));
211
212 1
        FFMPEG::convert()
213 1
            ->input($video->getRealPath())
214 1
            ->output(storage_path('app/public/videos/').$name.'.webm')
215 1
            ->overwrite(true)
216 1
            ->go();
217 1
    }
218
}
219