Issues (44)

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/Console/Commands/MakeJsonApiDemoRemove.php (3 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\Console\Commands;
4
5
use Illuminate\Console\Command;
6
7
class MakeJsonApiDemoRemove extends Command
8
{
9
    /**
10
     * The name and signature of the console command.
11
     *
12
     * @var string
13
     */
14
    protected $signature = 'make:demo-remove
15
            {--test  : Add files postfix for test}';
16
17
    /**
18
     * The console command description.
19
     *
20
     * @var string
21
     */
22
    protected $description = 'Remove JsonApi Demo entities';
23
24
    protected $testPostfix = '-test';
25
26
    /**
27
     * @var array
28
     */
29
    protected $controllers = [
30
        'LikesController.stub' => 'LikesController.php',
31
        'SkillsController.stub' => 'SkillsController.php',
32
        'TeamsController.stub' => 'TeamsController.php',
33
        'UsersController.stub' => 'UsersController.php'
34
    ];
35
36
    protected $models = [
37
        'Like.stub' => 'Like.php',
38
        'Skill.stub' => 'Skill.php',
39
        'Team.stub' => 'Team.php'
40
    ];
41
42
    protected $migrations = [
43
        'create_likes_table.stub'                   => 'create_likes_table.php',
44
        'create_membership_table.stub'              => 'create_membership_table.php',
45
        'create_skills_table.stub'                  => 'create_skills_table.php',
46
        'create_teams_table.stub'                   => 'create_teams_table.php',
47
        'add_foreign_keys_to_likes_table.stub'      => 'add_foreign_keys_to_likes_table.php',
48
        'add_foreign_keys_to_membership_table.stub' => 'add_foreign_keys_to_membership_table.php',
49
        'add_foreign_keys_to_skills_table.stub'     => 'add_foreign_keys_to_skills_table.php',
50
        'add_foreign_keys_to_teams_table.stub'      => 'add_foreign_keys_to_teams_table.php'
51
    ];
52
53
    protected $seeds = [
54
        'TeamsTableSeeder.stub'     => 'TeamsTableSeeder.php',
55
        'TeamUsersTableSeeder.stub' => 'TeamUsersTableSeeder.php',
56
        'JsonApiSeeder.stub' => 'JsonApiSeeder.php'
57
    ];
58
59
    protected $jsonapiEntities = [
60
        'JsonApi/Likes/Hydrator.stub' => 'JsonApi/Likes/Hydrator.php',
61
        'JsonApi/Likes/Request.stub' => 'JsonApi/Likes/Request.php',
62
        'JsonApi/Likes/Schema.stub' => 'JsonApi/Likes/Schema.php',
63
        'JsonApi/Likes/Search.stub' => 'JsonApi/Likes/Search.php',
64
        'JsonApi/Likes/Validators.stub' => 'JsonApi/Likes/Validators.php',
65
66
        'JsonApi/Skills/Hydrator.stub' => 'JsonApi/Skills/Hydrator.php',
67
        'JsonApi/Skills/Request.stub' => 'JsonApi/Skills/Request.php',
68
        'JsonApi/Skills/Schema.stub' => 'JsonApi/Skills/Schema.php',
69
        'JsonApi/Skills/Search.stub' => 'JsonApi/Skills/Search.php',
70
        'JsonApi/Skills/Validators.stub' => 'JsonApi/Skills/Validators.php',
71
72
        'JsonApi/Teams/Hydrator.stub' => 'JsonApi/Teams/Hydrator.php',
73
        'JsonApi/Teams/Request.stub' => 'JsonApi/Teams/Request.php',
74
        'JsonApi/Teams/Schema.stub' => 'JsonApi/Teams/Schema.php',
75
        'JsonApi/Teams/Search.stub' => 'JsonApi/Teams/Search.php',
76
        'JsonApi/Teams/Validators.stub' => 'JsonApi/Teams/Validators.php',
77
78
        'JsonApi/Users/Hydrator.stub' => 'JsonApi/Users/Hydrator.php',
79
        'JsonApi/Users/Request.stub' => 'JsonApi/Users/Request.php',
80
        'JsonApi/Users/Schema.stub' => 'JsonApi/Users/Schema.php',
81
        'JsonApi/Users/Search.stub' => 'JsonApi/Users/Search.php',
82
        'JsonApi/Users/Validators.stub' => 'JsonApi/Users/Validators.php',
83
    ];
84
85
    /**
86
     * Create a new command instance.
87
     *
88
     */
89
    public function __construct()
90
    {
91
        parent::__construct();
92
    }
93
94
    /**
95
     * Execute the console command.
96
     *
97
     * @return mixed
98
     */
99
    public function handle()
100
    {
101
        if ($this->option('test')) {
102
            $this->setupTest();
103
        }
104
105
        $this->removeJsonApiEntities();
106
        $this->removeModels();
107
        $this->removeControllers();
108
109
        $this->removeSeeds();
110
        $this->removeMigrations();
111
112
        if (!$this->option('test')) {
113
            $this::call('optimize');
114
        }
115
116
        $this->info('JsonApi demo entities removed successfully.');
117
    }
118
119
    /**
120
     *
121
     */
122 View Code Duplication
    protected function setupTest()
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...
123
    {
124
        foreach ($this->migrations as $key => $value) {
125
            $this->migrations[$key] = $value . $this->testPostfix;
126
        }
127
        foreach ($this->seeds as $key => $value) {
128
            $this->seeds[$key] = $value . $this->testPostfix;
129
        }
130
        foreach ($this->controllers as $key => $value) {
131
            $this->controllers[$key] = $value . $this->testPostfix;
132
        }
133
        foreach ($this->models as $key => $value) {
134
            $this->models[$key] = $value . $this->testPostfix;
135
        }
136
        foreach ($this->jsonapiEntities as $key => $value) {
137
            $this->jsonapiEntities[$key] = $value . $this->testPostfix;
138
        }
139
    }
140
141
    /**
142
     *
143
     */
144 View Code Duplication
    protected function removeModels()
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...
145
    {
146
        foreach ($this->models as $key => $value) {
147
            if (file_exists(app_path('Models/' . $value))) {
148
                unlink(app_path('Models/' . $value));
149
            }
150
        }
151
    }
152
153
    /**
154
     *
155
     */
156 View Code Duplication
    protected function removeControllers()
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...
157
    {
158
        foreach ($this->controllers as $key => $value) {
159
            if (file_exists(app_path('Http/Controllers/Api/v1/' . $value))) {
160
                unlink(app_path('Http/Controllers/Api/v1/' . $value));
161
            }
162
        }
163
    }
164
165
    /**
166
     *
167
     */
168
    protected function removeMigrations()
169
    {
170
        foreach ($this->migrations as $key => $value) {
171
            $mask = database_path('migrations/*' . $value);
172
            array_map( "unlink", glob( $mask ) );
173
        }
174
    }
175
176
    /**
177
     *
178
     */
179
    protected function removeSeeds()
180
    {
181
        foreach ($this->seeds as $key => $value) {
182
            if (file_exists(database_path('seeds/' . $value))) {
183
                unlink(database_path('seeds/' . $value));
184
            }
185
        }
186
    }
187
188
    /**
189
     *
190
     */
191
    protected function removeJsonApiEntities()
192
    {
193
        try {
194
            foreach ($this->jsonapiEntities as $key => $value) {
195
                if (file_exists(app_path($value))) {
196
                    unlink(app_path($value));
197
                }
198
            }
199
            if (file_exists(app_path('JsonApi/Users'))) {
200
                rmdir(app_path('JsonApi/Users'));
201
            }
202
203
            if (file_exists(app_path('JsonApi/Likes'))) {
204
                rmdir(app_path('JsonApi/Likes'));
205
            }
206
207
            if (file_exists(app_path('JsonApi/Skills'))) {
208
                rmdir(app_path('JsonApi/Skills'));
209
            }
210
211
            if (file_exists(app_path('JsonApi/Teams'))) {
212
                rmdir(app_path('JsonApi/Teams'));
213
            }
214
215
            if (file_exists(app_path('JsonApi'))) {
216
                if(!@rmdir(app_path('JsonApi'))) {
217
                     throw new \League\Flysystem\Exception('JsonApi directory is not empty!');
218
                };
219
            }
220
        } catch (\League\Flysystem\Exception $e) {
221
            $this->warn($e->getMessage());
222
        }
223
    }
224
}
225