Issues (19)

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/TaskController.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 Acme\Transformers\TaskTransformer;
6
use App\Task;
7
use Illuminate\Http\Request;
8
use Illuminate\Http\Response as IlluminateResponse;
9
use Illuminate\Support\Facades\Input;
10
11
class TaskController extends ApiController
12
{
13
    protected $taskTransformer;
14
    /**
15
     * TaskController constructor.
16
     * @param $taskTransformer
17
     */
18
    public function __construct(TaskTransformer $taskTransformer)
19
    {
20
        $this->taskTransformer = $taskTransformer;
21
22
    }
23
24
    /**
25
     * Display a listing of the resource.
26
     *
27
     * @return \Illuminate\Http\Response
28
     */
29
    public function index()
30
    {
31
        //1. No és retorna: paginació
32
        //return Task::all();
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
33
34
        $task = Task::all();
35
        return $this->respond($this->taskTransformer->transformCollection($task->all()));
36
    }
37
38
    /**
39
     * Show the form for creating a new resource.
40
     *
41
     * @return \Illuminate\Http\Response
42
     */
43
    public function create()
44
    {
45
        //
46
    }
47
48
    /**
49
     * Store a newly created resource in storage.
50
     *  @return \Illuminate\Http\Response
51
     */
52
    public function store()
53
    {
54
        if (!Input::get('name') or !Input::get('done') or !Input::get('priority'))
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as or instead of || is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
55
        {
56
            return $this->setStatusCode(IlluminateResponse::HTTP_UNPROCESSABLE_ENTITY)
57
                        ->respondWithError('Parameters failed validation for a task.');
58
        }
59
60
        Task::create(Input::all());
61
62
        return $this->respondCreated('Task successfully created.');
63
    }
64
65
    /**
66
     * Display the specified resource.
67
     *
68
     * @param  int $id
69
     * @return \Illuminate\Http\Response
70
     */
71 View Code Duplication
    public function show($id)
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...
72
    {
73
        $task = Task::find($id);
74
75
        if (!$task) {
76
            return $this->respondNotFound('Task does not exsist');
77
        }
78
79
        return $this->respond([
80
            'data' => $this->taskTransformer->transform($task)
81
        ]);
82
    }
83
84
    /**
85
     * Show the form for editing the specified resource.
86
     *
87
     * @param  int $id
88
     * @return \Illuminate\Http\Response
89
     */
90
    public function edit($id)
0 ignored issues
show
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
91
    {
92
        //
93
    }
94
95
    /**
96
     * Update the specified resource in storage.
97
     *
98
     * @param  \Illuminate\Http\Request $request
99
     * @param  int $id
100
     * @return \Illuminate\Http\Response
101
     */
102
    public function update(Request $request, $id)
103
    {
104
        $task = Task::find($id);
105
106
        if (!$task)
107
        {
108
            return $this->respondNotFound('Task does not exist!!');
109
        }
110
111
        $task->name = $request->name;
112
        $task->priority = $request->priority;
113
        $task->done = $request->done;
114
        $task->save();
115
    }
116
117
    /**
118
     * Remove the specified resource from storage.
119
     *
120
     * @param  int $id
121
     * @return \Illuminate\Http\Response
122
     */
123
    public function destroy($id)
124
    {
125
        Task::destroy($id);
126
    }
127
}