Issues (181)

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.

sources/Commands/AddonMakeCommand.php (7 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 Jumilla\Addomnipot\Laravel\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Filesystem\Filesystem;
7
use Jumilla\Addomnipot\Laravel\Environment as AddonEnvironment;
8
use Jumilla\Addomnipot\Laravel\Generator as AddonGenerator;
9
use UnexpectedValueException;
10
use Exception;
11
12
/**
13
 * Modules console commands.
14
 *
15
 * @author Fumio Furukawa <[email protected]>
16
 */
17
class AddonMakeCommand extends Command
18
{
19
    use Functions;
20
    use MakeCommandTrait;
21
22
    /**
23
     * The console command signature.
24
     *
25
     * @var string
26
     */
27
    protected $signature = 'make:addon
28
        {name : The name of the addon.}
29
        {skeleton? : Skeleton of addon.}
30
        {--space= : Addons space.}
31
        {--namespace= : PHP namespace of addon. Slash OK.}
32
        {--no-namespace : No PHP namespace.}
33
        {--language= : Languages, comma separated.}
34
        {--yes : No confirm.}
35
    ';
36
37
    /**
38
     * The console command description.
39
     *
40
     * @var string
41
     */
42
    protected $description = 'Create a new addon directory';
43
44
    /**
45
     * @var array
46
     */
47
    protected $skeletons = [
48
        1 => 'minimum',
49
        2 => 'simple',
50
        3 => 'asset',
51
        4 => 'library',
52
        5 => 'api',
53
        6 => 'ui',
54
        11 => 'ui-sample',
55
        12 => 'debug',
56
        13 => 'generator',
57
        14 => 'laravel5',
58
        15 => 'laravel5-auth',
59
    ];
60
61
    /**
62
     * @var string
63
     */
64
    protected $default_skeleton = 'ui-sample';
65
66
    /**
67
     * Execute the console command.
68
     *
69
     * @param \Jumilla\Addomnipot\Laravel\Addons\AddonGenerator $generator
70
     *
71
     * @return mixed
72
     */
73
    public function handle(Filesystem $filesystem, AddonEnvironment $env, AddonGenerator $generator)
74
    {
75
        $addon_name = preg_replace('#(/+)#', '-', $this->argument('name'));
76
77
        // Check addon-directory
78
        if ($env->exists($addon_name)) {
0 ignored issues
show
It seems like $addon_name defined by preg_replace('#(/+)#', '...this->argument('name')) on line 75 can also be of type array<integer,string>; however, Jumilla\Addomnipot\Laravel\Environment::exists() does only seem to accept string, 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...
79
            throw new UnexpectedValueException("addon directory '{$addon_name}' is already exists.");
80
        }
81
82
        $output_path = $env->spacePath($this->option('space'), $addon_name);
0 ignored issues
show
It seems like $this->option('space') targeting Illuminate\Console\Command::option() can also be of type array; however, Jumilla\Addomnipot\Larav...nvironment::spacePath() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
It seems like $addon_name defined by preg_replace('#(/+)#', '...this->argument('name')) on line 75 can also be of type array<integer,string>; however, Jumilla\Addomnipot\Larav...nvironment::spacePath() does only seem to accept string|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...
83
84
        // Adjust addon_name
85
        $addon_name = preg_replace('/[^\w_\-]/', '', $addon_name);
86
87
        $addon_class = preg_replace(
88
            ['/[^\w_]/', '/^(\d)/'],
89
            ['', '_$1'],
90
            studly_case($addon_name)
0 ignored issues
show
It seems like $addon_name defined by preg_replace('/[^\\w_\\-]/', '', $addon_name) on line 85 can also be of type array<integer,string>; however, studly_case() does only seem to accept string, 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...
91
        );
92
93
        // namespace
94
        if ($this->option('no-namespace')) {
95
            $namespace = '';
96
        } else {
97
            if ($this->option('namespace')) {
98
                $namespace = str_replace('/', '\\', $this->option('namespace'));
99
            } else {
100
                $namespace = 'App\\'.$addon_class;
101
            }
102
103
            if (! $this->validPhpNamespace($namespace)) {
104
                throw new UnexpectedValueException("PHP namespace '{$namespace}' is invalid.");
105
            }
106
        }
107
108
        // languages
109
        $languages = $this->option('language') ? explode($this->option('language')) : [];
110
111
        // Show select prompt if not specified
112
        $skeleton = $this->chooseSkeleton($this->argument('skeleton'));
0 ignored issues
show
It seems like $this->argument('skeleton') targeting Illuminate\Console\Command::argument() can also be of type array; however, Jumilla\Addomnipot\Larav...Trait::chooseSkeleton() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
113
114
        $properties = [
115
            'addon_name' => $addon_name,
116
            'addon_class' => $addon_class,
117
            'namespace' => $namespace,
118
            'languages' => array_unique(array_merge(['en', $this->laravel['config']->get('app.locale')], $languages)),
119
            'test_namespace' => 'Tests\\'.studly_case($addon_name),
0 ignored issues
show
It seems like $addon_name defined by preg_replace('/[^\\w_\\-]/', '', $addon_name) on line 85 can also be of type array<integer,string>; however, studly_case() does only seem to accept string, 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...
120
        ];
121
122
        // confirm
123
        $this->line('Addon name: '.$properties['addon_name']);
124
        $this->line('PHP namespace: '.$properties['namespace']);
125
        $this->line('Skeleton: '.$skeleton);
126
        $this->line('Languages: '.implode(', ', $properties['languages']));
127
128 View Code Duplication
        if (!$this->option('yes') && !$this->confirm('generate ready? [Y/n]', true)) {
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...
129
            $this->comment('canceled');
130
            return;
131
        }
132
133
        try {
134
            $generator->generateAddon($output_path, str_replace(':', '-', $skeleton), $properties);
135
            $this->info('Addon Generated.');
136
        } catch (Exception $ex) {
137
            $filesystem->deleteDirectory($output_path);
138
139
            throw $ex;
140
        }
141
    }
142
}
143