GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (519)

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/UpdateEmailSettings.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
 * Pterodactyl - Panel
4
 * Copyright (c) 2015 - 2017 Dane Everitt <[email protected]>.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7
 * of this software and associated documentation files (the "Software"), to deal
8
 * in the Software without restriction, including without limitation the rights
9
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
 * copies of the Software, and to permit persons to whom the Software is
11
 * furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included in all
14
 * copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
 * SOFTWARE.
23
 */
24
25
namespace Pterodactyl\Console\Commands;
26
27
use Illuminate\Console\Command;
28
29
class UpdateEmailSettings extends Command
30
{
31
    /**
32
     * The name and signature of the console command.
33
     *
34
     * @var string
35
     */
36
    protected $signature = 'pterodactyl:mail
37
                            {--driver=}
38
                            {--email=}
39
                            {--from-name=}
40
                            {--host=}
41
                            {--port=}
42
                            {--username=}
43
                            {--password=}';
44
45
    /**
46
     * The console command description.
47
     *
48
     * @var string
49
     */
50
    protected $description = 'Sets or updates email settings for the .env file.';
51
52
    /**
53
     * Create a new command instance.
54
     *
55
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
56
     */
57
    public function __construct()
58
    {
59
        parent::__construct();
60
    }
61
62
    /**
63
     * Execute the console command.
64
     *
65
     * @return mixed
66
     */
67
    public function handle()
68
    {
69
        $variables = [];
70
        $file = base_path() . '/.env';
71
        if (! file_exists($file)) {
72
            $this->error('Missing environment file! It appears that you have not installed this panel correctly.');
73
            exit();
0 ignored issues
show
Coding Style Compatibility introduced by
The method handle() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
74
        }
75
76
        $envContents = file_get_contents($file);
77
78
        $this->table([
79
            'Option',
80
            'Description',
81
        ], [
82
            [
83
                'smtp',
84
                'SMTP Server Email',
85
            ],
86
            [
87
                'mail',
88
                'PHP\'s Internal Mail Server',
89
            ],
90
            [
91
                'mailgun',
92
                'Mailgun Email Service',
93
            ],
94
            [
95
                'mandrill',
96
                'Mandrill Transactional Email Service',
97
            ],
98
            [
99
                'postmark',
100
                'Postmark Transactional Email Service',
101
            ],
102
        ]);
103
104
        $variables['MAIL_DRIVER'] = is_null($this->option('driver')) ? $this->choice('Which email driver would you like to use?', [
105
            'smtp',
106
            'mail',
107
            'mailgun',
108
            'mandrill',
109
            'postmark',
110
        ]) : $this->option('driver');
111
112
        switch ($variables['MAIL_DRIVER']) {
113
            case 'smtp':
114
                $variables['MAIL_HOST'] = is_null($this->option('host')) ? $this->ask('SMTP Host (e.g smtp.google.com)', config('mail.host')) : $this->option('host');
115
                $variables['MAIL_PORT'] = is_null($this->option('port')) ? $this->anticipate('SMTP Host Port (e.g 587)', ['587', config('mail.port')], config('mail.port')) : $this->option('port');
116
                $variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('SMTP Username', config('mail.username')) : $this->option('password');
117
                $variables['MAIL_PASSWORD'] = is_null($this->option('password')) ? $this->secret('SMTP Password') : $this->option('password');
118
                break;
119
            case 'mail':
120
                break;
121
            case 'mailgun':
122
                $variables['MAILGUN_DOMAIN'] = is_null($this->option('host')) ? $this->ask('Mailgun Domain') : $this->option('host');
123
                $variables['MAILGUN_KEY'] = is_null($this->option('username')) ? $this->ask('Mailgun Key') : $this->option('username');
124
                break;
125
            case 'mandrill':
126
                $variables['MANDRILL_SECRET'] = is_null($this->option('username')) ? $this->ask('Mandrill Secret') : $this->option('username');
127
                break;
128
            case 'postmark':
129
                $variables['MAIL_DRIVER'] = 'smtp';
130
                $variables['MAIL_HOST'] = 'smtp.postmarkapp.com';
131
                $variables['MAIL_PORT'] = 587;
132
                $variables['MAIL_USERNAME'] = is_null($this->option('username')) ? $this->ask('Postmark API Token', config('mail.username')) : $this->option('username');
133
                $variables['MAIL_PASSWORD'] = $variables['MAIL_USERNAME'];
134
                break;
135
            default:
136
                $this->error('No email service was defined!');
137
                exit();
0 ignored issues
show
Coding Style Compatibility introduced by
The method handle() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
138
                break;
0 ignored issues
show
break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
139
        }
140
141
        $variables['MAIL_FROM'] = is_null($this->option('email')) ? $this->ask('Email address emails should originate from', config('mail.from.address')) : $this->option('email');
142
        $variables['MAIL_FROM_NAME'] = is_null($this->option('from-name')) ? $this->ask('Name emails should appear to be from', config('mail.from.name')) : $this->option('from-name');
143
        $variables['MAIL_FROM_NAME'] = '"' . $variables['MAIL_FROM_NAME'] . '"';
144
        $variables['MAIL_ENCRYPTION'] = 'tls';
145
146
        $bar = $this->output->createProgressBar(count($variables));
147
148
        $this->line('Writing new email environment configuration to file.');
149 View Code Duplication
        foreach ($variables as $key => $value) {
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...
150
            if (str_contains($value, ' ') && ! str_contains($value, '"')) {
0 ignored issues
show
It seems like $value defined by $value on line 149 can also be of type array; however, str_contains() 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...
151
                $value = '"' . $value . '"';
152
            }
153
            $newValue = $key . '=' . $value . ' # DO NOT EDIT! set using pterodactyl:mail';
154
155
            if (preg_match_all('/^' . $key . '=(.*)$/m', $envContents) < 1) {
156
                $envContents = $envContents . "\n" . $newValue;
157
            } else {
158
                $envContents = preg_replace('/^' . $key . '=(.*)$/m', $newValue, $envContents);
159
            }
160
            $bar->advance();
161
        }
162
163
        file_put_contents($file, $envContents);
164
        $bar->finish();
165
166
        $this->line('Updating evironment configuration cache file.');
167
        $this->call('config:cache');
168
        echo "\n";
169
    }
170
}
171