Issues (69)

Security Analysis    no request data  

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.

src/Http/Controllers/ArticleController.php (5 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 Ergare17\Articles\Http\Controllers;
4
5
use App\User;
6
use Ergare17\Articles\Http\Requests\DestroyArticle;
7
use Ergare17\Articles\Http\Requests\ShowArticle;
8
use Ergare17\Articles\Http\Requests\StoreArticle;
9
use Ergare17\Articles\Http\Requests\UpdateArticle;
10
use Ergare17\Articles\Models\Article;
11
use Illuminate\Http\Request;
12
use Illuminate\Support\Facades\App;
13
use Redirect;
14
use Session;
15
16
class ArticleController extends Controller
17
{
18
    /**
19
     * Display a listing of the resource.
20
     *
21
     * @return \Illuminate\Http\Response
22
     */
23
    public function index()
24
    {
25
        // CRUD -> Retrieve --> List
26
        // BREAD -> Browse Read Edit Add Delete
27
        $articles = Article::all();
28
        return view('articles::list_article', ['articles' => $articles]);
29
    }
30
31
    /**
32
     * Show the form for creating a new resource.
33
     *
34
     * @return \Illuminate\Http\Response
35
     */
36
    public function create()
37
    {
38
        $users = User::all();
39
40
        return view('articles::create_article', ['users' => $users]);
41
    }
42
43
    /**
44
     * Store a newly created resource in storage.
45
     *
46
     * @param  \Illuminate\Http\Request  $request
47
     * @return \Illuminate\Http\Response
48
     */
49
    public function store(StoreArticle $request)
50
    {
51
        Article::create([
0 ignored issues
show
The method create() does not exist on Ergare17\Articles\Models\Article. Did you maybe mean created()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
52
            'title'             => $request->title,
53
            'description'      => $request->description,
54
            'user_id'          => $request->user_id,
55
            'read'        => false,
56
        ]);
57
58
        Session::flash('status', 'Created ok!');
59
        return Redirect::to('/articles_php/create');
60
    }
61
62
    /**
63
     * Display the specified resource.
64
     *
65
     * @param  \App\Article  $article
66
     * @return \Illuminate\Http\Response
67
     */
68
    public function show(ShowArticle $request, Article $article)
69
    {
70
//        return view('show_article',compact('article'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% 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...
71
        return view('articles::show_article', compact('article'));
72
    }
73
74
    /**
75
     * Display the specified resource.
76
     *
77
     * @param  \App\Article  $article
0 ignored issues
show
There is no parameter named $article. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
78
     * @return \Illuminate\Http\Response
79
     */
80
    public function show1($id)
81
    {
82
        dump($id);
83
        dump($article = Article::find($id));
84
85
//        if ($article == null)abort(404);
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% 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...
86
//        try{
87
//            $article = Article::findOrFail($id);
88
//        } catch(\Exception $e){
89
//            abort(404);
90
//        }
91
        $article = Article::findOrFail($id);
92
93
        dump($article->title);
94
//        return $article;
95
    }
96
97
    /**
98
     * Show the form for editing the specified resource.
99
     *
100
     * @param  \App\Article  $article
101
     * @return \Illuminate\Http\Response
102
     */
103
    public function edit(Article $article)
104
    {
105
        $users = User::all();
106
107
        return view('articles::edit_article', ['article' => $article,'users' => $users]);
108
    }
109
110
    /**
111
     * Update the specified resource in storage.
112
     *
113
     * @param  \Illuminate\Http\Request  $request
114
     * @param  \App\Article  $article
115
     * @return \Illuminate\Http\Response
116
     */
117
    public function update(UpdateArticle $request, Article $article)
118
    {
119
        $article->update($request->only(['title','description','user_id']));
120
121
        Session::flash('status', 'Edited ok!');
122
        return Redirect::to('/articles_php/edit/'.$article->id);
0 ignored issues
show
The property id does not exist on object<Ergare17\Articles\Models\Article>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
123
    }
124
125
    /**
126
     * Remove the specified resource from storage.
127
     *
128
     * @param  \App\Article  $article
129
     * @return \Illuminate\Http\Response
130
     */
131
    public function destroy(DestroyArticle $request, Article $article)
132
    {
133
        $article->delete();
134
        Session::flash('status', 'Article was deleted successful!');
135
        return Redirect::to('/articles_php');
136
    }
137
}
138