Issues (305)

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/GroupsController.php (6 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
/*
4
 * This file is part of Gitamin.
5
 *
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gitamin\Http\Controllers;
13
14
use AltThree\Validator\ValidationException;
15
use Gitamin\Commands\Owner\AddOwnerCommand;
16
use Gitamin\Commands\Owner\UpdateOwnerCommand;
17
use Gitamin\Models\Group;
18
use Gitamin\Models\Owner;
19
use Gitamin\Models\Project;
20
use Illuminate\Database\QueryException;
21
use Illuminate\Support\Facades\Auth;
22
use Illuminate\Support\Facades\Redirect;
23
use Illuminate\Support\Facades\Request;
24
use Illuminate\Support\Facades\View;
25
26
class GroupsController extends Controller
27
{
28
    /**
29
     * Shows the project groups view.
30
     *
31
     * @return \Illuminate\View\View
32
     */
33
    public function indexAction()
34
    {
35
        return View::make('groups.index')
36
            ->withPageTitle(trans_choice('gitamin.groups.groups', 2).' - '.trans('dashboard.dashboard'))
37
            ->withGroups(Group::get())
38
            ->withSubMenu($this->subMenu);
0 ignored issues
show
The property subMenu 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...
39
    }
40
41
    /**
42
     * Shows the group view.
43
     *
44
     * @return \Illuminate\View\View
45
     */
46
    public function showAction($path)
47
    {
48
        $group = Group::findByPath($path);
49
50
        return View::make('groups.show')
51
            ->withPageTitle($group->name)
0 ignored issues
show
The property name does not exist on object<Gitamin\Models\User>. 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...
52
            ->withGroup($group);
53
    }
54
55
    /**
56
     * Shows the new project view.
57
     *
58
     * @return \Illuminate\View\View
59
     */
60
    public function newAction()
61
    {
62
        return View::make('groups.new')
63
            ->withPageTitle(trans('dashboard.groups.new.title').' - '.trans('dashboard.dashboard'));
64
    }
65
66
    /**
67
     * Creates a new project.
68
     *
69
     * @return \Illuminate\Http\RedirectResponse
70
     */
71
    public function createAction()
72
    {
73
        $groupData = Request::get('group');
74
        $groupData['type'] = 'group';
75
        $groupData['user_id'] = Auth::user()->id;
76
        try {
77
            $group = $this->dispatchFromArray(AddOwnerCommand::class, $groupData);
0 ignored issues
show
$group 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
        } catch (ValidationException $e) {
79
            return Redirect::route('groups.new')
80
                ->withInput(Request::all())
81
                ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('gitamin.groups.add.failure')))
82
                ->withErrors($e->getMessageBag());
83
        } catch (QueryException $e) {
84
            return Redirect::route('groups.new')
85
                ->withInput(Request::all())
86
                ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('gitamin.groups.add.failure')))
87
                ->withErrors('Path has been used');
88
        }
89
90
        return Redirect::route('dashboard.groups.index')
91
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('gitamin.groups.add.success')));
92
    }
93
94
    /**
95
     * Shows the edit project namespace view.
96
     *
97
     * @param \Gitamin\Models\Owner $namespace
0 ignored issues
show
There is no parameter named $namespace. 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...
98
     *
99
     * @return \Illuminate\View\View
100
     */
101
    public function editAction($path)
102
    {
103
        $group = Group::findByPath($path);
104
105
        return View::make('groups.edit')
106
            ->withPageTitle(trans('gitamin.groups.edit.title').' - '.trans('dashboard.dashboard'))
107
            ->withGroup($group);
108
    }
109
110
    /**
111
     * Updates a project namespace.
112
     *
113
     * @param \Gitamin\Models\Owner $namespace
0 ignored issues
show
There is no parameter named $namespace. 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...
114
     *
115
     * @return \Illuminate\Http\RedirectResponse
116
     */
117 View Code Duplication
    public function updateAction($path)
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...
118
    {
119
        $groupData = Request::get('group');
120
        $group = Owner::where('path', '=', $path)->first();
121
        try {
122
            $groupData['owner'] = $group;
123
            $groupData['user_id'] = Auth::user()->id;
124
            $group = $this->dispatchFromArray(UpdateOwnerCommand::class, $groupData);
125
        } catch (ValidationException $e) {
126
            return Redirect::route('groups.group_edit', ['owner' => $group->path])
127
                ->withInput(Request::all())
128
                ->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('gitamin.groups.edit.failure')))
129
                ->withErrors($e->getMessageBag());
130
        }
131
132
        return Redirect::route('groups.group_edit', ['owner' => $group->path])
133
            ->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('gitamin.groups.edit.success')));
134
    }
135
}
136