Issues (115)

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/MainController.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 App\Http\Controllers;
4
5
use App\Http\Models\Actors;
6
use App\Http\Models\Comments;
7
use App\Http\Models\Movies;
8
use App\Http\Models\Sessions;
9
use App\Http\Models\User;
10
use Illuminate\Http\Request;
11
use Illuminate\Support\Facades\Validator;
12
use Netshell\Paypal\Facades\Paypal;
13
14
/**
15
 * Class MainController.
16
 */
17
class MainController extends Controller
18
{
19
    /**
20
     * Fo Page.
21
     *
22
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
23
     */
24
    public function index()
25
    {
26
        return view('Main/index');
27
    }
28
29
    /**
30
     * Ajax Movies.
31
     *
32
     * @param Request $request
33
     *
34
     * @return mixed
35
     */
36
    public function ajaxmovies(Request $request)
37
    {
38
        $validator = Validator::make(
39
            $request->all(),  //request all : tous les elements de requetses
40
            [
41
            'title' => 'required|min:10',
42
            ], [
43
            'title.required' => 'Votre titre est obligatoire',
44
            'title.min'      => 'Votre titre est trop court',
45
            ]);
46
47
        if ($validator->fails()) { // si mon validateur échoue
48
            return $validator->errors()->all();
49
        } else {
50
            Movies::create([
51
                'title'         => $request->title,
52
                'description'   => $request->description,
53
                'categories_id' => $request->categories_id,
54
            ]);
55
56
            return $request->title;
57
        }
58
    }
59
60
    /**
61
     * Done Payment.
62
     *
63
     * @param Request $request
64
     *
65
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
66
     */
67 View Code Duplication
    public function done(Request $request)
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...
68
    {
69
        $id = $request->get('paymentId');
70
        $payer_id = $request->get('PayerID');
71
72
        $payment = PayPal::getById($id, $this->_apiContext);
0 ignored issues
show
The property _apiContext does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
73
74
        $paymentExecution = PayPal::PaymentExecution();
75
76
        $paymentExecution->setPayerId($payer_id);
77
        $executePayment = $payment->execute($paymentExecution, $this->_apiContext);
0 ignored issues
show
$executePayment is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
78
79
        // Clear the shopping cart, write to database, send notifications, etc.
80
        $request->session()->pull('likes', []);
0 ignored issues
show
array() is of type array, but the function expects a string|null.

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...
81
82
        return view('Main/index');
83
    }
84
85
    /**
86
     * Page Dashboard.
87
     */
88
    public function dashboard()
89
    {
90
        $nbacteurs = Actors::count();
91
        $nbcommentaires = Comments::count();
92
        $nbmovies = Movies::count();
93
        $nbseances = Sessions::count();
94
95
        $manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017');
96
        $collection = new \MongoDB\Collection($manager, 'laravel', 'videos');
97
        $videos = collect($collection->find()->toArray())->shuffle();
98
99
        $collection = new \MongoDB\Collection($manager, 'laravel', 'stats');
100
        $youtubeinfo = collect($collection->find(['origin' => 'Youtube'])->toArray())->first();
101
102
        $collection = new \MongoDB\Collection($manager, 'laravel', 'stats');
103
        $tweeterinfo = collect($collection->find(['origin' => 'Twitter', 'type' => 'infos'])->toArray())->first();
104
105
        $actor = new Actors(); // Je récpere mon modèle
106
        $comment = new Comments(); // Je récpere mon modèle
107
        $movie = new Movies(); // Je récpere mon modèle
108
        $session = new Sessions(); // Je récpere mon modèle
109
        $user = new User(); // Je récpere mon modèle
110
111
        $avgacteurs = $actor->getAvgActors();
112
        $avgnotecommentaire = $comment->getAvgNote();
113
        $avgnotepresse = $movie->getAvgNotePresse();
114
        $avghour = $session->getAvgHourDate();
115
116
        $seances = $session->getNextSession();
117
        $users = $user->getLastUsers();
118
119
        return view('Main/dashboard', [
120
            'avgnotecommentaire'     => $avgnotecommentaire->avgnote,
121
            'avgnotepresse'          => $avgnotepresse->avgpress,
122
            'avgacteurs'             => $avgacteurs->age,
123
            'videos'                 => $videos,
124
            'video'                  => $videos[0],
125
            'youtubeinfo'            => $youtubeinfo->data,
126
            'tweeterinfo'            => $tweeterinfo['data'][0],
127
            'youtubeinfodateupdated' => $youtubeinfo->created,
128
            'tweeterinfodateupdated' => $tweeterinfo['created_at'],
129
            'avghour'                => $avghour->avghour,
130
            'nbacteurs'              => $nbacteurs,
131
            'nbcommentaires'         => $nbcommentaires,
132
            'nbmovies'               => $nbmovies,
133
            'nbseances'              => $nbseances,
134
            'seances'                => $seances,
135
            'users'                  => $users,
136
        ]);
137
    }
138
}
139