Issues (93)

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.

macros.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
/*
4
|--------------------------------------------------------------------------
5
| Translatable fields
6
|--------------------------------------------------------------------------
7
*/
8
/**
9
 * Add an input field
10
 * @param string $name The field name
11
 * @param string $title The field title
12
 * @param object $errors The laravel errors object
13
 * @param string $lang the language of the field
14
 * @param null|object $object The entity of the field
15
 */
16
use Illuminate\Support\ViewErrorBag;
17
18
Form::macro('i18nInput', function ($name, $title, ViewErrorBag $errors, $lang, $object = null, array $options = []) {
19
    $options = array_merge(['class' => "form-control", 'placeholder' => $title], $options);
20
21
    $string  = "<div class='form-group " . ($errors->has($lang . '.' . $name) ? ' has-error' : '') . "'>";
22
    $string .= Form::label("{$lang}[{$name}]", $title);
23
24
    if (is_object($object)) {
25
        $currentData = $object->hasTranslation($lang) ? $object->translate($lang)->{$name} : '';
26
    } else {
27
        $currentData = '';
28
    }
29
30
    $string .= Form::text("{$lang}[{$name}]", Input::old("{$lang}[{$name}]", $currentData), $options);
31
    $string .= $errors->first("{$lang}.{$name}", '<span class="help-block">:message</span>');
32
    $string .= "</div>";
33
34
    return $string;
35
});
36
37
/**
38
 * Add a textarea
39
 * @param string $name The field name
40
 * @param string $title The field title
41
 * @param object $errors The laravel errors object
42
 * @param string $lang the language of the field
43
 * @param null|object $object The entity of the field
44
 */
45
Form::macro('i18nTextarea', function ($name, $title, ViewErrorBag $errors, $lang, $object = null, array $options = []) {
46
    $options = array_merge(['class' => 'ckeditor', 'rows' => 10, 'cols' => 10], $options);
47
48
    $string  = "<div class='form-group " . ($errors->has($lang . '.' . $name) ? ' has-error' : '') . "'>";
49
    $string .= Form::label("{$lang}[{$name}]", $title);
50
51
    if (is_object($object)) {
52
        $currentData = $object->hasTranslation($lang) ? $object->translate($lang)->{$name} : '';
53
    } else {
54
        $currentData = '';
55
    }
56
57
    $string .= Form::textarea("{$lang}[$name]", Input::old("{$lang}[{$name}]", $currentData), $options);
58
    $string .= $errors->first("{$lang}.{$name}", '<span class="help-block">:message</span>');
59
    $string .= "</div>";
60
61
    return $string;
62
});
63
64
/**
65
 * Add a checkbox input field
66
 * @param string $name The field name
67
 * @param string $title The field title
68
 * @param object $errors The laravel errors object
69
 * @param string $lang the language of the field
70
 * @param null|object $object The entity of the field
71
 */
72
Form::macro('i18nCheckbox', function ($name, $title, ViewErrorBag $errors, $lang, $object = null) {
73
    $string = "<div class='checkbox" . ($errors->has($lang . '.' . $name) ? ' has-error' : '') . "'>";
74
    $string .= "<label for='{$lang}[{$name}]'>";
75
    $string .= "<input id='{$lang}[{$name}]' name='{$lang}[{$name}]' type='checkbox' class='flat-blue'";
76
77 View Code Duplication
    if (is_object($object)) {
0 ignored issues
show
This code seems to be duplicated across 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...
78
        $currentData = $object->hasTranslation($lang) ? (bool) $object->translate($lang)->{$name} : '';
79
    } else {
80
        $currentData = false;
81
    }
82
83
    $oldInput = Input::old("{$lang}.$name", $currentData) ? 'checked' : '';
0 ignored issues
show
It seems like $currentData can also be of type boolean; however, Illuminate\Http\Request::old() does only seem to accept string|array|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
84
    $string .= "value='1' {$oldInput}>";
85
    $string .= $title;
86
    $string .= $errors->first($name, '<span class="help-block">:message</span>');
87
    $string .= "</label>";
88
    $string .= "</div>";
89
90
    return $string;
91
});
92
93
/*
94
|--------------------------------------------------------------------------
95
| Standard fields
96
|--------------------------------------------------------------------------
97
*/
98
/**
99
 * Add an input field
100
 * @param string $name The field name
101
 * @param string $title The field title
102
 * @param object $errors The laravel errors object
103
 * @param null|object $object The entity of the field
104
 */
