Issues (34)

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 (11 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\Task;
6
use Illuminate\Http\Request;
7
8
use App\Http\Requests;
9
use App\Http\Controllers\Controller;
10
use Response;
11
12
class TaskController extends Controller {
13
    /**
14
     * TaskController constructor.
15
     */
16
    public function __construct(){
17
        //$this->middleware('auth:api');
0 ignored issues
show
Unused Code Comprehensibility introduced by
86% 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...
18
    }
19
20
21
    /**
22
     * Display a listing of the resource.
23
     *
24
     * @return \Illuminate\Http\Response
25
     */
26
    public function index() {
27
        // 1. No es retorna: paginacion
28
        //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...
29
30
        $task = Task::all();
31
32
        return Response::json([
33
            'data' => $this->transformCollection($task)
34
            //'data' => $task->toArray()
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
35
        ],200);
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
     * Store a newly created resource in storage.
49
     *
50
     * @param  \Illuminate\Http\Request  $request
51
     * @return \Illuminate\Http\Response
52
     */
53
    public function store(Request $request) {
54
        $task = new Task();
55
56
        $this->saveTask($request, $task);
57
    }
58
59
    /**
60
     * Display the specified resource.
61
     *
62
     * @param  int  $id
63
     * @return \Illuminate\Http\Response
64
     */
65 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...
66
        //return $tag = Task::findOrFail($id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% 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...
67
68
        $task = Task::find($id);
69
70
        if (!$task) {
71
            return Response::json([
72
                'error' => [
73
                    'message' => 'Task does not exist',
74
                    'code' => 195
75
                 ]
76
            ], 404);
77
        }
78
79
        return Response::json([
80
            'data' => $this->transform($task->toArray())
81
            //'data' => $task->toArray()
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
82
        ],200);
83
    }
84
85
    /**
86
     * Show the form for editing the specified resource.
87
     *
88
     * @param  int  $id
89
     * @return \Illuminate\Http\Response
90
     */
91
    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...
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 View Code Duplication
    public function update(Request $request, $id) {
0 ignored issues
show
The parameter $request 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...
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...
103
        //$task = Task::findOrFail($id);
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
104
105
        $task = Task::find($id);
106
107
        if (!$task) {
108
            return Response::json([
109
                'error' => [
110
                    'message' => 'Task does not exist',
111
                    'code' => 195
112
                ]
113
            ], 404);
114
        }
115
116
        return Response::json([
117
            'data' => $task->toArray()
118
        ],200);
119
120
        $this->saveTask($request, $task);
0 ignored issues
show
$this->saveTask($request, $task); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
121
    }
122
123
    /**
124
     * Remove the specified resource from storage.
125
     *
126
     * @param  int  $id
127
     * @return \Illuminate\Http\Response
128
     */
129
    public function destroy($id) {
130
        Task::destroy($id);
131
    }
132
133
    public function transformCollection($task) {
134
        return array_map([$this, 'transform'], $task->toArray());
135
    }
136
137
    private function transform($task){
138
        return [
139
            'name' => $task['name'],
140
            'priority' => (boolean) $task['priority'],
141
            'done' => $task['done']
142
        ];
143
    }
144
145
    /**
146
     * @param Request $request
147
     * @param $tag
148
     */
149
    public function saveTask(Request $request, $task) {
150
        $task->name = $request->name;
151
        $task->priority = $request->priority;
152
        $task->done = $request->done;
153
        $task->save();
154
    }
155
}
156