105
Form::macro('normalInput', function ($name, $title, ViewErrorBag $errors, $object = null, array $options = []) {
106
    $options = array_merge(['class' => "form-control", 'placeholder' => $title], $options);
107
108
    $string  = "<div class='form-group " . ($errors->has($name) ? ' has-error' : '') . "'>";
109
    $string .= Form::label($name, $title);
110
111
    if (is_object($object)) {
112
        $currentData = $object->{$name} ?: '';
113
    } else {
114
        $currentData = '';
115
    }
116
117
    $string .= Form::text($name, Input::old($name, $currentData), $options);
118
    $string .= $errors->first($name, '<span class="help-block">:message</span>');
119
    $string .= "</div>";
120
121
    return $string;
122
});
123
124
Form::macro('normalTextarea', function ($name, $title, ViewErrorBag $errors, $object = null, array $options = []) {
125
    $options = array_merge(['class' => 'ckeditor', 'rows' => 10, 'cols' => 10], $options);
126
127
    $string  = "<div class='form-group " . ($errors->has($name) ? ' has-error' : '') . "'>";
128
    $string .= Form::label($name, $title);
129
130
    if (is_object($object)) {
131
        $currentData = $object->{$name} ?: '';
132
    } else {
133
        $currentData = '';
134
    }
135
136
    $string .= Form::textarea($name, Input::old($name, $currentData), $options);
137
    $string .= $errors->first($name, '<span class="help-block">:message</span>');
138
    $string .= "</div>";
139
140
    return $string;
141
});
142
143
/**
144
 * Add a checkbox input field
145
 * @param string $name The field name
146
 * @param string $title The field title
147
 * @param object $errors The laravel errors object
148
 * @param null|object $object The entity of the field
149
 */
150
Form::macro('normalCheckbox', function ($name, $title, ViewErrorBag $errors, $object = null) {
151
    $string = "<div class='checkbox" . ($errors->has($name) ? ' has-error' : '') . "'>";
152
    $string .= "<input type='hidden' value='0' name='{$name}'/>";
153
    $string .= "<label for='$name'>";
154
    $string .= "<input id='$name' name='$name' type='checkbox' class='flat-blue'";
155
156 View Code Duplication
    if (is_object($object)) {
0 ignored issues
show
This code seems to be duplicated across 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...
157
        $currentData = isset($object->$name) && (bool) $object->$name ? 'checked' : '';
158
    } else {
159
        $currentData = false;
160
    }
161
162
    $oldInput = Input::old($name, $currentData) ? 'checked' : '';
0 ignored issues
show
It seems like $currentData defined by false on line 159 can also be of type false; however, Illuminate\Http\Request::old() does only seem to accept string|array|null, did you maybe forget to handle an error condition?

This check looks for type mismatches where the missing type is false. This is usually indicative of an error condtion.

Consider the follow example

<?php

function getDate($date)
{
    if ($date !== null) {
        return new DateTime($date);
    }

    return false;
}

This function either returns a new DateTime object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returned false before passing on the value to another function or method that may not be able to handle a false.

Loading history...
163
    $string .= "value='1' {$oldInput}>";
164
    $string .= $title;
165
    $string .= $errors->first($name, '<span class="help-block">:message</span>');
166
    $string .= "</label>";
167
    $string .= "</div>";
168
169
    return $string;
170
});
171